Skip to content

Commit

Permalink
l10n_fr_das2: partner_declare_threshold is now a computed field
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Jun 15, 2024
1 parent 2f2f931 commit 6f734b3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions l10n_fr_das2/models/l10n_fr_das2.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ class L10nFrDas2(models.Model):
string="Lines",
)
partner_declare_threshold = fields.Integer(
string="Partner Declaration Threshold", readonly=True
compute="_compute_partner_declare_threshold",
store=True,
precompute=True,
string="Partner Declaration Threshold",
)
dads_type = fields.Selection(
[
Expand Down Expand Up @@ -140,6 +143,14 @@ class L10nFrDas2(models.Model):
)
]

@api.depends("year")
def _compute_partner_declare_threshold(self):
for rec in self:
if rec.year:
rec.partner_declare_threshold = get_partner_declaration_threshold(
rec.year
)

@api.model
def _default_dads_type(self):
previous_decl = self.search(
Expand Down Expand Up @@ -244,9 +255,6 @@ def generate_lines(self):
currency=company.currency_id.name,
)
)
self.write(
{"partner_declare_threshold": get_partner_declaration_threshold(self.year)}
)
das2_partners = self.env["res.partner"].search(
[("parent_id", "=", False), ("fr_das2_type", "!=", False)]
)
Expand Down

0 comments on commit 6f734b3

Please sign in to comment.