Skip to content

Commit

Permalink
[IMP] recurring_contract : refresh UI
Browse files Browse the repository at this point in the history
- Refresh UI after generating invoices
  • Loading branch information
ecino committed Sep 17, 2024
1 parent ea16c1b commit b5bc0fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
27 changes: 16 additions & 11 deletions recurring_contract/models/contract_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def button_generate_invoices(self, contract_id=None):
"title": ("Generation of Invoices"),
"message": msg,
"type": f"{notification_type}",
"next": {"type": "ir.actions.client", "tag": "soft_reload"},
},
}
return notification
Expand Down Expand Up @@ -347,7 +348,9 @@ def _should_skip_invoice_generation(self, invoicing_date, contract=None):
),
]

has_all_invoices = bool(self.env["account.move"].search_count(search_filter))
has_all_invoices = bool(
self.env["account.move"].search_count(search_filter)
)
else:
search_filter = [
("invoice_date_due", "=", invoicing_date),
Expand All @@ -359,13 +362,18 @@ def _should_skip_invoice_generation(self, invoicing_date, contract=None):
"in",
self.active_contract_ids.mapped("product_ids").ids,
),
('state', '!=', 'cancel')
("state", "!=", "cancel"),
]

open_invoices = self.env["account.move"].search(search_filter)

has_all_invoices = len(self.active_contract_ids -
open_invoices.mapped("line_ids.contract_id")) == 0
has_all_invoices = (
len(
self.active_contract_ids
- open_invoices.mapped("line_ids.contract_id")
)
== 0
)

is_suspended = (
self.invoice_suspended_until
Expand Down Expand Up @@ -560,9 +568,7 @@ def build_inv_line_data(
if contract_line:
qty = contract_line.quantity
contract = contract_line.contract_id
product = contract_line.product_id.with_company(
contract.company_id.id
)
product = contract_line.product_id.with_company(contract.company_id.id)
line_name = product.name
if contract_line.pricelist_item_count:
price = contract.pricelist_id._get_product_price(
Expand All @@ -573,9 +579,7 @@ def build_inv_line_data(
elif gift_wizard:
qty = gift_wizard.quantity
contract = gift_wizard.contract_id
product = gift_wizard.product_id.with_company(
contract.company_id.id
)
product = gift_wizard.product_id.with_company(contract.company_id.id)
price = gift_wizard.amount
line_name = gift_wizard.description or product.name
else:
Expand All @@ -591,7 +595,8 @@ def build_inv_line_data(
"contract_id": contract.id,
"account_id": (
product.property_account_income_id
or product.categ_id.property_account_income_categ_id).id,
or product.categ_id.property_account_income_categ_id
).id,
}

def _updt_invoices_cg(self, vals):
Expand Down
7 changes: 5 additions & 2 deletions recurring_contract/models/recurring_contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def _compute_display_name(self):
"Product",
required=True,
readonly=False,
domain=["|", ("property_account_income_id", "!=", False),
("categ_id.property_account_income_categ_id", "!=", False)],
domain=[
"|",
("property_account_income_id", "!=", False),
("categ_id.property_account_income_categ_id", "!=", False),
],
)
amount = fields.Float("Price", required=True)
quantity = fields.Integer(default=1, required=True)
Expand Down

0 comments on commit b5bc0fa

Please sign in to comment.