[IMP] repair: improve constraint error message
* Private method * Clearer and more complete error message, specifying all erroneous records Task Id: 2328664 COM PR: https://github.com/odoo/odoo/pull/55525 ENT PR: https://github.com/odoo/enterprise/pull/12250
This commit is contained in:
@@ -652,9 +652,14 @@ class RepairLine(models.Model):
|
||||
help='The status of a repair line is set automatically to the one of the linked repair order.')
|
||||
|
||||
@api.constrains('lot_id', 'product_id')
|
||||
def constrain_lot_id(self):
|
||||
for line in self.filtered(lambda x: x.product_id.tracking != 'none' and not x.lot_id):
|
||||
raise ValidationError(_("Serial number is required for operation line with product '%s'") % (line.product_id.name))
|
||||
def _check_product_tracking(self):
|
||||
invalid_lines = self.filtered(lambda x: x.product_id.tracking != 'none' and not x.lot_id)
|
||||
if invalid_lines:
|
||||
products = invalid_lines.product_id
|
||||
raise ValidationError(_(
|
||||
"Serial number is required for operation lines with products: %s",
|
||||
", ".join(products.mapped('name')),
|
||||
))
|
||||
|
||||
@api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'repair_id.invoice_method')
|
||||
def _compute_price_subtotal(self):
|
||||
|
||||
Reference in New Issue
Block a user