From 6003efc8209ac42b547303e5681d4bf8a8354ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 Apr 2022 23:24:20 +0200 Subject: [PATCH] Add validate_fields to ModelStorage issue11303 review386191002 --- account.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/account.py b/account.py index 0570dd5f4e..d889d0732b 100644 --- a/account.py +++ b/account.py @@ -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,