Skip to content

Commit

Permalink
[FIX] sale_order_line_planned_quantity: Calcular diferencia solo a mv…
Browse files Browse the repository at this point in the history
…tos con tipo operación marcada.
  • Loading branch information
alfredoavanzosc authored and oihane committed Aug 29, 2024
1 parent 1c22df0 commit ca269fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions sale_order_line_planned_quantity/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ class SaleOrderLine(models.Model):
def _compute_planned_quantity(self):
for line in self:
planned_quantity = 0
moves_planned_quantities = False
if line.move_ids:
moves = line.move_ids.filtered(
lambda x: x.state != "cancel"
and x.picking_type_id
and x.picking_type_id.use_to_calculate_planned_quantities
moves_planned_quantities = line.move_ids.filtered(
lambda x: x.picking_type_id.use_to_calculate_planned_quantities
)
if moves:
planned_quantity = sum(moves.mapped("product_uom_qty"))
line.planned_quantity = planned_quantity
if moves_planned_quantities:
moves = moves_planned_quantities.filtered(
lambda x: x.state != "cancel"
)
if moves:
planned_quantity = sum(moves.mapped("product_uom_qty"))
line.planned_quantity = planned_quantity if moves_planned_quantities else 0

@api.depends(
"planned_quantity",
Expand All @@ -49,6 +52,15 @@ def _compute_planned_quantity(self):
)
def _compute_difference_between_ordered_planned(self):
for line in self:
line.difference_between_ordered_planned = bool(
line.product_uom_qty != line.planned_quantity and line.state != "draft"
)
moves_planned_quantities = False
if line.move_ids:
moves_planned_quantities = line.move_ids.filtered(
lambda x: x.picking_type_id.use_to_calculate_planned_quantities
)
if moves_planned_quantities:
line.difference_between_ordered_planned = bool(
line.product_uom_qty != line.planned_quantity
and line.state != "draft"
)
else:
line.difference_between_ordered_planned = False
2 changes: 1 addition & 1 deletion sale_order_line_planned_quantity/views/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='order_line']/tree/field[@name='product_uom_qty']"
expr="//page/field[@name='order_line']/tree/field[@name='product_uom_qty']"
position="after"
>
<field name="planned_quantity" optional="show" />
Expand Down

0 comments on commit ca269fc

Please sign in to comment.