diff options
| author | Andrea Grazioso (agr-odoo) <agr@odoo.com> | 2021-04-02 12:46:07 +0000 |
|---|---|---|
| committer | Andrea Grazioso (agr-odoo) <agr@odoo.com> | 2021-04-07 11:10:13 +0000 |
| commit | 43b77d47db090368eb9c241925dc6e9421208295 (patch) | |
| tree | 756a31503f6a226bf54eb0091445ae2e96cb1955 /addons/mrp | |
| parent | 4b0f86107e9ecaf734ebc95ccc0013cc25c65e64 (diff) | |
[FIX] mrp: deny deleting move related to MO
- Create a MO for a product and add a component. Save
- Look for the stock move of the MO, delete the move going from
Virtual Locations/Production to WH/Stock
- Back to the MO, Confirm it
- An error related to the producing quantity will be raised
opw-2478546
closes odoo/odoo#68698
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons/mrp')
| -rw-r--r-- | addons/mrp/i18n/mrp.pot | 6 | ||||
| -rw-r--r-- | addons/mrp/models/stock_move.py | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/addons/mrp/i18n/mrp.pot b/addons/mrp/i18n/mrp.pot index 9375e83a2ad..a4dc5e4ebd8 100644 --- a/addons/mrp/i18n/mrp.pot +++ b/addons/mrp/i18n/mrp.pot @@ -3054,6 +3054,12 @@ msgid "Plastic Laminate" msgstr "" #. module: mrp +#: code:addons/mrp/models/stock_move.py:0 +#, python-format +msgid "Please delete the Manufacture Order first." +msgstr "" + +#. module: mrp #: model:product.product,name:mrp.product_product_wood_ply #: model:product.template,name:mrp.product_product_wood_ply_product_template msgid "Ply Layer" diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 1ab6538f19b..a763380185a 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -204,6 +204,13 @@ class StockMove(models.Model): defaults['additional'] = True return defaults + def unlink(self): + # Avoid deleting move related to active MO + for move in self: + if move.production_id and move.production_id.state not in ('draft', 'cancel'): + raise UserError(_('Please cancel the Manufacture Order first.')) + return super(StockMove, self).unlink() + def _action_assign(self): res = super(StockMove, self)._action_assign() for move in self.filtered(lambda x: x.production_id or x.raw_material_production_id): |
