diff --git a/sale_order_batch/README.rst b/sale_order_batch/README.rst index a0c7db4..2b7e934 100644 --- a/sale_order_batch/README.rst +++ b/sale_order_batch/README.rst @@ -41,6 +41,7 @@ Changelog :1.1.1: Remove validity date :2.0.0: Move product logic to sale order lines :2.1.0: Add "In Progress" and "Cancelled" state +:2.1.0: Add invoice status and menues Bug Tracker =========== diff --git a/sale_order_batch/__manifest__.py b/sale_order_batch/__manifest__.py index 01d8331..6afd829 100644 --- a/sale_order_batch/__manifest__.py +++ b/sale_order_batch/__manifest__.py @@ -4,7 +4,7 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "Sale", - "version": "16.0.2.1.0", + "version": "16.0.2.2.0", "depends": ["sale", "product"], "data": [ "data/ir_sequence_data.xml", diff --git a/sale_order_batch/models/sale_order_batch.py b/sale_order_batch/models/sale_order_batch.py index a35f39e..c40b53f 100644 --- a/sale_order_batch/models/sale_order_batch.py +++ b/sale_order_batch/models/sale_order_batch.py @@ -1,5 +1,7 @@ from odoo import _, api, fields, models +from odoo.addons.sale.models.sale_order import INVOICE_STATUS + STATES = [("open", "Open"), ("in_progress", "In Progress"), ("closed", "Closed"), ("cancel", "Cancelled")] READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"closed"}} @@ -42,6 +44,7 @@ class SaleOrderBatch(models.Model): sale_order_line_ids = fields.One2many("sale.order.line", "batch_id", states=READONLY_FIELD_STATES) invoice_ids = fields.Many2many("account.move", compute="_compute_invoice_ids") invoice_count = fields.Integer(compute="_compute_invoice_ids") + invoice_status = fields.Selection(selection=INVOICE_STATUS, compute="_compute_invoice_status", store=True) amount_total = fields.Float(compute="_compute_amount_total", string="Total") product_ids = fields.One2many("sale.order.batch.product", "batch_id") product_count = fields.Integer(compute="_compute_product_count") @@ -59,6 +62,25 @@ class SaleOrderBatch(models.Model): batch.invoice_ids = invoices batch.invoice_count = len(invoices) + @api.depends("sale_order_ids.invoice_status") + def _compute_invoice_status(self): + for batch in self: + if batch.sale_order_ids and any( + invoice_status == "to invoice" for invoice_status in batch.sale_order_ids.mapped("invoice_status") + ): + batch.invoice_status = "to invoice" + elif batch.sale_order_ids and all( + invoice_status == "invoiced" for invoice_status in batch.sale_order_ids.mapped("invoice_status") + ): + batch.invoice_status = "invoiced" + elif batch.sale_order_ids and all( + invoice_status in ("invoiced", "upselling") + for invoice_status in batch.sale_order_ids.mapped("invoice_status") + ): + batch.invoice_status = "upselling" + else: + batch.invoice_status = "no" + @api.depends("sale_order_ids.amount_total") def _compute_amount_total(self): for batch in self: diff --git a/sale_order_batch/readme/HISTORY.rst b/sale_order_batch/readme/HISTORY.rst index 9257f92..a1b5cb6 100644 --- a/sale_order_batch/readme/HISTORY.rst +++ b/sale_order_batch/readme/HISTORY.rst @@ -5,3 +5,4 @@ :1.1.1: Remove validity date :2.0.0: Move product logic to sale order lines :2.1.0: Add "In Progress" and "Cancelled" state +:2.1.0: Add invoice status and menues \ No newline at end of file diff --git a/sale_order_batch/static/description/index.html b/sale_order_batch/static/description/index.html index af0e897..cd417ce 100644 --- a/sale_order_batch/static/description/index.html +++ b/sale_order_batch/static/description/index.html @@ -406,6 +406,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
+ No batches to invoice found +
+