Skip to content

Commit

Permalink
[IMP]: account_invoice_section_sale_order add option to always create…
Browse files Browse the repository at this point in the history
… sections
  • Loading branch information
victorvermot committed Jan 28, 2025
1 parent 798c23d commit 494b1bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions account_invoice_section_sale_order/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ class ResCompany(models.Model):
default="sale_order",
required=True,
)

always_create_invoice_section = fields.Boolean(
help="Defines when to create sections",
default=False,
required=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ class ResConfigSettings(models.TransientModel):
readonly=False,
required=True,
)

always_create_invoice_section = fields.Boolean(
related="company_id.always_create_invoice_section",
readonly=False,
required=True,
)
3 changes: 2 additions & 1 deletion account_invoice_section_sale_order/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def _create_invoices(self, grouped=False, final=False, date=None):
invoice_ids = super()._create_invoices(grouped=grouped, final=final, date=date)
for invoice in invoice_ids:
if (
len(invoice.line_ids.mapped(invoice.line_ids._get_section_grouping()))
not invoice.company_id.always_create_invoice_section
and len(invoice.line_ids.mapped(invoice.line_ids._get_section_grouping()))
== 1
):
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
/>
<field name="invoice_section_name_scheme" />
</div>
<div class="row">
<label
for="always_create_invoice_section"
class="col-lg-4 o_light_label"
string="When to create sections"
/>
<field name="always_create_invoice_section" />
</div>
</setting>
</xpath>
</field>
Expand Down

0 comments on commit 494b1bd

Please sign in to comment.