From 91a3e8b8d6c1c1e6bd823807a2e3459ac94c637d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20G=C3=B6ttsch?= Date: Tue, 25 Mar 2025 21:52:31 +0100 Subject: [PATCH] [imp] sale_order_batch: Add invoice status and menues --- sale_order_batch/README.rst | 1 + sale_order_batch/__manifest__.py | 2 +- sale_order_batch/models/sale_order_batch.py | 22 ++++++++++ sale_order_batch/readme/HISTORY.rst | 1 + .../static/description/index.html | 2 + sale_order_batch/views/sale_menus.xml | 17 +++++++- .../views/sale_order_batch_views.xml | 40 ++++++++++++++++--- 7 files changed, 77 insertions(+), 8 deletions(-) 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 2.1.0:Add “In Progress” and “Cancelled” state +2.1.0:Add invoice status and menues + diff --git a/sale_order_batch/views/sale_menus.xml b/sale_order_batch/views/sale_menus.xml index 82eca0b..44413a8 100644 --- a/sale_order_batch/views/sale_menus.xml +++ b/sale_order_batch/views/sale_menus.xml @@ -1,12 +1,25 @@ + + + diff --git a/sale_order_batch/views/sale_order_batch_views.xml b/sale_order_batch/views/sale_order_batch_views.xml index 6789903..7c9a494 100644 --- a/sale_order_batch/views/sale_order_batch_views.xml +++ b/sale_order_batch/views/sale_order_batch_views.xml @@ -10,6 +10,14 @@ + @@ -185,18 +193,40 @@ - + - - - Sale Order Batches + + Quotation Batches ir.actions.act_window sale.order.batch - tree,form + tree,form,activity {'search_default_filter_batch_open': 1} + + + Order Batches + ir.actions.act_window + sale.order.batch + tree,form,activity + {'search_default_filter_batch_finished': 1} + + + + Batches to Invoice + ir.actions.act_window + sale.order.batch + tree,form,activity + {'create': False} + [('invoice_status','=','to invoice')] + + +

+ No batches to invoice found +

+
+