[FIX] stock: constrains should raise ValidationError
Before this commit, some constrains rose UserError Which is not compliant with the api.constrains After this commit, the constrains raise ValidationError OPW 1949572 closes odoo/odoo#32444 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.addons import decimal_precision as dp
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tools import float_utils
|
||||
|
||||
|
||||
@@ -148,13 +148,13 @@ class Inventory(models.Model):
|
||||
if self.filter == 'none' and self.product_id and self.location_id and self.lot_id:
|
||||
return
|
||||
if self.filter not in ('product', 'product_owner') and self.product_id:
|
||||
raise UserError(_('The selected inventory options are not coherent.'))
|
||||
raise ValidationError(_('The selected inventory options are not coherent.'))
|
||||
if self.filter != 'lot' and self.lot_id:
|
||||
raise UserError(_('The selected inventory options are not coherent.'))
|
||||
raise ValidationError(_('The selected inventory options are not coherent.'))
|
||||
if self.filter not in ('owner', 'product_owner') and self.partner_id:
|
||||
raise UserError(_('The selected inventory options are not coherent.'))
|
||||
raise ValidationError(_('The selected inventory options are not coherent.'))
|
||||
if self.filter != 'pack' and self.package_id:
|
||||
raise UserError(_('The selected inventory options are not coherent.'))
|
||||
raise ValidationError(_('The selected inventory options are not coherent.'))
|
||||
|
||||
def action_reset_product_qty(self):
|
||||
self.mapped('line_ids').write({'product_qty': 0})
|
||||
@@ -406,7 +406,7 @@ class InventoryLine(models.Model):
|
||||
"""
|
||||
for line in self:
|
||||
if line.product_id.type != 'product':
|
||||
raise UserError(_("You can only adjust stockable products.") + '\n\n%s -> %s' % (line.product_id.display_name, line.product_id.type))
|
||||
raise ValidationError(_("You can only adjust stockable products.") + '\n\n%s -> %s' % (line.product_id.display_name, line.product_id.type))
|
||||
|
||||
def _get_quants(self):
|
||||
return self.env['stock.quant'].search([
|
||||
|
||||
Reference in New Issue
Block a user