[FIX] uom: useless constrain on purchase UoM

The purchase UoM doesn't interfere with account move line at all so we
can remove this check.

Task id: 1844684
This commit is contained in:
William Henrotin
2018-06-25 09:20:55 +02:00
committed by Simon Lejeune
parent 74737865d5
commit 85f8e4761b
-16
View File
@@ -35,22 +35,6 @@ class ProductTemplate(models.Model):
domain=[('deprecated', '=', False)],
help="The expense is accounted for when a vendor bill is validated, except in anglo-saxon accounting with perpetual inventory valuation in which case the expense (Cost of Goods Sold account) is recognized at the customer invoice validation. If the field is empty, it uses the one defined in the product category.")
@api.multi
def write(self, vals):
#TODO: really? i don't see the reason we'd need that constraint..
check = self.ids and 'uom_po_id' in vals
if check:
self._cr.execute("SELECT id, uom_po_id FROM product_template WHERE id IN %s", [tuple(self.ids)])
uoms = dict(self._cr.fetchall())
res = super(ProductTemplate, self).write(vals)
if check:
self._cr.execute("SELECT id, uom_po_id FROM product_template WHERE id IN %s", [tuple(self.ids)])
if dict(self._cr.fetchall()) != uoms:
products = self.env['product.product'].search([('product_tmpl_id', 'in', self.ids)])
if self.env['account.move.line'].search_count([('product_id', 'in', products.ids)]):
raise UserError(_('You can not change the unit of measure of a product that has been already used in an account journal item. If you need to change the unit of measure, you may deactivate this product.'))
return res
@api.multi
def _get_product_accounts(self):
return {