Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3845 Lượt xem

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 !



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 22
2777
2
thg 9 22
8704
1
thg 6 25
15365
3
thg 4 25
5539
Compute Fields Đã xử lý
2
thg 7 24
2551