From b26a4c78091e39de92b98b64edcc6dbd821214a6 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Tue, 27 Sep 2016 11:15:27 +0200 Subject: [PATCH] [FIX] computation of remaining qty [FIX] test_flake8 [FIX] - use the already existing field product_qty - fix picking edition by warehouse user due to related none readonly field --- stock_quant_manual_assign/models/stock_picking.py | 2 +- .../wizard/assign_manual_quants.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/stock_quant_manual_assign/models/stock_picking.py b/stock_quant_manual_assign/models/stock_picking.py index da3f07761..86880446a 100644 --- a/stock_quant_manual_assign/models/stock_picking.py +++ b/stock_quant_manual_assign/models/stock_picking.py @@ -19,4 +19,4 @@ class StockMove(models.Model): _inherit = 'stock.move' picking_type_code = fields.Selection( - related='picking_type_id.code', store=True) + related='picking_type_id.code', store=True, readonly=True) diff --git a/stock_quant_manual_assign/wizard/assign_manual_quants.py b/stock_quant_manual_assign/wizard/assign_manual_quants.py index 1358687f6..c1b8a2d12 100644 --- a/stock_quant_manual_assign/wizard/assign_manual_quants.py +++ b/stock_quant_manual_assign/wizard/assign_manual_quants.py @@ -17,20 +17,18 @@ class AssignManualQuants(models.TransientModel): if record.quants_lines: move = self.env['stock.move'].browse( self.env.context['active_id']) - move_qty = self.env['product.uom']._compute_qty_obj( - move.product_uom, move.product_uom_qty, move.product_id.uom_id) - if record.lines_qty > move_qty: + if record.lines_qty > move.product_qty: raise exceptions.Warning( _('Quantity is higher than the needed one')) @api.depends('quants_lines', 'quants_lines.qty') def _compute_qties(self): move = self.env['stock.move'].browse(self.env.context['active_id']) - lines_qty = sum(self.quants_lines.mapped('qty')) + + lines_qty = sum(quant_line.qty for quant_line in self.quants_lines + if quant_line.selected) self.lines_qty = lines_qty - move_qty = self.env['product.uom']._compute_qty_obj( - move.product_uom, move.product_uom_qty, move.product_id.uom_id) - self.move_qty = move_qty - lines_qty + self.move_qty = move.product_qty - lines_qty name = fields.Char(string='Name') lines_qty = fields.Float(