Skip to content

Commit

Permalink
[REM] hr_expense_invoice: Remove inherit to _compute_state.
Browse files Browse the repository at this point in the history
Function _compute_state from hr_expense_sheet inheritance is removed
because with this inheritance the records are not changing state
appropriately.
  • Loading branch information
ysantiago committed Nov 21, 2024
1 parent 1cfc076 commit c7679ca
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions hr_expense_invoice/models/hr_expense_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,3 @@ def action_view_invoices(self):
action["view_mode"] = "tree,form"
action["domain"] = [("id", "in", invoice_ids)]
return action

@api.depends()
def _compute_state(self):
"""Set proper state according to linked invoices."""
sheets_with_invoices = self.filtered(
lambda sheet: all(
expense.invoice_id and expense.invoice_id.state == "posted"
for expense in sheet.expense_line_ids
)
and sheet.state == sheet.approval_state
)

company_account_sheets = sheets_with_invoices.filtered(
lambda sheet: sheet.payment_mode == "company_account"
)
company_account_sheets.state = "done"

sheets_with_paid_invoices = (
sheets_with_invoices - company_account_sheets
).filtered(
lambda sheet: all(
expense.invoice_id.payment_state != "not_paid"
for expense in sheet.expense_line_ids
)
)
sheets_with_paid_invoices.state = "post"

return super(HrExpenseSheet, self - sheets_with_invoices)._compute_state()

0 comments on commit c7679ca

Please sign in to comment.