Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions account_invoice_report_grouped_by_picking/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ Contributors

- Thao Le <thaolt@trobz.com>

- `Apik <https://apik.cloud>`__:

- Thomas HERBIN

Other credits
-------------

Expand Down
2 changes: 1 addition & 1 deletion account_invoice_report_grouped_by_picking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
15 changes: 11 additions & 4 deletions account_invoice_report_grouped_by_picking/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
- Ioan Galan \<<ioan@studio73.es>\>
- [Trobz](https://trobz.com):
- Thao Le \<<thaolt@trobz.com>\>
- [Apik](https://apik.cloud):
- Thomas HERBIN
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Thao Le &lt;<a class="reference external" href="mailto:thaolt&#64;trobz.com">thaolt&#64;trobz.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://apik.cloud">Apik</a>:<ul>
<li>Thomas HERBIN</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down