-
Notifications
You must be signed in to change notification settings - Fork 51
Update event_compassion.py #2071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 14.0
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -163,9 +163,11 @@ def _compute_expense_lines(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| def _compute_income_lines(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for event in self: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.income_line_ids = event.invoice_line_ids.filtered( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda line: line.payment_state == "paid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| and not line.contract_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| and line.move_id.move_type == "out_invoice" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda line: not line.contract_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| and line.account_id.user_type_id.name == "Income" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| and ((line.payment_state == "paid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| and line.move_id.move_type == "out_invoice") or | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| (line.move_id.move_type == "entry")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
163
to
171
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a hardcoded string
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @api.depends("analytic_id.line_ids") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -178,7 +180,8 @@ def _compute_expense(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| def _compute_income(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for event in self: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| incomes = event.income_line_ids | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.total_income = sum(incomes.mapped("price_subtotal") or [0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.total_income = (sum(incomes.mapped("credit") or [0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| -sum(incomes.mapped("debit") or [0])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @api.depends("total_income", "total_expense") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _compute_balance(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic inside this
filteredcall introduces new dependencies onaccount.move.linefields (account_id,move_id.move_type). Sincetotal_incomeis a stored computed field that depends on this, its@api.dependsdecorator needs to be updated to reflect these new dependencies. Otherwise,total_incomewill not be recomputed when these fields change, leading to incorrect data.The decorator for
_compute_incomeshould be updated. A better long-term solution would be to add a proper@api.dependsto_compute_income_linesitself, and then make_compute_incomedepend onincome_line_ids.