Merge lp:~openerp-commiter/openobject-client/6.0-opw-381574-nch into lp:openobject-client/6.0

Proposed by Naresh(OpenERP)
Status: Merged
Merged at revision: 1943
Proposed branch: lp:~openerp-commiter/openobject-client/6.0-opw-381574-nch
Merge into: lp:openobject-client/6.0
Diff against target: 58 lines (+9/-4)
3 files modified
bin/widget/model/field.py (+2/-2)
bin/widget/model/record.py (+6/-1)
bin/widget/view/form_gtk/interface.py (+1/-1)
To merge this branch: bzr merge lp:~openerp-commiter/openobject-client/6.0-opw-381574-nch
Reviewer Review Type Date Requested Status
Xavier ALT Pending
Review via email: mp+94925@code.launchpad.net

Description of the change

[FIX/IMP][381574]:on_change call to pass context defined on the field"

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/widget/model/field.py'
2--- bin/widget/model/field.py 2011-11-04 10:09:40 +0000
3+++ bin/widget/model/field.py 2012-02-28 09:20:14 +0000
4@@ -61,7 +61,7 @@
5 if self.get_state_attrs(model).get('readonly', False):
6 return
7 if self.attrs.get('on_change',False):
8- model.on_change(self.attrs['on_change'])
9+ model.on_change(self.attrs['on_change'], field = self)
10 if self.attrs.get('change_default', False):
11 model.cond_default(self.attrs['name'], self.get(model))
12
13@@ -119,7 +119,7 @@
14 res = self.set(model, value)
15 model.cond_default(self.attrs['name'], self.get(model))
16 if self.attrs.get('on_change',False):
17- model.on_change(self.attrs['on_change'])
18+ model.on_change(self.attrs['on_change'], field=self)
19 return res
20
21 def get_default(self, model):
22
23=== modified file 'bin/widget/model/record.py'
24--- bin/widget/model/record.py 2011-06-10 15:07:06 +0000
25+++ bin/widget/model/record.py 2012-02-28 09:20:14 +0000
26@@ -297,13 +297,18 @@
27 return val
28
29 #XXX Shoud use changes of attributes (ro, ...)
30- def on_change(self, callback):
31+ def on_change(self, callback, field=False):
32 match = re.match('^(.*?)\((.*)\)$', callback)
33 if not match:
34 raise Exception, 'ERROR: Wrong on_change trigger: %s' % callback
35 func_name = match.group(1)
36 arg_names = [n.strip() for n in match.group(2).split(',') if n.strip()]
37+ idx = False
38+ if 'context' in arg_names:
39+ idx = arg_names.index('context')
40 args = [self.expr_eval(arg) for arg in arg_names]
41+ if idx and field:
42+ args[idx].update(field.context_get(self))
43 ids = self.id and [self.id] or []
44 response = getattr(self.rpc, func_name)(ids, *args)
45 if response:
46
47=== modified file 'bin/widget/view/form_gtk/interface.py'
48--- bin/widget/view/form_gtk/interface.py 2010-12-13 15:45:20 +0000
49+++ bin/widget/view/form_gtk/interface.py 2012-02-28 09:20:14 +0000
50@@ -144,7 +144,7 @@
51
52 def sig_changed(self):
53 if self.attrs.get('on_change',False):
54- self._view.view_form.screen.on_change(self.attrs['on_change'])
55+ self._view.view_form.screen.on_change(self.attrs['on_change'], field=self._view.modelfield)
56
57 def grab_focus(self):
58 return self.widget.grab_focus()