diff --git a/sale_order_type_automation/i18n/es.po b/sale_order_type_automation/i18n/es.po
index 4d17646fa..801aad5f4 100644
--- a/sale_order_type_automation/i18n/es.po
+++ b/sale_order_type_automation/i18n/es.po
@@ -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
diff --git a/sale_order_type_automation/models/sale_order.py b/sale_order_type_automation/models/sale_order.py
index 00f6a5b10..61fe83d61 100644
--- a/sale_order_type_automation/models/sale_order.py
+++ b/sale_order_type_automation/models/sale_order.py
@@ -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,
+ {
+ "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")
@@ -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:
@@ -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()
diff --git a/sale_order_type_automation/models/sale_order_type.py b/sale_order_type_automation/models/sale_order_type.py
index a87010887..30ad052a7 100644
--- a/sale_order_type_automation/models/sale_order_type.py
+++ b/sale_order_type_automation/models/sale_order_type.py
@@ -94,8 +94,12 @@ class SaleOrderType(models.Model):
compute="_compute_auto_done_setting",
)
invoice_validate_domain = fields.Char(
- 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.",
)
@api.depends("payment_atomation")
diff --git a/sale_order_type_automation/views/sale_order_type_views.xml b/sale_order_type_automation/views/sale_order_type_views.xml
index ee3868fed..f39797d8a 100644
--- a/sale_order_type_automation/views/sale_order_type_views.xml
+++ b/sale_order_type_automation/views/sale_order_type_views.xml
@@ -11,6 +11,7 @@
+