Please review this at http://codereview.appspot.com/612041/show
Affected files:
M trytond/model/model.py
Index: trytond/model/model.py
===================================================================
--- a/trytond/model/model.py
+++ b/trytond/model/model.py
@@ -113,6 +113,24 @@
if on_change_with not in self._rpc:
self._rpc[on_change_with] = False
+ def __getattr__(self, name):
+ try:
+ super(Model, self).__getattr__(name)
+ except AttributeError:
+ # Search if a function exists in inherits parents
+ for model_name, field_name in self._inherits.iteritems():
+ model_obj = self.pool.get(model_name)
+ if hasattr(model_obj, name) and \
+ callable(getattr(model_obj, name)):
+ def func(cursor, user, ids, *args, **kwargs):
+ # Replace ids by the parent ids
+ ids = [getattr(x, field_name).id for x in
+ self.browse(cursor, user, ids)]
+ return getattr(model_obj, name)(cursor, user, ids,
+ *args, **kwargs)
+ return func
+ raise
+
def _inherits_reload(self):
"""
Reconstruct _inherit_fields
--
Cédric Krier
B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/
pgpUmNrZsmP85.pgp
Description: PGP signature
