Skip to Content
Menu
This question has been flagged
1 Reply
3226 Views

I'm trying to add a computed field from the UI (x_my_field) to the model sale.order whose value is computed based on 2 other fields, let's say field1 from the model sale.order.line and field2 from the model mrp.bom.line : 

x_my_field = sale_order_line.field1 * mrp_bom_line.field2 

But i can't figure out how to add the correct dependencies !!! to make it work.

All fields are of type float.

Any advice or help !



Avatar
Discard
Best Answer

Are you editing odoo base? Editing odoo base is not recommended.

I would recommend creating another module that depends on mrp and sale (define it on the manifest). 

https://www.odoo.com/forum/help-1/getting-started-with-editing-community-source-code-182202

https://www.odoo.com/documentation/master/developer/tutorials/backend.html

Then you can inherit 'sale.order' and change it as you see fit.

Hope that helps.

Avatar
Discard
Author

Thank you, but i just want to add this field from the UI

I don't have much experience on the UI part. What you are saying may not be possible, as you are accessing a field from another module that does not depend on the previous field module (if that makes any sense: you are binding 'mrp' to 'sales', even tho it was not designed this way).
Hope someone can clarify you if that can work or not.

PD: You can try creating a module using studio, and make the field there, and then just create the views... Not sure if that would work either.

Related Posts Replies Views Activity
1
May 22
2313
2
Sep 22
8225
3
Apr 25
3910
2
Jul 24
1283
4
May 24
11367