From d2951fadcd119776c346f60dec5f7521e870968e Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Tue, 19 Feb 2019 12:35:43 +0000 Subject: [PATCH] [FIX] mrp: remove unused code Commit 5ef46664a25923e6f9e632fd10e031d4a2e81c26 change the workorder model but some of the old fields was not removed. This clean all the occurence of these unused part of code. --- addons/mrp/models/mrp_abstract_workorder.py | 4 ++-- addons/mrp/models/mrp_production.py | 4 ++-- addons/mrp/models/mrp_workorder.py | 3 --- addons/mrp/models/stock_move.py | 20 +++----------------- addons/mrp/views/stock_move_views.xml | 3 +-- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/addons/mrp/models/mrp_abstract_workorder.py b/addons/mrp/models/mrp_abstract_workorder.py index 4a6e65648e4..c4673041ba9 100644 --- a/addons/mrp/models/mrp_abstract_workorder.py +++ b/addons/mrp/models/mrp_abstract_workorder.py @@ -136,7 +136,7 @@ class MrpAbstractWorkorder(models.AbstractModel): 'qty_to_consume': to_consume_in_line, 'qty_reserved': move_line.product_uom_qty, 'lot_id': move_line.lot_id.id, - 'qty_done': is_tracked and 0 or to_consume_in_line + 'qty_done': to_consume_in_line } lines.append(line) qty_to_consume -= to_consume_in_line @@ -159,7 +159,7 @@ class MrpAbstractWorkorder(models.AbstractModel): 'product_id': move.product_id.id, 'product_uom_id': move.product_uom.id, 'qty_to_consume': qty_to_consume, - 'qty_done': is_tracked and 0 or qty_to_consume + 'qty_done': qty_to_consume } lines.append(line) return lines diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index ba2afbc20dc..23eebb40276 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -825,8 +825,8 @@ class MrpProduction(models.Model): moves_to_finish = order.move_finished_ids.filtered(lambda x: x.state not in ('done','cancel')) moves_to_finish._action_done() order.action_assign() - consume_move_lines = moves_to_do.mapped('active_move_line_ids') - for moveline in moves_to_finish.mapped('active_move_line_ids'): + consume_move_lines = moves_to_do.mapped('move_line_ids') + for moveline in moves_to_finish.mapped('move_line_ids'): if moveline.product_id == order.product_id and moveline.move_id.has_tracking != 'none': if any([not ml.lot_produced_id for ml in consume_move_lines]): raise UserError(_('You can not consume without telling for which lot you consumed it')) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 9991be74969..7c70141d73c 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -209,9 +209,6 @@ class MrpWorkorder(models.Model): 'location_dest_id': by_product_move.location_dest_id.id, } - def _link_to_quality_check(self, old_move_line, new_move_line): - return True - @api.multi def record_production(self): if not self: diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 85822eaa519..c04cdb2a063 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -16,7 +16,6 @@ class StockMoveLine(models.Model): lot_produced_qty = fields.Float( 'Quantity Finished Product', digits=dp.get_precision('Product Unit of Measure'), help="Informative, not used in matching") - done_wo = fields.Boolean('Done for Work Order', default=True, help="Technical Field which is False when temporarily filled in in work order") # TDE FIXME: naming done_move = fields.Boolean('Move Done', related='move_id.is_done', readonly=False, store=True) # TDE FIXME: naming def _get_similar_move_lines(self): @@ -24,12 +23,11 @@ class StockMoveLine(models.Model): if self.move_id.production_id: finished_moves = self.move_id.production_id.move_finished_ids finished_move_lines = finished_moves.mapped('move_line_ids') - lines |= finished_move_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name) and ml.done_wo == self.done_wo) + lines |= finished_move_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name)) if self.move_id.raw_material_production_id: raw_moves = self.move_id.raw_material_production_id.move_raw_ids raw_moves_lines = raw_moves.mapped('move_line_ids') - raw_moves_lines |= self.move_id.active_move_line_ids - lines |= raw_moves_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name) and ml.done_wo == self.done_wo) + lines |= raw_moves_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name)) return lines def _reservation_is_updatable(self, quantity, reserved_quant): @@ -46,7 +44,7 @@ class StockMoveLine(models.Model): for move_line in self: if move_line.move_id.production_id and 'lot_id' in vals: move_line.production_id.move_raw_ids.mapped('move_line_ids')\ - .filtered(lambda r: r.done_wo and not r.done_move and r.lot_produced_id == move_line.lot_id)\ + .filtered(lambda r: not r.done_move and r.lot_produced_id == move_line.lot_id)\ .write({'lot_produced_id': vals['lot_id']}) production = move_line.move_id.production_id or move_line.move_id.raw_material_production_id if production and move_line.state == 'done' and any(field in vals for field in ('lot_id', 'location_id', 'qty_done')): @@ -71,7 +69,6 @@ class StockMove(models.Model): workorder_id = fields.Many2one( 'mrp.workorder', 'Work Order To Consume') # Quantities to process, in normalized UoMs - active_move_line_ids = fields.One2many('stock.move.line', 'move_id', domain=[('done_wo', '=', True)], string='Lots') bom_line_id = fields.Many2one('mrp.bom.line', 'BoM Line') unit_factor = fields.Float('Unit Factor') is_done = fields.Boolean( @@ -89,10 +86,6 @@ class StockMove(models.Model): .filtered(lambda ml: ml.qty_done == 0.0)\ .write({'move_id': new_move, 'product_uom_qty': 0}) - @api.depends('active_move_line_ids.qty_done', 'active_move_line_ids.product_uom_id') - def _compute_done_quantity(self): - super(StockMove, self)._compute_done_quantity() - @api.depends('raw_material_production_id.move_finished_ids.move_line_ids.lot_id') def _compute_order_finished_lot_ids(self): for move in self: @@ -116,13 +109,6 @@ class StockMove(models.Model): if move.raw_material_production_id: move.is_locked = move.raw_material_production_id.is_locked - def _get_move_lines(self): - self.ensure_one() - if self.raw_material_production_id: - return self.active_move_line_ids - else: - return super(StockMove, self)._get_move_lines() - @api.depends('state') def _compute_is_done(self): for move in self: diff --git a/addons/mrp/views/stock_move_views.xml b/addons/mrp/views/stock_move_views.xml index ef531c2cc45..46b52a10513 100644 --- a/addons/mrp/views/stock_move_views.xml +++ b/addons/mrp/views/stock_move_views.xml @@ -49,7 +49,7 @@ - + @@ -61,7 +61,6 @@ -