Skip to content

Commit

Permalink
TA#62285 [IMP] Module sale_delivery_completion (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda authored Mar 12, 2024
1 parent cf3dd1e commit b14fac6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions gitoo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
- url: https://github.com/OCA/stock-logistics-workflow
branch: "14.0"
includes:
- sale_line_returned_qty
- sale_order_global_stock_route

- url: https://github.com/OCA/stock-logistics-warehouse
Expand Down
10 changes: 10 additions & 0 deletions sale_delivery_completion/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ order is displayed.

.. image:: static/description/stock_picking_list.png


Since Version 1.1.0 the module maintains the completion rate even if there are delivery returns.

We use the community module `sale_line_returned_qty <https://github.com/OCA/stock-logistics-workflow/tree/14.0/sale_line_returned_qty>`_, to get
the returned quantity in the sale order line.

The returned quantity is added to the rate of completion calculation.

.. image:: static/description/rate_completion_with_returned_qty.png

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
Expand Down
4 changes: 2 additions & 2 deletions sale_delivery_completion/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

{
"name": "Sale Delivery Completion",
"version": "14.0.1.0.0",
"version": "14.0.1.1.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "LGPL-3",
"category": "Sales",
"summary": "Show the completion rate on sale orders",
"depends": ["sale_stock"],
"depends": ["sale_stock", "sale_line_returned_qty"],
"data": ["views/sale_order.xml"],
"installable": True,
}
9 changes: 5 additions & 4 deletions sale_delivery_completion/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def _compute_completion_rate(self):

def _get_completion_rate(self):
lines_without_services = self.order_line.filtered(
lambda l: l.product_id.type in ("product", "consu")
lambda line: line.product_id.type in ("product", "consu")
)
delivered = sum(lines_without_services.mapped(lambda l: l.qty_delivered))
total_qty = sum(lines_without_services.mapped(lambda l: l.product_uom_qty))
completion = (delivered / total_qty) if total_qty else 1
delivered = sum(lines_without_services.mapped(lambda line: line.qty_delivered))
returned = sum(lines_without_services.mapped(lambda line: line.qty_returned))
total_qty = sum(lines_without_services.mapped(lambda line: line.product_uom_qty))
completion = ((delivered + returned) / total_qty) if total_qty else 1
return "{}%".format(int(completion * 100))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions sale_delivery_completion/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ def test_if_no_stockable_product__then_fully_delivered(self):
self.product_1.type = "service"
self.product_2.type = "service"
assert self.sale_order.completion_rate == "100%"

def test_product_returned(self):
self.line_1.qty_delivered = 10
self.line_2.qty_delivered = 8
self.line_2.qty_returned = 2
assert self.sale_order.completion_rate == "100%"

0 comments on commit b14fac6

Please sign in to comment.