From d542a3562aa1d1dbfc8529705c8c2804fb9eec5a Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Sat, 22 Jun 2013 13:03:23 +0200 Subject: [PATCH] Add on_change functions for functional fields that depend on work issue3267 review936002 --- work.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/work.py b/work.py index aa960b9260..e44a48c46a 100644 --- a/work.py +++ b/work.py @@ -22,8 +22,9 @@ class Work(ModelSQL, ModelView): ('task', 'Task') ], 'Type', required=True, select=True) - company = fields.Function(fields.Many2One('company.company', 'Company'), - 'get_company', searcher='search_comany') + company = fields.Function(fields.Many2One('company.company', 'Company', + on_change_with=['work']), + 'on_change_with_company', searcher='search_comany') party = fields.Many2One('party.party', 'Party', states={ 'invisible': Eval('type') != 'project', @@ -34,13 +35,14 @@ class Work(ModelSQL, ModelView): 'invisible': Eval('type') != 'project', }, depends=['party', 'type']) timesheet_available = fields.Function( - fields.Boolean('Available on timesheets'), 'get_timesheet_available') + fields.Boolean('Available on timesheets', on_change_with=['work']), + 'on_change_with_timesheet_available') hours = fields.Function(fields.Float('Timesheet Hours', digits=(16, 2), states={ 'invisible': ~Eval('timesheet_available'), }, - depends=['timesheet_available'], - help="Total time spent on this work"), 'get_hours') + depends=['timesheet_available'], on_change_with=['work'], + help="Total time spent on this work"), 'on_change_with_hours') effort = fields.Float("Effort", states={ 'invisible': Eval('type') != 'task', @@ -159,17 +161,17 @@ class Work(ModelSQL, ModelView): def search_active(cls, name, clause): return [('work.active',) + tuple(clause[1:])] - def get_company(self, name): + def on_change_with_company(self, name=None): return self.work.company.id @classmethod def search_comany(cls, name, clause): return [('work.company',) + tuple(clause[1:])] - def get_timesheet_available(self, name): + def on_change_with_timesheet_available(self, name=None): return self.work.timesheet_available - def get_hours(self, name): + def on_change_with_hours(self, name=None): return self.work.hours @classmethod