Skip to content
Permalink
Browse files

[FIX] sale_mrp, sale_stock: No delivered_qty computed with partial de…

…livery

Steps to reproduce the bug:
- Create a consumable or storable final product A with invoicing policy
in "delivered quantity"
- Create two storable products B and C
- Create a BOM kit for A with 1 B and 1 C
- Create a SO with 5 qty of A and confirm it
- Deliver 3 B and 2 C and either on "No backorder" or "With backorder"

Bug:

The delivered_qty on the SO line is of course not automatically updated
(as in this case, a right value is not computable) but the delivered_qty
was not updatable  manually and then it was possible to invoice the SO.

opw:1966170
  • Loading branch information...
simongoffin committed Apr 10, 2019
1 parent e1b1d3c commit 8e272bdf601b609a2cb42fc20037fe0c53067af2
Showing with 14 additions and 0 deletions.
  1. +8 −0 addons/sale_mrp/models/sale_mrp.py
  2. +6 −0 addons/sale_stock/models/sale_order.py
@@ -24,6 +24,14 @@ def _get_delivered_qty(self):
return 0.0
return super(SaleOrderLine, self)._get_delivered_qty()

@api.multi
def _compute_qty_delivered_updateable_for_kit(self):
self.ensure_one()
bom = self.env['mrp.bom']._bom_find(product=self.product_id, company_id=self.company_id.id)
pick_moves = self.move_ids.filtered(lambda m: m.picking_id)
done_pick_moves = pick_moves.filtered(lambda m: m.picking_id.state == 'done')
return bom and bom.type == 'phantom' and len(pick_moves) != len(done_pick_moves)

@api.multi
def _get_bom_component_qty(self, bom):
bom_quantity = self.product_uom._compute_quantity(1, bom.product_uom_id)
@@ -135,12 +135,18 @@ def _compute_product_updatable(self):
else:
line.product_updatable = False

@api.multi
def _compute_qty_delivered_updateable_for_kit(self):
return False

@api.multi
@api.depends('product_id')
def _compute_qty_delivered_updateable(self):
for line in self:
if line.product_id.type not in ('consu', 'product'):
super(SaleOrderLine, line)._compute_qty_delivered_updateable()
elif line._compute_qty_delivered_updateable_for_kit():
super(SaleOrderLine, line)._compute_qty_delivered_updateable()

@api.onchange('product_id')
def _onchange_product_id_set_customer_lead(self):

0 comments on commit 8e272bd

Please sign in to comment.
You can’t perform that action at this time.