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

created a related field in my Model items which seems fine untill unless i add it in "form view".

classification_id = fields.Many2one('donation.types', related="donation_type_id.classification_id", store=True)


when add it to form view copying from tree view it is showing error when i press button New from tree view. it is showing in tree view means i have restarted odoo service and upgraded module.


ValueError: Wrong value for items.classification_id: classification()


please help to resolve the problem.

regards


Ảnh đại diện
Huỷ bỏ

Hi, could you please post the complete Class code?

Câu trả lời hay nhất

Hi,

You can add a related field for this, suppose you have a field named classification_id in your model, and if you need to show the same in the other model form, add a new field to the model and give the relation as this:
donation_type_id = fields.Many2one('refer_model.name')
classification_id = fields.Many2one('donation.types', related="donation_type_id.classification_id", store=True)
In the refer_model.name you must add the field classification_id
classification_id = fields.Many2one('model.name')

for eg when you try to add an employee number in the hr.employee model into another model
hr. employee :

employee_number = fields.Integer('Employee Number', copy=False,readonly=True)

your model :

nominee_id = fields.Many2one('hr.employee')
employee_number = fields.Integer('Employee Number', copy=False,related='nominee_id.employee_number',readonly=True)

you can try this way


Hope it helps

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

thanks, it works fine now.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 25
2451
1
thg 4 25
3470
1
thg 4 25
4299
1
thg 4 25
1780
4
thg 3 25
6889