From 54649836ff4769dde78ae423b091516dd6a0074e Mon Sep 17 00:00:00 2001 From: agaldona Date: Mon, 27 Mar 2017 16:09:16 +0200 Subject: [PATCH] [FIX] stock_quant_manual_assign: computed field is not the same --- .../wizard/assign_manual_quants.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/stock_quant_manual_assign/wizard/assign_manual_quants.py b/stock_quant_manual_assign/wizard/assign_manual_quants.py index 947d2e047..1347b0fcb 100644 --- a/stock_quant_manual_assign/wizard/assign_manual_quants.py +++ b/stock_quant_manual_assign/wizard/assign_manual_quants.py @@ -5,6 +5,7 @@ from openerp import api, exceptions, fields, models, _ import openerp.addons.decimal_precision as dp +from openerp.tools.float_utils import float_compare class AssignManualQuants(models.TransientModel): @@ -13,13 +14,14 @@ class AssignManualQuants(models.TransientModel): @api.multi @api.constrains('quants_lines') def check_qty(self): - for record in self: - if record.quants_lines: - move = self.env['stock.move'].browse( - self.env.context['active_id']) - if record.lines_qty > move.product_qty: - raise exceptions.Warning( - _('Quantity is higher than the needed one')) + precision_digits = dp.get_precision('Product Unit of Measure' + )(self.env.cr)[1] + move = self.env['stock.move'].browse(self.env.context['active_id']) + for record in self.filtered(lambda x: x.quants_lines): + if float_compare(record.lines_qty, move.product_qty, + precision_digits=precision_digits) > 0: + raise exceptions.Warning( + _('Quantity is higher than the needed one')) @api.depends('quants_lines', 'quants_lines.qty') def _compute_qties(self):