From 40d0ca35b362a6d2b6287298e5c6c8e2f647d6e9 Mon Sep 17 00:00:00 2001 From: Tu Nombre Date: Tue, 2 Jul 2024 08:14:56 +0200 Subject: [PATCH] [14.0][IMP] custom_mrp_descarga: Change quartering compute function. --- custom_mrp_descarga/data/ir_sequence.xml | 1 - custom_mrp_descarga/data/mrp_bom_category.xml | 1 - .../data/quartering_product.xml | 1 - custom_mrp_descarga/models/mrp_bom.py | 6 +- custom_mrp_descarga/models/stock_move_line.py | 13 +- .../models/stock_production_lot.py | 9 - custom_mrp_descarga/views/mrp_bom_view.xml | 2 +- .../views/mrp_production_view.xml | 12 +- .../views/product_template_view.xml | 6 +- custom_mrp_descarga/views/saca_line_view.xml | 35 +-- .../views/stock_move_line_view.xml | 234 +++++------------- .../views/stock_production_lot_view.xml | 12 +- .../views/stock_quant_view.xml | 2 +- 13 files changed, 103 insertions(+), 231 deletions(-) diff --git a/custom_mrp_descarga/data/ir_sequence.xml b/custom_mrp_descarga/data/ir_sequence.xml index 0092c2f4d..12532e592 100644 --- a/custom_mrp_descarga/data/ir_sequence.xml +++ b/custom_mrp_descarga/data/ir_sequence.xml @@ -1,4 +1,3 @@ - Secuencia para órdenes de producción de despiece diff --git a/custom_mrp_descarga/data/mrp_bom_category.xml b/custom_mrp_descarga/data/mrp_bom_category.xml index 5a23d0839..a731ca59c 100644 --- a/custom_mrp_descarga/data/mrp_bom_category.xml +++ b/custom_mrp_descarga/data/mrp_bom_category.xml @@ -1,4 +1,3 @@ - Despiece diff --git a/custom_mrp_descarga/data/quartering_product.xml b/custom_mrp_descarga/data/quartering_product.xml index 9d3c57998..95c2023e0 100644 --- a/custom_mrp_descarga/data/quartering_product.xml +++ b/custom_mrp_descarga/data/quartering_product.xml @@ -1,4 +1,3 @@ - Despiece diff --git a/custom_mrp_descarga/models/mrp_bom.py b/custom_mrp_descarga/models/mrp_bom.py index aeba76507..267ef3cfd 100644 --- a/custom_mrp_descarga/models/mrp_bom.py +++ b/custom_mrp_descarga/models/mrp_bom.py @@ -19,8 +19,10 @@ def _compute_quartering(self): for line in self: quartering = False try: - quartering = self.env.ref("custom_mrp_descarga.quartering_category") - if line.category_id == quartering: + quartering_type = self.env.ref( + "custom_mrp_descarga.quartering_category" + ) + if line.category_id == quartering_type: quartering = True except Exception: quartering = False diff --git a/custom_mrp_descarga/models/stock_move_line.py b/custom_mrp_descarga/models/stock_move_line.py index 9910924f6..f62c7bb25 100644 --- a/custom_mrp_descarga/models/stock_move_line.py +++ b/custom_mrp_descarga/models/stock_move_line.py @@ -16,7 +16,7 @@ class StockMoveLine(models.Model): string="Sequence", compute="_compute_sequence", store=True ) quartering = fields.Boolean( - string="Quartering", related="production_id.quartering", store=True + string="Sequence", compute="_compute_sequence", store=True ) saca_date = fields.Date(string="Saca Date", related="saca_line_id.date", store=True) @@ -175,4 +175,15 @@ def write(self, values): if line.move_id.state == "cancel" and values.get("qty_done") != 0: line.move_id.state = "done" line.state = "done" + if "qty_done" or "amount" or "state" in values: + for line in self: + if line.lot_id and line.company_id.paasa: + quartering = line.lot_id.move_line_ids.filtered( + lambda c: c.production_id + and c.production_id.quartering + and (c.location_id == c.production_id.location_src_id) + ) + for record in quartering: + if record.standard_price != line.lot_id.average_price: + record.standard_price = line.lot_id.average_price return result diff --git a/custom_mrp_descarga/models/stock_production_lot.py b/custom_mrp_descarga/models/stock_production_lot.py index 3deacb182..e962af2dd 100644 --- a/custom_mrp_descarga/models/stock_production_lot.py +++ b/custom_mrp_descarga/models/stock_production_lot.py @@ -22,21 +22,12 @@ def _compute_average_price(self): clasified = line.move_line_ids.filtered( lambda c: c.state == "done" and (c.location_dest_id.usage == "internal") ) - quartering = line.move_line_ids.filtered( - lambda c: c.production_id - and c.production_id.quartering - and (c.location_id == c.production_id.location_src_id) - ) if clasified: amount_total = sum(clasified.mapped("amount")) qty_done = sum(clasified.mapped("qty_done")) if qty_done != 0: average_price = amount_total / qty_done line.average_price = average_price - if line.company_id.paasa and average_price: - for record in quartering: - if record.standard_price != line.average_price: - record.standard_price = line.average_price def action_view_move_lines(self): context = self.env.context.copy() diff --git a/custom_mrp_descarga/views/mrp_bom_view.xml b/custom_mrp_descarga/views/mrp_bom_view.xml index 4751c2bf8..99ef7c2e7 100644 --- a/custom_mrp_descarga/views/mrp_bom_view.xml +++ b/custom_mrp_descarga/views/mrp_bom_view.xml @@ -5,7 +5,7 @@ - + diff --git a/custom_mrp_descarga/views/mrp_production_view.xml b/custom_mrp_descarga/views/mrp_production_view.xml index 21e1f29a4..4d7f39cac 100644 --- a/custom_mrp_descarga/views/mrp_production_view.xml +++ b/custom_mrp_descarga/views/mrp_production_view.xml @@ -100,10 +100,12 @@ mrp.production - primary - + + 1 + + mrp.production -
- - - - - - - + + + + + + + diff --git a/custom_mrp_descarga/views/stock_move_line_view.xml b/custom_mrp_descarga/views/stock_move_line_view.xml index ce318af88..85f405b38 100644 --- a/custom_mrp_descarga/views/stock_move_line_view.xml +++ b/custom_mrp_descarga/views/stock_move_line_view.xml @@ -2,131 +2,60 @@ stock.move.line - + - + - - - - + + + + stock.move.line - + - + - + stock.move.line - + sequence desc qty_done == 0 - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -136,61 +65,42 @@ stock.move.line - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + stock.move.line - + - - + + - + - - - + + + @@ -199,14 +109,11 @@ stock.move.line.search.view stock.move.line primary - 100 - + 30 + - - + + [('lot_id','=ilike',str(self)+'%')] @@ -216,11 +123,9 @@ stock.move.line ir.actions.act_window tree,form - + - ['|', ('move_id.raw_material_production_id', '!=', False), ('move_id.production_id', '!=', False), '|',('move_id.raw_material_production_id.quartering', '=', False), ('move_id.production_id.quartering', '=', False), '|', ('move_id.production_id.paasa', '=', True), ('move_id.raw_material_production_id.paasa', '=', True), ('state', '=', 'done')] + ['|', ('move_id.raw_material_production_id', '!=', False), ('move_id.production_id', '!=', False), '|',('move_id.raw_material_production_id.quartering', '=', False), ('move_id.production_id.quartering', '=', False), '|', ('move_id.production_id.paasa', '=', True), ('move_id.raw_material_production_id.paasa', '=', True), ('state', '=', 'done')] @@ -228,32 +133,15 @@ stock.move.line ir.actions.act_window tree,form - - + + [('quartering', '=', True)] - {"search_default_todo": 1, "search_default_groupby_production": 1} + {"search_default_todo": 1, "search_default_groupby_production": 1} - + - + tree,form,pivot diff --git a/custom_mrp_descarga/views/stock_production_lot_view.xml b/custom_mrp_descarga/views/stock_production_lot_view.xml index 6d926771c..79e8d7ca8 100644 --- a/custom_mrp_descarga/views/stock_production_lot_view.xml +++ b/custom_mrp_descarga/views/stock_production_lot_view.xml @@ -2,19 +2,13 @@ stock.production.lot - +
-
- +
diff --git a/custom_mrp_descarga/views/stock_quant_view.xml b/custom_mrp_descarga/views/stock_quant_view.xml index ac98ade64..518fde14f 100644 --- a/custom_mrp_descarga/views/stock_quant_view.xml +++ b/custom_mrp_descarga/views/stock_quant_view.xml @@ -2,7 +2,7 @@ stock.quant - + Total Qty Available