diff options
| author | Rémy Voet (ryv) <ryv@odoo.com> | 2021-03-01 06:56:46 +0000 |
|---|---|---|
| committer | Rémy Voet (ryv) <ryv@odoo.com> | 2021-03-18 12:40:39 +0000 |
| commit | e61ae06572db8aa5d1c3ecea754d3be6719eb55b (patch) | |
| tree | 30083cc1022e0a76e17ae219b0e2c8e777076498 /addons/mrp_subcontracting | |
| parent | 9184ae45e0df179fc093c1fc48a7fa56d8fe9594 (diff) | |
[FIX] mrp_subcontracting: fix subcontracting + MTO
Issue:
In case of MTO on the component tracked by serial of the subcontracted
MO, if the picking generated by the MTO is complete
before record component on the subcontracted picking, when we
record the component, move lines is duplicated, one for the
reservation (due to the MTO chained move) and a other only with the
quantity done. Then it is painful to register component.
Fixes:
Don't the call of `_set_qty_producing()` when we click on
'Record Component', the user should it self applied the `qty_producing`.
closes odoo/odoo#66873
Signed-off-by: Steve Van Essche <svs-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/mrp_subcontracting')
| -rw-r--r-- | addons/mrp_subcontracting/models/mrp_production.py | 12 | ||||
| -rw-r--r-- | addons/mrp_subcontracting/models/stock_picking.py | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/addons/mrp_subcontracting/models/mrp_production.py b/addons/mrp_subcontracting/models/mrp_production.py index e546bf1b034..a0917e15536 100644 --- a/addons/mrp_subcontracting/models/mrp_production.py +++ b/addons/mrp_subcontracting/models/mrp_production.py @@ -128,5 +128,13 @@ class MrpProduction(models.Model): def _subcontracting_filter_to_done(self): """ Filter subcontracting production where composant is already recorded and should be consider to be validate """ - mos = self.filtered(lambda mo: mo.state not in ('done', 'cancel')) - return mos.filtered(lambda pro: all(line.lot_id for line in pro.move_raw_ids.filtered(lambda sm: sm.has_tracking != 'none').move_line_ids)) + def filter_in(mo): + if mo.state in ('done', 'cancel'): + return False + if float_is_zero(mo.qty_producing, precision_rounding=mo.product_uom_id.rounding): + return False + if not all(line.lot_id for line in mo.move_raw_ids.filtered(lambda sm: sm.has_tracking != 'none').move_line_ids): + return False + return True + + return self.filtered(filter_in) diff --git a/addons/mrp_subcontracting/models/stock_picking.py b/addons/mrp_subcontracting/models/stock_picking.py index 4649a0ef673..c5c70510e04 100644 --- a/addons/mrp_subcontracting/models/stock_picking.py +++ b/addons/mrp_subcontracting/models/stock_picking.py @@ -145,7 +145,3 @@ class StockPicking(models.Model): finished_move = mo.move_finished_ids.filtered(lambda m: m.product_id == move.product_id) finished_move.write({'move_dest_ids': [(4, move.id, False)]}) mo.action_assign() - - if move._has_tracked_subcontract_components(): - mo.qty_producing = move.product_uom_qty - mo.with_context(subcontract_move_id=True)._set_qty_producing() |
