[REM] mrp: remove unused fields + Dead code

- Refactor `order_finished_lot_ids` compute, to be linked to the `lot_producing_id`
the the related production (less boiler plate). We can't remove it because
it is used in mrp_subcontracting, and keep the Many2Many, for the tag widget.
Remove the second field compute by this method, `finished_lots_exist` (never used).
- Remove unused field `needs_lots` (also it is a duplication
with `has_tracking` info) from `stock.move` (mrp)
- Remove unused field `done_move` from `stock.move.line` (mrp).
- Remove unused methods `_strict_consumption_check` and `_update_raw_move`.
- Remove unused variables.

odoo/upgrade#1594

closes odoo/odoo#54996

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Rémy Voet (ryv)
2020-08-20 07:01:49 +00:00
parent d1c0a97c18
commit c9c5281827
3 changed files with 3 additions and 64 deletions
-30
View File
@@ -909,35 +909,6 @@ class MrpProduction(models.Model):
move.move_line_ids.filtered(lambda ml: ml.state not in ('done', 'cancel')).qty_done = 0
move.move_line_ids = move._set_quantity_done_prepare_vals(new_qty)
def _update_raw_move(self, bom_line, line_data):
""" :returns update_move, old_quantity, new_quantity """
quantity = line_data['qty']
self.ensure_one()
move = self.move_raw_ids.filtered(lambda x: x.bom_line_id.id == bom_line.id and x.state not in ('done', 'cancel'))
if move:
old_qty = move[0].product_uom_qty
if quantity > 0:
move[0].write({'product_uom_qty': quantity})
move[0]._action_assign()
return move[0], old_qty, quantity
else:
if move[0].quantity_done > 0:
raise UserError(_('Lines need to be deleted, but can not as you still have some quantities to consume in them. '))
move[0]._action_cancel()
move[0].unlink()
return self.env['stock.move'], old_qty, quantity
else:
operation = bom_line.operation_id.id or line_data['parent_line'] and line_data['parent_line'].operation_id.id
move_values = self._get_move_raw_values(
bom_line.product_id,
line_data['qty'],
bom_line.product_uom_id,
operation,
bom_line
)
move = self.env['stock.move'].create(move_values)
return move, 0, quantity
def _update_raw_moves(self, factor):
self.ensure_one()
update_info = []
@@ -963,7 +934,6 @@ class MrpProduction(models.Model):
"""
self.ensure_one()
first_operation = self.bom_id.operation_ids[0]
bom_line_ids = self.env['mrp.bom.line']
if len(self.bom_id.operation_ids) == 1:
moves_in_first_operation = self.move_raw_ids
else:
-10
View File
@@ -781,16 +781,6 @@ class MrpWorkorder(models.Model):
float_round(self.qty_producing, precision_rounding=rounding)
)
def _strict_consumption_check(self):
if self.consumption == 'strict':
for move in self.move_raw_ids:
qty_done = 0.0
for line in move.move_line_ids:
qty_done += line.product_uom_id._compute_quantity(line.qty_done, move.product_uom)
rounding = move.product_uom_id.rounding
if float_compare(qty_done, move.product_uom_qty, precision_rounding=rounding) != 0:
raise UserError(_('You should consume the quantity of %s defined in the BoM. If you want to consume more or less components, change the consumption setting on the BoM.', move.product_id.name))
def _check_sn_uniqueness(self):
""" Alert the user if the serial number as already been produced """
if self.product_tracking == 'serial' and self.finished_lot_id:
+3 -24
View File
@@ -11,7 +11,6 @@ class StockMoveLine(models.Model):
workorder_id = fields.Many2one('mrp.workorder', 'Work Order', check_company=True)
production_id = fields.Many2one('mrp.production', 'Production Order', check_company=True)
done_move = fields.Boolean('Move Done', related='move_id.is_done', readonly=False, store=True) # TDE FIXME: naming
@api.model_create_multi
def create(self, values):
@@ -107,9 +106,7 @@ class StockMove(models.Model):
'Done', compute='_compute_is_done',
store=True,
help='Technical Field to order moves')
needs_lots = fields.Boolean('Tracking', compute='_compute_needs_lots')
order_finished_lot_ids = fields.Many2many('stock.production.lot', string="Finished Lot/Serial Number", compute='_compute_order_finished_lot_ids')
finished_lots_exist = fields.Boolean('Finished Lots Exist', compute='_compute_order_finished_lot_ids')
should_consume_qty = fields.Float('Quantity To Consume', compute='_compute_should_consume_qty')
def _unreserve_initial_demand(self, new_move):
@@ -125,21 +122,10 @@ class StockMove(models.Model):
for move in self:
move.priority = move.raw_material_production_id.priority or move.priority or '0'
@api.depends('raw_material_production_id.move_finished_ids.move_line_ids.lot_id')
@api.depends('raw_material_production_id.lot_producing_id')
def _compute_order_finished_lot_ids(self):
for move in self:
if move.raw_material_production_id.move_finished_ids:
# TODO ryv : to clean in master, finished_lots_exist is never used. order_finished_lot_ids can become one2many instead
finished_lots_ids = move.raw_material_production_id.lot_producing_id
if finished_lots_ids:
move.order_finished_lot_ids = finished_lots_ids
move.finished_lots_exist = True
else:
move.order_finished_lot_ids = False
move.finished_lots_exist = False
else:
move.order_finished_lot_ids = False
move.finished_lots_exist = False
move.order_finished_lot_ids = move.raw_material_production_id.lot_producing_id
@api.depends('raw_material_production_id.bom_id')
def _compute_allowed_operation_ids(self):
@@ -159,11 +145,6 @@ class StockMove(models.Model):
]
move.allowed_operation_ids = self.env['mrp.routing.workcenter'].search(operation_domain)
@api.depends('product_id.tracking')
def _compute_needs_lots(self):
for move in self:
move.needs_lots = move.product_id.tracking != 'none'
@api.depends('raw_material_production_id.is_locked', 'production_id.is_locked')
def _compute_is_locked(self):
super(StockMove, self)._compute_is_locked()
@@ -214,7 +195,7 @@ class StockMove(models.Model):
def _onchange_product_uom_qty(self):
if self.raw_material_production_id and self.has_tracking == 'none':
mo = self.raw_material_production_id
vals = self._update_quantity_done(mo)
self._update_quantity_done(mo)
@api.model
def default_get(self, fields_list):
@@ -431,11 +412,9 @@ class StockMove(models.Model):
def _update_quantity_done(self, mo):
self.ensure_one()
ml_values = {}
new_qty = mo.product_uom_id._compute_quantity((mo.qty_producing - mo.qty_produced) * self.unit_factor, mo.product_uom_id, rounding_method='HALF-UP')
if not self.is_quantity_done_editable:
self.move_line_ids.filtered(lambda ml: ml.state not in ('done', 'cancel')).qty_done = 0
self.move_line_ids = self._set_quantity_done_prepare_vals(new_qty)
else:
self.quantity_done = new_qty
return ml_values