Add validate_fields to ModelStorage
issue11303 review386191002
This commit is contained in:
1 parent
00e8dbfebc
commit
6003efc820
1 file changed
+8
-2
+8
-2
@@ -698,13 +698,19 @@ class BudgetLinePeriod(AmountMixin, ModelSQL, ModelView):
|
||||
group_by=table.id))
|
||||
|
||||
@classmethod
|
||||
def validate(cls, periods):
|
||||
def validate_fields(cls, periods, field_names):
|
||||
super().validate_fields(periods, field_names)
|
||||
cls.check_ratio(periods, field_names)
|
||||
|
||||
@classmethod
|
||||
def check_ratio(cls, periods, field_names=None):
|
||||
pool = Pool()
|
||||
Line = pool.get('account.budget.line')
|
||||
if field_names and not (field_names & {'ratio', 'budget_line'}):
|
||||
return
|
||||
transaction = Transaction()
|
||||
cursor = transaction.connection.cursor()
|
||||
table = cls.__table__()
|
||||
super().validate(periods)
|
||||
for sub_ids in grouped_slice({p.budget_line.id for p in periods}):
|
||||
cursor.execute(*table.select(
|
||||
table.budget_line,
|
||||
|
||||
Reference in new issue
Block a user