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

Hello,


I am using V8 and I would like to read the value of a selection field from another form, normally which types should I use ? field.related or field.many2one or both of them.

The original model is "product.template" , I would like to know the value of the field "type" which is a selection field in the model.

the other model is "product.supplierinfo", It already contains a field which is defined as follows:

'product_tmpl_id' : fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade', select=True, oldname='product_id'),

I extended this model to add a new field which will hold the value of the selection field in product using the incoming code:

product_type = fields.Selection(related='product_tmpl_id.type',store=True)

But when I open the form I don't find the selected type value, I just find the selection drop-down menu without selected option.


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

dear mohamed aboelfadl,

please add selection to the field attribute as same as selection on product type

product_type = fields.Selection(selection=[('',''),('',''),....], related='product_tmpl_id.type',store=True)

I hope I helped you ...

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

I tried this solution but the value of my field doesn't take the original value unless I assign a value for both in the beginning, the scenario I tried is as follows.

select a value in the original selection "type" then save then edit then check the value of my field "product_type" it shows empty as not selected yet. the second scenario I choose a value for "product type" , then I check the value of "type" I find that it was assigned the same value that I chose and then they become related if I change any of them the other one changes

Do you know how to solve this issue ? Thanks in advance

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 16
5727
1
thg 8 15
5301
0
thg 3 15
3316
1
thg 11 24
4410
2
thg 4 24
9294