I have one master model and i need to show 2 different fields from the same other model how can i do it?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Dự án
- MRP
Câu hỏi này đã bị gắn cờ
You have to set "relation" attribute for the fields so the odoo ORM can distinguish the tables.
example:
from odoo import fields, models
class Rel(models.Model):
_name = 'module.rel'
name = fields.Char()
class Master(models.Model):
_name = 'module.master'
rel_id = fields.Many2many('module.rel', relation='module_rel_rel_1')
rel_id_2 = fields.Many2many('module.rel', relation='module_rel_rel_2')
Hello.
I don't get your question, if you mean show fileds from one model in another you can use Many2one and create these two fields as related fields.
_Eg: model_id = fields.Many2one(comodel_name="your.model")
field_1 = fields.Char(related=model_id.the_name_of_the_field)
field_2 = fields.Char(related=model_id.the_name_of_the_field)
In (Char) you must include your field type, and it must be the same as in your master model.
In comodel_name you must put the Master model name dot separeted.
If not your answer, please tell more details.
Thanks Jodoo i tried related and its working fine
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký