Skip to content

Commit 5cab30d

Browse files
committed
[IMP] sale_order_type_ux: Improve when consolidation billing is set and having multiple sale types
closes #1462 Signed-off-by: Franco Leyes <lef@adhoc.com.ar>
1 parent ff2dcb5 commit 5cab30d

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

sale_order_type_ux/models/sale_order.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,22 @@ def _create_invoices(self, grouped=False, final=False, date=None):
6060
Overrides the `_create_invoices` method to ensure that taxes are correctly computed
6161
for the company of the invoice. In cases where the company has a localization
6262
(e.g., l10n_ar), this ensures that the taxes from `l10n_ar_tax_ids` are applied.
63+
64+
Also creates separate invoices for each sale order type when multiple types are present.
6365
"""
64-
invoices = super()._create_invoices(grouped=grouped, final=final, date=date)
66+
# If we have multiple order types and not explicitly grouped, create separate invoices per type
67+
if len(self.mapped("type_id")) > 1 and not grouped:
68+
all_invoices = self.env["account.move"]
69+
for order_type in self.mapped("type_id"):
70+
orders_with_type = self.filtered(lambda x: x.type_id.id == order_type.id)
71+
type_invoices = super(SaleOrder, orders_with_type)._create_invoices(
72+
grouped=grouped, final=final, date=date
73+
)
74+
all_invoices |= type_invoices
75+
invoices = all_invoices
76+
else:
77+
invoices = super()._create_invoices(grouped=grouped, final=final, date=date)
78+
6579
for invoice in invoices.filtered("sale_type_id.journal_id"):
6680
company = invoice.sale_type_id.journal_id.company_id
6781
if invoice.company_id != company:

0 commit comments

Comments
 (0)