[FIX] stock_quant_manual_assign: computed field is not the same

This commit is contained in:
agaldona
2017-03-27 16:09:16 +02:00
committed by Tony Gu
parent 37dc136958
commit 54649836ff

View File

@@ -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):