Skip to content

Commit

Permalink
[13.0][IMP] account_invoicing_mode_at_shipping
Browse files Browse the repository at this point in the history
With a picking related to multiple sales order and those sales order
with different invoicing mode, the invoicing could happen at the wrong
moment or not at all.

This change unifies the way the module checks for sales order needed to
be invoiced at shipping.
  • Loading branch information
TDu committed Jul 15, 2021
1 parent 8b14b7a commit 29d10d4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions account_invoice_mode_at_shipping/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ def action_done(self):
picking.with_delay()._invoicing_at_shipping()
return res

def _get_sales_order_to_invoice_at_shipping(self):
"""Returns sales order to invoice at shipping related to the picking."""
return self.mapped("move_lines.sale_line_id.order_id").filtered(
lambda r: r.partner_invoice_id.invoicing_mode == "at_shipping"
)

def _invoice_at_shipping(self):
"""Check if picking must be invoiced at shipping."""
self.ensure_one()
return (
self.picking_type_code == "outgoing"
and self.sale_id.partner_invoice_id.invoicing_mode == "at_shipping"
and self._get_sales_order_to_invoice_at_shipping()
)

@job(default_channel="root.invoice_at_shipping")
Expand All @@ -44,6 +50,5 @@ def _invoicing_at_shipping(self):
return invoices or _("Nothing to invoice.")

def _get_sales_order_to_invoice(self):
return self.mapped("move_lines.sale_line_id.order_id").filtered(
lambda r: r._get_invoiceable_lines()
)
sales = self._get_sales_order_to_invoice_at_shipping()
return sales.filtered(lambda r: r._get_invoiceable_lines())

0 comments on commit 29d10d4

Please sign in to comment.