diff --git a/sale_order_batch/README.rst b/sale_order_batch/README.rst index e370d9b..a0c7db4 100644 --- a/sale_order_batch/README.rst +++ b/sale_order_batch/README.rst @@ -40,6 +40,7 @@ Changelog :1.1.0: Make validity_date persistent, add batches to SO views :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 Bug Tracker =========== diff --git a/sale_order_batch/__manifest__.py b/sale_order_batch/__manifest__.py index 59c437f..01d8331 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.0.0", + "version": "16.0.2.1.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 b368dfc..a35f39e 100644 --- a/sale_order_batch/models/sale_order_batch.py +++ b/sale_order_batch/models/sale_order_batch.py @@ -1,9 +1,8 @@ from odoo import _, api, fields, models -STATES = [("open", "Open"), ("close", "Close")] - -READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"close"}} +STATES = [("open", "Open"), ("in_progress", "In Progress"), ("closed", "Closed"), ("cancel", "Cancelled")] +READONLY_FIELD_STATES = {state: [("readonly", True)] for state in {"closed"}} class SaleOrderBatch(models.Model): @@ -27,26 +26,20 @@ class SaleOrderBatch(models.Model): comodel_name="res.company", required=True, index=True, default=lambda self: self.env.company ) state = fields.Selection( - selection=[("open", "Open"), ("closed", "Closed")], - string="Status", - readonly=True, - copy=False, - index=True, - tracking=1, - default="open", + selection=STATES, string="Status", readonly=True, copy=False, index=True, tracking=1, default="open" ) date_order = fields.Datetime( string="Order Date", required=True, readonly=False, copy=False, - states={"closed": [("readonly", True)]}, + states=READONLY_FIELD_STATES, help="Creation date of order batch,\nConfirmation date of confirmed orders.", default=fields.Datetime.now, ) sale_order_ids = fields.One2many("sale.order", "batch_id") sale_order_count = fields.Integer(compute="_compute_sale_order_count") - sale_order_line_ids = fields.One2many("sale.order.line", "batch_id") + 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") amount_total = fields.Float(compute="_compute_amount_total", string="Total") @@ -126,11 +119,26 @@ class SaleOrderBatch(models.Model): action["context"] = {"default_move_type": "out_invoice"} return action + def action_in_progress(self): + for batch in self: + batch.sale_order_line_ids._validate_analytic_distribution() + orders = batch.sale_order_ids + orders.update({"state": "sent"}) + batch.update({"state": "in_progress"}) + return True + def action_confirm(self): for batch in self: orders = batch.with_context(bypass_batch=True).sale_order_ids orders.action_confirm() - batch.state = "closed" + batch.update({"state": "closed"}) + return True + + def action_cancel(self): + for batch in self: + orders = batch.sale_order_ids + orders.action_cancel() + batch.update({"state": "cancel"}) return True @api.model_create_multi diff --git a/sale_order_batch/models/sale_order_batch_product.py b/sale_order_batch/models/sale_order_batch_product.py index 1c4b327..6bb4911 100644 --- a/sale_order_batch/models/sale_order_batch_product.py +++ b/sale_order_batch/models/sale_order_batch_product.py @@ -1,5 +1,7 @@ from odoo import api, fields, models +from .sale_order_batch import READONLY_FIELD_STATES + class SaleOrderBatchProduct(models.Model): """Show Products available in Sale Order Batch""" @@ -21,7 +23,7 @@ class SaleOrderBatchProduct(models.Model): product_template_id = fields.Many2one( "product.template", related="product_id.product_tmpl_id", string="Product Template" ) - sale_order_line_ids = fields.One2many("sale.order.line", "batch_product_id") + sale_order_line_ids = fields.One2many("sale.order.line", "batch_product_id", states=READONLY_FIELD_STATES) product_uom_category_id = fields.Many2one(related="product_id.uom_id.category_id", depends=["product_id"]) product_uom_qty = fields.Float(compute="_compute_uom_qty", string="Quantity") product_uom = fields.Many2one(related="product_id.uom_id") diff --git a/sale_order_batch/readme/HISTORY.rst b/sale_order_batch/readme/HISTORY.rst index 5b08b64..9257f92 100644 --- a/sale_order_batch/readme/HISTORY.rst +++ b/sale_order_batch/readme/HISTORY.rst @@ -4,3 +4,4 @@ :1.1.0: Make validity_date persistent, add batches to SO views :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 diff --git a/sale_order_batch/static/description/index.html b/sale_order_batch/static/description/index.html index 3bbaf3f..af0e897 100644 --- a/sale_order_batch/static/description/index.html +++ b/sale_order_batch/static/description/index.html @@ -404,6 +404,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation 2.0.0:Move product logic to sale order lines +2.1.0:Add “In Progress” and “Cancelled” state + diff --git a/sale_order_batch/views/sale_order_batch_product_views.xml b/sale_order_batch/views/sale_order_batch_product_views.xml index ee5d099..4f0b7e9 100644 --- a/sale_order_batch/views/sale_order_batch_product_views.xml +++ b/sale_order_batch/views/sale_order_batch_product_views.xml @@ -5,6 +5,9 @@ sale.order.batch.product
+
+ +
@@ -23,12 +26,7 @@ - - + diff --git a/sale_order_batch/views/sale_order_batch_views.xml b/sale_order_batch/views/sale_order_batch_views.xml index dd80a76..6789903 100644 --- a/sale_order_batch/views/sale_order_batch_views.xml +++ b/sale_order_batch/views/sale_order_batch_views.xml @@ -21,6 +21,24 @@
+
- + @@ -117,11 +143,7 @@ - + @@ -162,13 +184,14 @@ sale.order.batch - - + + + + Sale Order Batches ir.actions.act_window