-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_br_fiscal: estimate tax without company
- Loading branch information
Showing
6 changed files
with
50 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Copyright (C) 2012 Renato Lima - Akretion <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import fields, models | ||
from odoo import api, fields, models | ||
|
||
|
||
class TaxEstimate(models.Model): | ||
|
@@ -43,8 +43,22 @@ class TaxEstimate(models.Model): | |
|
||
origin = fields.Char(string="Source", size=32) | ||
|
||
company_id = fields.Many2one( | ||
comodel_name="res.company", | ||
string="Company", | ||
default=lambda self: self.env.company, | ||
) | ||
active = fields.Boolean(string="Ativo", default=True) | ||
|
||
def _deactivate_old_estimates(self): | ||
for estimate in self: | ||
domain = [ | ||
("id", "!=", estimate.id), | ||
("state_id", "=", estimate.state_id.id), | ||
"|", | ||
("ncm_id", "=", estimate.ncm_id.id), | ||
("nbs_id", "=", estimate.nbs_id.id), | ||
] | ||
old_estimates = self.search(domain) | ||
old_estimates.write({"active": False}) | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
estimates = super().create(vals_list) | ||
estimates._deactivate_old_estimates() | ||
return estimates |
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