Skip to content

Commit da2b00c

Browse files
[FIX] l10n_es_account_asset: replace sql constraints
1 parent 8f20755 commit da2b00c

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

l10n_es_account_asset/models/account_asset.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ class AccountAssetAsset(models.Model):
2828
store=True,
2929
)
3030

31-
_sql_constraints = [
32-
(
33-
"annual_percentage",
34-
"CHECK (annual_percentage > 0 and annual_percentage <= 100)",
35-
"Wrong percentage!",
36-
),
37-
]
31+
_annual_percentage_check = models.Constraint(
32+
"CHECK (annual_percentage > 0 and annual_percentage <= 100)",
33+
"Wrong percentage!",
34+
)
3835

3936
@api.depends("profile_id")
4037
def _compute_annual_percentage(self):

l10n_es_account_asset/models/account_asset_profile.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ def _inverse_method_percentage(self):
5757
if float_compare(new_percentage, profile.annual_percentage, 2) != 0:
5858
profile.annual_percentage = new_percentage
5959

60-
_sql_constraints = [
61-
(
62-
"annual_percentage",
63-
"CHECK (annual_percentage > 0 and annual_percentage <= 100)",
64-
"Wrong percentage!",
65-
),
66-
]
60+
_annual_percentage_check = models.Constraint(
61+
"CHECK (annual_percentage > 0 and annual_percentage <= 100)",
62+
"Wrong percentage!",
63+
)

0 commit comments

Comments
 (0)