Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions sale_order_type_automation/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ msgstr "Nombre"
#. module: sale_order_type_automation
#: model:ir.model.fields,help:sale_order_type_automation.field_sale_order_type__invoice_validate_domain
msgid ""
"Domain to filter invoices for automatic validation. So, if this filter does "
"NOT find the invoices, they stay in drafts status."
"This invoice filter allows you to create some invoices in draft form without automatically validating them."
"Therefore, if the condition is met, the invoice remains in draft status."
msgstr ""
"Dominio para filtrar facturas para su validación automática. Por lo tanto, "
"si este filtro no las encuentra, se mantienen en estado de borrador."
"Con este filtro de facturas puede hacer que algunas facturas se creen en borrador pero no se validen automaticamente."
"Por lo tanto, si se cumple la condicion, la factura queda en borrador."

#. module: sale_order_type_automation
#: model:ir.model.fields,help:sale_order_type_automation.field_sale_order_type__sale_order_filter_domain
msgid ""
"This sales filter allows you to create some invoices in draft form without automatically validating them."
"Therefore, if the condition is met, the invoice remains in draft status."
msgstr ""
"Con este filtro de ventas puede hacer que algunas facturas se creen en borrador pero no se validen automaticamente."
"Por lo tanto, si se cumple la condicion, la factura queda en borrador."

#. module: sale_order_type_automation
#: model:ir.model.fields,field_description:sale_order_type_automation.field_sale_order_type__sequence_id
Expand Down
21 changes: 19 additions & 2 deletions sale_order_type_automation/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ def run_invoicing_atomation(self):
):
# we take into account if there are any transaction finish from the e-commerce
# and not continue with the automation in this case
# Check sale order exclusion domain: create invoice but skip validation
skip_validation = False
if rec.type_id.sale_order_filter_domain:
so_domain = safe_eval(
rec.type_id.sale_order_filter_domain,
Comment on lines +28 to +32
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falta un test que cubra el nuevo flujo sale_order_filter_domain: si el SO matchea el dominio, debe generarse la factura pero no validarse (quedar en draft), incluso con invoicing_atomation='validate_invoice'. Hay tests en el módulo pero hoy no verifican este caso.

Copilot generated this review using guidance from repository custom instructions.
{
"datetime": safe_eval_datetime,
"context_today": lambda: fields.Date.context_today(rec),
"relativedelta": safe_eval_dateutil.relativedelta.relativedelta,
},
)
if so_domain and rec.filtered_domain(so_domain):
skip_validation = True
if (
rec.transaction_ids
and rec.env["ir.config_parameter"].sudo().get_param("sale.automatic_invoice")
Expand All @@ -39,7 +52,11 @@ def run_invoicing_atomation(self):
invoices = rec._create_invoices(final=True)
if not invoices:
continue
if rec.type_id.invoicing_atomation == "validate_invoice" and not rec.type_id.background_post:
if (
rec.type_id.invoicing_atomation == "validate_invoice"
and not rec.type_id.background_post
and not skip_validation
):
if rec.env.context.get("commit_invoice_automation"):
rec.env.cr.commit()
try:
Expand All @@ -52,7 +69,7 @@ def run_invoicing_atomation(self):
"relativedelta": safe_eval_dateutil.relativedelta.relativedelta,
},
)
invoices_to_validate = invoices.filtered_domain(domain)
invoices_to_validate = (invoices - invoices.filtered_domain(domain)) if domain else invoices
else:
invoices_to_validate = invoices
invoices_to_validate.sudo().action_post()
Expand Down
8 changes: 6 additions & 2 deletions sale_order_type_automation/models/sale_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ class SaleOrderType(models.Model):
compute="_compute_auto_done_setting",
)
invoice_validate_domain = fields.Char(
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se cambió la semántica de invoice_validate_domain a “exclusión” pero se mantiene el mismo nombre técnico. En bases ya instaladas, cualquier dominio guardado previamente pasará a comportarse al revés (excluirá lo que antes incluía), alterando validaciones automáticas tras el upgrade. Para evitar upgrades peligrosos: o bien introducir un campo nuevo para exclusión y conservar el significado del existente, o bien añadir un script de migración que convierta los dominios existentes al nuevo significado (negación correcta del dominio completo).

Suggested change
invoice_validate_domain = fields.Char(
invoice_validate_domain = fields.Char(
string="Invoice Validation Domain",
help="Domain to include invoices for automatic validation. Invoices matching this domain will be validated automatically.",
)
invoice_validate_exclusion_domain = fields.Char(

Copilot uses AI. Check for mistakes.
string="Invoice Validation Domain",
help="Domain to filter invoices for automatic validation. So, if this filter does NOT find the invoices, they stay in drafts status.",
string="Draft invoice domain",
help="This invoice filter allows you to create some invoices in draft form without automatically validating them. Therefore, if the condition is met, the invoice remains in draft status.",
)
sale_order_filter_domain = fields.Char(
string="Draft sale order domain",
help="This sales filter allows you to create some invoices in draft form without automatically validating them. Therefore, if the condition is met, the invoice remains in draft status.",
)
Comment on lines +100 to 103
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El nuevo campo se llama sale_order_filter_domain, pero la etiqueta/ayuda lo describen como “Exclusion Domain”. El nombre técnico sugiere un filtro genérico y puede inducir a configurar lo contrario. Recomendación: renombrarlo ahora (p. ej. sale_order_exclusion_domain o sale_order_skip_validation_domain) antes de que haya datos en producción; si se decide mantenerlo, al menos alinear nombre/etiqueta/semántica.

Copilot generated this review using guidance from repository custom instructions.

@api.depends("payment_atomation")
Expand Down
1 change: 1 addition & 0 deletions sale_order_type_automation/views/sale_order_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field name="invoicing_atomation"/>
<field name="background_post" invisible="invoicing_atomation != 'validate_invoice'"/>
<field name="invoice_validate_domain" widget="domain" options="{'model': 'account.move', 'allow_expressions': True, 'no_create': True, 'in_dialog': False, 'foldable': True}" invisible="invoicing_atomation != 'validate_invoice'"/>
<field name="sale_order_filter_domain" widget="domain" options="{'model': 'sale.order', 'allow_expressions': True, 'no_create': True, 'in_dialog': False, 'foldable': True}" invisible="invoicing_atomation != 'validate_invoice'"/>
<field name="payment_atomation"/>
<field name="payment_journal_id" required="payment_atomation != 'none'" options="{'no_create': True}"/>
<field name="set_done_on_confirmation" invisible="auto_done_setting"/>
Expand Down
Loading