From 85f8e4761b9ad1d05ed787de4235fbbdfd33d7dd Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Mon, 18 Jun 2018 15:32:03 +0200 Subject: [PATCH] [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 --- addons/account/models/product.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/addons/account/models/product.py b/addons/account/models/product.py index 4d7e68bb297..bc94da1cccd 100644 --- a/addons/account/models/product.py +++ b/addons/account/models/product.py @@ -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 {