-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] account: Logging and tracking of some fields.
Problem --------- All fields in the tax definition are currently modifiable even after the tax has been used. This raises some issues in tax reports and make investigations difficult when things go wrong in tax report. Objective --------- Once an account tax has been used: - Some fields in the account tax should not be modifiable anymore to avoid tax report issues; - Other fields should be logged when modified to ease debugging and investigations. Solution --------- 1. Add a logger to the tax form to track the modification of some fields 2. Track whether the task is being used in transactions or not. This is done thanks to a compute field. In order to be flexible, the compute function uses a hook function that other modules can override to easily add transactions to computation of the field. 3. Make the fields that should not be modified anymore readonly when the tax is being used. 4. In order to track the repartition line values, a tracked computed field that stores the relevant value in a string is used. Task-3450002 Part-of: odoo#130403
- Loading branch information
Showing
12 changed files
with
343 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from collections import Counter | ||
from odoo import models | ||
|
||
|
||
class AccountTax(models.Model): | ||
_inherit = "account.tax" | ||
|
||
def _hook_compute_is_used(self): | ||
# OVERRIDE in order to count the usage of taxes in expenses | ||
|
||
taxes_in_transactions_ctr = Counter(dict(self.env['hr.expense']._read_group([], groupby=['tax_ids'], aggregates=['__count']))) | ||
|
||
return super()._hook_compute_is_used() + taxes_in_transactions_ctr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.