Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to get value from another function?

By
kitcle
on 4/11/15, 1:43 AM 696 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

1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/11/15, 3:28 AM

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

2

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
On 4/11/15, 6:52 AM

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.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/11/15, 1:43 AM
Seen: 696 times
Last updated: 3/13/16, 7:43 AM