Skip to Content
Menu
This question has been flagged
2 Replies
4836 Views


def _wc(self, cr, uid, ids, field_name, arg, context=None):

      res = {}

      v = {'w': 1,'l': 1,'h': 1,}

      for f in self.browse(cr, uid, ids, context=context):

          res[f.id] = v

          res[f.id]['w'] = 8*1

          res[f.id]['l'] = 8*2

          res[f.id]['h'] = 8*3

      return res

--------------------------------------------------------------------------------------------------------------

def _wc2(self, cr, uid, ids, field_name, arg, context=None):

      res = {}

      v = {'x': 1,'y': 1,}

      for f in self.browse(cr, uid, ids, context=context):

          res[f.id] = v

          res[f.id]['x'] = how to get value ...'w' from def _wc.... ??

          res[f.id]['y'] = 25

      return res

Avatar
Discard
Best Answer

Hello Kitcle,

It seems w is your function field so you directly can get it's value either browse or read method.

Try following code:

res[f.id]['x'] = f.w #how to get value ...'w' from def _wc.... ??

System will call function when you access function field if the field is not stored in database, otherwise system will get it's value from database instead calling method.

Reference: Function field

Avatar
Discard
Best Answer

kitcle,

This guidance might help you.

1) If you will combined both the function by applying multi="your key" on that field it will call the common function for all the fields, so you can return at the same time all the fileds value, it will be easy to get information based on another field.

2) If you are using v8 (api) coding standard

Than you can directly use store=true, it will always  store the latest calculated value in the database, because in api coding standard , it using depends decorator.

Here is the link for that example : click here  for more information for store=true in v8, follow the answer given in attached link.

Or Explain more your question if you don't want to comibined function for all field, explain the exact purpose for doing this.


Regards,

Anil.


Avatar
Discard