Skip to content

Commit

Permalink
Some code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kittiu committed Mar 3, 2024
1 parent 5562efd commit 8804c82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
15 changes: 7 additions & 8 deletions sale_invoice_plan/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ def _compute_invoice_plan_process(self):
for rec in self:
has_invoice_plan = rec.use_invoice_plan and rec.invoice_plan_ids
to_invoice = rec.invoice_plan_ids.filtered(lambda l: not l.invoiced)
if rec.state == "sale" and has_invoice_plan and to_invoice:
if rec.invoice_status == "to invoice" or (
rec.invoice_status == "no"
and "advance" in to_invoice.mapped("invoice_type")
):
rec.invoice_plan_process = True
continue
rec.invoice_plan_process = False
inv_or_adv = rec.invoice_status == "to invoice" or (
rec.invoice_status == "no"
and "advance" in to_invoice.mapped("invoice_type")
)
rec.invoice_plan_process = (
rec.state == "sale" and has_invoice_plan and to_invoice and inv_or_adv
)

@api.constrains("invoice_plan_ids")
def _check_invoice_plan_total_percent(self):
Expand Down
14 changes: 7 additions & 7 deletions sale_invoice_plan/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,31 @@
<group expand="0" string="Group By">
<filter
string="Customer"
name="customer"
name="groupby_customer"
domain="[]"
context="{'group_by':'partner_id'}"
/>
<filter
string="Sales Order"
name="sale"
name="groupby_sale"
domain="[]"
context="{'group_by':'sale_id'}"
/>
<filter
string="Analytic Account"
name="analytic_account_id"
name="groupby_analytic_account_id"
domain="[]"
context="{'group_by':'analytic_account_id'}"
/>
<filter
string="Installment"
name="install"
name="groupby_install"
domain="[]"
context="{'group_by':'installment'}"
/>
<filter
string="Status"
name="state"
name="groupby_state"
domain="[]"
context="{'group_by':'state'}"
/>
Expand Down Expand Up @@ -222,7 +222,7 @@
<field name="search_view_id" ref="view_sale_invoice_plan_filter" />
<field
name="context"
>{'search_default_draft': 1, 'search_default_sale': 1}</field>
>{'search_default_sales': 1, 'search_default_groupby_sale': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
View sales invoice plan lines
Expand All @@ -237,6 +237,6 @@
id="menu_sale_invoice_plan"
parent="sale.sale_order_menu"
groups="sales_team.group_sale_salesman"
sequence="22"
sequence="25"
/>
</odoo>

0 comments on commit 8804c82

Please sign in to comment.