Skip to content
Snippets Groups Projects
Commit ee8fbcbe authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] mrp: same unique SN

- Create a product with unique SN, create a BOM for this product
- Create a MO to produce 2 units
- Produce the first unit, create a lot number
- Produce the second unit, use the previously created lot number

Nothing prevents the user to do this. However, the user won't be able to
set the MO as "Done", but it is better to prevent the issue as soon as
possible.

opw-724944
parent 48c773de
Branches
Tags
No related merge requests found
......@@ -3244,7 +3244,13 @@ msgid "You can not delete a Bill of Material with running manufacturing orders.\
msgstr ""
#. module: mrp
#: code:addons/mrp/models/stock_move.py:123
#: code:addons/mrp/models/stock_move.py:40
#, python-format
msgid "You can only produce 1.0 %s for products with unique serial number."
msgstr ""
#. module: mrp
#: code:addons/mrp/models/stock_move.py:135
#, python-format
msgid "You cannot cancel a move move having already consumed material"
msgstr ""
......
......@@ -29,13 +29,15 @@ class StockMoveLots(models.Model):
plus_visible = fields.Boolean("Plus Visible", compute='_compute_plus')
@api.one
@api.constrains('lot_id')
@api.constrains('lot_id', 'quantity_done')
def _check_lot_id(self):
if self.move_id.product_id.tracking == 'serial':
lots = set([])
for move_lot in self.move_id.move_lot_ids.filtered(lambda r: not r.lot_produced_id):
if move_lot.lot_id in lots:
raise exceptions.UserError(_('You cannot use the same serial number in two different lines.'))
if float_compare(move_lot.quantity_done, 1.0, precision_rounding=move_lot.product_id.uom_id.rounding) == 1:
raise exceptions.UserError(_('You can only produce 1.0 %s for products with unique serial number.') % move_lot.product_id.uom_id.name)
lots.add(move_lot.lot_id)
def _compute_plus(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment