diff --git a/account_invoice_report_grouped_by_picking/README.rst b/account_invoice_report_grouped_by_picking/README.rst index f3052d028..7a0356cf9 100644 --- a/account_invoice_report_grouped_by_picking/README.rst +++ b/account_invoice_report_grouped_by_picking/README.rst @@ -7,7 +7,7 @@ Account Invoice Grouped by Picking !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:de4c4463a2aa0e1670dca3c708e6ca71ab665dded60239f6e7a61b20792fc61a + !! source digest: sha256:fa621af850264f0ff2d2219fca81d3676f300dde7b1bc668e0d215a217d86107 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -86,6 +86,10 @@ Contributors * Ioan Galan +* `Sygel `__: + + * Manuel Regidor + Maintainers ~~~~~~~~~~~ diff --git a/account_invoice_report_grouped_by_picking/models/account_move.py b/account_invoice_report_grouped_by_picking/models/account_move.py index 8ed5eec20..fc4d14c4b 100644 --- a/account_invoice_report_grouped_by_picking/models/account_move.py +++ b/account_invoice_report_grouped_by_picking/models/account_move.py @@ -107,7 +107,7 @@ def lines_grouped_by_picking(self): so_dict[so_line.order_id], ) picking_dict.setdefault(key, 0) - qty = so_line.product_uom_qty + qty = min(so_line.product_uom_qty, remaining_qty) picking_dict[key] += qty remaining_qty -= qty elif not line.move_line_ids and not line.sale_line_ids: diff --git a/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.rst b/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.rst index 0831340f5..b02ad6f7f 100644 --- a/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.rst +++ b/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.rst @@ -10,3 +10,7 @@ * `Studio73 `__: * Ioan Galan + +* `Sygel `__: + + * Manuel Regidor diff --git a/account_invoice_report_grouped_by_picking/static/description/index.html b/account_invoice_report_grouped_by_picking/static/description/index.html index 5b7ee9a4a..c69696b04 100644 --- a/account_invoice_report_grouped_by_picking/static/description/index.html +++ b/account_invoice_report_grouped_by_picking/static/description/index.html @@ -367,7 +367,7 @@

Account Invoice Grouped by Picking

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:de4c4463a2aa0e1670dca3c708e6ca71ab665dded60239f6e7a61b20792fc61a +!! source digest: sha256:fa621af850264f0ff2d2219fca81d3676f300dde7b1bc668e0d215a217d86107 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/account-invoice-reporting Translate me on Weblate Try me on Runboat

This module allows print invoices with picking info. This module groups @@ -433,6 +433,10 @@

Contributors

  • Ioan Galan <ioan@studio73.es>
  • +
  • Sygel: +
  • diff --git a/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py b/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py index 487918764..9bc9a8c19 100644 --- a/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py +++ b/account_invoice_report_grouped_by_picking/tests/test_account_invoice_group_picking.py @@ -1,6 +1,7 @@ # Copyright 2017 Carlos Dauden # Copyright 2018 David Vidal # Copyright 2019 Tecnativa - Pedro M. Baeza +# Copyright 2024 Manuel Regidor # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from lxml import html @@ -313,3 +314,51 @@ def test_account_invoice_group_picking_refund_without_return(self): self.assertEqual(tbody.count(self.sale.name), 1) # information about pickings is printed self.assertTrue(picking.name in tbody) + + def test_service_less_than_ordered(self): + self.sale.action_confirm() + picking = self.sale.picking_ids[:1] + picking.action_confirm() + picking.move_line_ids.write({"qty_done": 2}) + picking._action_done() + invoice = self.sale._create_invoices() + invoice_service_line = invoice.invoice_line_ids.filtered( + lambda a: a.product_id.type == "service" + ) + invoice_service_line.write({"quantity": 1}) + grouped_lines = invoice.lines_grouped_by_picking() + service_dict = list( + filter(lambda e: e.get("line") == invoice_service_line, grouped_lines) + ) + self.assertEqual(len(service_dict), 1) + self.assertEqual(service_dict[0].get("quantity"), 1) + + def test_service_greater_than_ordered(self): + self.sale.action_confirm() + picking = self.sale.picking_ids[:1] + picking.action_confirm() + picking.move_line_ids.write({"qty_done": 2}) + picking._action_done() + invoice = self.sale._create_invoices() + invoice_service_line = invoice.invoice_line_ids.filtered( + lambda a: a.product_id.type == "service" + ) + invoice_service_line.write({"quantity": 5}) + grouped_lines = invoice.lines_grouped_by_picking() + service_with_picking_dict = list( + filter( + lambda e: e.get("line") == invoice_service_line and e.get("picking"), + grouped_lines, + ) + ) + service_without_picking_dict = list( + filter( + lambda e: e.get("line") == invoice_service_line + and not e.get("picking"), + grouped_lines, + ) + ) + self.assertEqual(len(service_with_picking_dict), 1) + self.assertEqual(service_with_picking_dict[0].get("quantity"), 3) + self.assertEqual(len(service_without_picking_dict), 1) + self.assertEqual(service_without_picking_dict[0].get("quantity"), 2)