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.

4

how to write fields.function with depends and inverse function in v8

By
Hardik Patadia
on 8/29/14, 8:16 AM 3,108 views

For Odoo V8

I have a field.function in product.product model, depending on two fields one from product.template say "a" and one from product.product "b", also it has got an inverse function which is having no definition, which allows me to write the value manually in the field.function field.

Now when I try to delete the value of the field "b" it calls the field.function and calculates the field but also deletes the value of field "a" (field from product.template) . I am not getting why this is happening.

Can any one guide me please

 

3

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 9/2/15, 8:00 AM

In v8, instead of fields.function, we use the compute field and @api.depends if the field depends on some other fields and that can be dotted paths when using sub-fields.

A simple example:

name = fields.Char(string="Name")
upper = fields.Char(compute='_compute_upper', inverse='_inverse_upper')

@api.depends('name')
def _compute_upper(self):
for rec in self:
self.upper = self.name.upper() if self.name else False

def _inverse_upper(self):
for rec in self:
self.name = self.upper.lower() if self.upper else False

I can help you better if you tell me what exactly you want to do, like which are the fields or paste your code.

Thank you Akhil..

Hardik Patadia
on 9/2/15, 8:18 AM

Did you solve the problem Hardik?

Akhil P Sivan
on 9/2/15, 9:40 AM

Hey Akhil i have another case which i need to execute the computed field each time there is an update in odoo field in setting another model without relation

Mostafa Abd El Fattah
on 8/22/16, 7:59 AM

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: 8/29/14, 8:16 AM
Seen: 3108 times
Last updated: 9/2/15, 8:01 AM