Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
5292 Zobrazení


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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit