[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
This commit is contained in:
jbeficent
2016-09-27 11:15:27 +02:00
committed by Tony Gu
parent a3480babb7
commit b26a4c7809
2 changed files with 6 additions and 8 deletions

View File

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

View File

@@ -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(