Skip to content

Commit

Permalink
[FIX] stock: constrains should raise ValidationError
Browse files Browse the repository at this point in the history
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 #32444

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
  • Loading branch information
kebeclibre committed Apr 5, 2019
1 parent 741ffc4 commit 6524b79
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addons/stock/models/stock_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -148,13 +148,13 @@ def _check_filter_product(self):
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})
Expand Down Expand Up @@ -406,7 +406,7 @@ def _check_product_id(self):
"""
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([
Expand Down

0 comments on commit 6524b79

Please sign in to comment.