From 6f00b0b0f96c28f8352189dc67f0ee2d90192197 Mon Sep 17 00:00:00 2001 From: Thomas HERBIN Date: Wed, 26 Nov 2025 10:35:46 +0100 Subject: [PATCH] [FIX] account_invoice_report_grouped_by_picking: Avoid quantity duplication for kit products --- .../README.rst | 4 ++++ .../__manifest__.py | 2 +- .../models/account_move.py | 15 +++++++++++---- .../readme/CONTRIBUTORS.md | 2 ++ .../static/description/index.html | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/account_invoice_report_grouped_by_picking/README.rst b/account_invoice_report_grouped_by_picking/README.rst index a1b4570fd..5b16154ce 100644 --- a/account_invoice_report_grouped_by_picking/README.rst +++ b/account_invoice_report_grouped_by_picking/README.rst @@ -90,6 +90,10 @@ Contributors - Thao Le +- `Apik `__: + + - Thomas HERBIN + Other credits ------------- diff --git a/account_invoice_report_grouped_by_picking/__manifest__.py b/account_invoice_report_grouped_by_picking/__manifest__.py index db6947d37..5dabd60b0 100644 --- a/account_invoice_report_grouped_by_picking/__manifest__.py +++ b/account_invoice_report_grouped_by_picking/__manifest__.py @@ -12,7 +12,7 @@ "website": "https://github.com/OCA/account-invoice-reporting", "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", - "depends": ["stock_picking_invoice_link"], + "depends": ["stock_picking_invoice_link", "mrp"], "data": ["views/report_invoice.xml"], "installable": True, } 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 9a6b3fc39..61df1185d 100644 --- a/account_invoice_report_grouped_by_picking/models/account_move.py +++ b/account_invoice_report_grouped_by_picking/models/account_move.py @@ -30,14 +30,15 @@ def _sort_grouped_lines(self, lines_dic): ), ) - def _get_signed_quantity_done(self, invoice_line, move, sign): + def _get_signed_quantity_done(self, invoice_line, move, sign, get_line_qty=False): """Hook method. Usage example: account_invoice_report_grouped_by_picking_sale_mrp module """ + qty = invoice_line.quantity if get_line_qty else move.quantity if move.location_id.usage == "customer": - return -move.quantity * sign + return -qty * sign if move.location_dest_id.usage == "customer": - return move.quantity * sign + return qty * sign return 0 def _process_section_note_lines_grouped( @@ -102,16 +103,22 @@ def lines_grouped_by_picking(self): has_returned_qty = False remaining_qty = line.quantity # Process moves related to the line + # If line is a bom, picking will have only components, and we don't want to + # count X times the product. So if it's a bom, we gonna loop one time + # through move lines to get section and note grouped, and picking name + line_is_bom = any([move.bom_line_id for move in line.move_line_ids]) for move in line.move_line_ids: key = (move.picking_id, line) self._process_section_note_lines_grouped( previous_section, previous_note, picking_dict, move.picking_id ) - qty = self._get_signed_quantity_done(line, move, sign) + qty = self._get_signed_quantity_done(line, move, sign, line_is_bom) picking_dict[key] = picking_dict.get(key, 0.0) + qty remaining_qty -= qty if move.location_id.usage == "customer": has_returned_qty = True + if line_is_bom: + break # Process sale order lines without moves if not line.move_line_ids and line.sale_line_ids: for so_line in line.sale_line_ids: diff --git a/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.md b/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.md index 552afbc4a..4a4bfb403 100644 --- a/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.md +++ b/account_invoice_report_grouped_by_picking/readme/CONTRIBUTORS.md @@ -9,3 +9,5 @@ - Ioan Galan \<\> - [Trobz](https://trobz.com): - Thao Le \<\> +- [Apik](https://apik.cloud): + - Thomas HERBIN 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 fe883415d..1c33de83a 100644 --- a/account_invoice_report_grouped_by_picking/static/description/index.html +++ b/account_invoice_report_grouped_by_picking/static/description/index.html @@ -438,6 +438,10 @@

Contributors

  • Thao Le <thaolt@trobz.com>
  • +
  • Apik:
      +
    • Thomas HERBIN
    • +
    +