diff --git a/sale_gathering_automation/__manifest__.py b/sale_gathering_automation/__manifest__.py index 751075adc..2f16efbde 100644 --- a/sale_gathering_automation/__manifest__.py +++ b/sale_gathering_automation/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { "name": "Sale Gathering Automation", - "version": "18.0.1.0.0", + "version": "18.0.1.1.0", "category": "Sales & Stock", "sequence": 14, "summary": "", @@ -30,6 +30,9 @@ "sale_gathering", "sale_order_type_automation", ], + "data": [ + "views/sale_order_views.xml", + ], "installable": True, "auto_install": True, "application": False, diff --git a/sale_gathering_automation/models/sale_order.py b/sale_gathering_automation/models/sale_order.py index b18335b90..860a1693f 100644 --- a/sale_gathering_automation/models/sale_order.py +++ b/sale_gathering_automation/models/sale_order.py @@ -14,6 +14,22 @@ class SaleOrder(models.Model): _inherit = "sale.order" + def action_create_invoice_with_automation(self): + self.ensure_one() + if ( + self.is_gathering + and self.state == "sale" + and self.type_id + and self.type_id.invoicing_atomation != "none" + and self.has_gathering_invoice + and any(line.qty_to_invoice for line in self.order_line) + ): + invoices = self.with_context(invoice_gathering=True)._create_invoices(final=True) + self._validate_gathering_invoices(invoices) + return self.action_view_invoice(invoices=invoices) + + return self.env.ref("sale.action_view_sale_advance_payment_inv").read()[0] + def run_invoicing_atomation(self): gathering_lines = self.filtered("is_gathering") super(SaleOrder, gathering_lines.with_context(invoice_gathering=True)).run_invoicing_atomation() diff --git a/sale_gathering_automation/views/sale_order_views.xml b/sale_gathering_automation/views/sale_order_views.xml new file mode 100644 index 000000000..a1285f815 --- /dev/null +++ b/sale_gathering_automation/views/sale_order_views.xml @@ -0,0 +1,15 @@ + + + sale.order.form.gathering.automation + sale.order + + + + + +