changeset 6b65c01a4e6e in modules/account_budget:default
details: 
https://hg.tryton.org/modules/account_budget?cmd=changeset&node=6b65c01a4e6e
description:
        Add validate_fields to ModelStorage

        issue11303
        review386191002
diffstat:

 account.py |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (25 lines):

diff -r 8636663c6c40 -r 6b65c01a4e6e account.py
--- a/account.py        Sun Apr 10 19:11:37 2022 +0200
+++ b/account.py        Mon Apr 11 23:24:20 2022 +0200
@@ -698,13 +698,19 @@
                 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,

Reply via email to