Chào tất cả mọi người !
Mọi người cho em hỏi vấn đề thừa kế trong odoo ạ.
Em viết 1 class res.partner kế thừa từ class res.partner , và em muốn thêm vào 1 fields mới .
Class mới này dùng view (màn hình giao diện) của của object cũ .
vậy em làm thế nào để fields em mới tạo đó hiển thị trên form ạ.
Ai biết trả lời giúp em với !!!
Em cám ơn
Welcome!
This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
Hỏi về thừa kế trong odoo ?
Câu hỏi này đã bị gắn cờ
2
Trả lời
5383
Xem
Dạ em cám ơn ạ .
Em làm được rồi ạ
Đơn giản thôi. Giả sử mình muốn thêm trường to_insurance vào sau trường name của đối tượng res.partner thì mình làm như sau:
Python: Tạo một class mới kế thừa với nội dung như sau
class res_partner(models.Model):
_inherit = 'res.partner'
to_insurance = fields.Boolean(string="Insurance Partner")
XML View: Chèn trường code vào sau trường name
<record id="to_hr_insurance_authority_form" model="ir.ui.view">
<field name="name">to.hr.insurance.authority.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"></field>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="code" string="Code" ></field>
</xpath>
</field>
</record>
Lưu ý cái chỗ inherit_id phải tìm được đúng id của cái form mà muốn kế thừa (cụ thể ở đây là view_partner_form của module base)
Làm thử và cho mình biết kết quả nhé.