Skip to content

Commit

Permalink
[13.0][FIX] acconut_invoicing_mode_at_shipping
Browse files Browse the repository at this point in the history
Split invoice creation on invoice partner settings that decides if sales order
atre being grouped in invoice or not.
The previous implementation would crash.
  • Loading branch information
TDu committed Apr 27, 2021
1 parent 2433312 commit f0b8724
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
1 change: 0 additions & 1 deletion account_invoice_base_invoicing_mode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import models
from . import tests
1 change: 0 additions & 1 deletion account_invoice_base_invoicing_mode/tests/__init__.py

This file was deleted.

This file was deleted.

14 changes: 11 additions & 3 deletions account_invoice_mode_at_shipping/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ def _invoice_at_shipping(self):
@job(default_channel="root.invoice_at_shipping")
def _invoicing_at_shipping(self):
self.ensure_one()
sales_order = self._get_sales_order_to_invoice()
partner = sales_order.partner_invoice_id
invoices = sales_order._create_invoices(grouped=partner.one_invoice_per_order)
sales = self._get_sales_order_to_invoice()
# Split invoice creation on partner sales grouping on invoice settings
sales_one_invoice_per_order = sales.filtered(
"partner_invoice_id.one_invoice_per_order"
)
invoices = self.env["account.move"].browse()
if sales_one_invoice_per_order:
invoices |= sales_one_invoice_per_order._create_invoices(grouped=True)
sales_many_invoice_per_order = sales - sales_one_invoice_per_order
if sales_many_invoice_per_order:
invoices |= sales_many_invoice_per_order._create_invoices(grouped=False)
for invoice in invoices:
invoice.with_delay()._validate_invoice()
return invoices
Expand Down

0 comments on commit f0b8724

Please sign in to comment.