Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6093 มุมมอง

Hi,


I'm trying to add a custom field to the wizard Configure Your Document Layout, like this:





But the problem is that I don't know how to inherit base.document.layout.

When I try to inherit I get the following error: TypeError: Model 'base.document.layout' does not exist in registry.

That's probably because it's a TransientModel, but how can I add the field if I can't inherit?


My code:

class BaseDocumentLayout(models.TransientModel):
_inherit = 'base.document.layout'

my_field = fields.Char('My Field')


Thanks in advance!





อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Hugo,

 make sure to add correct dependencies in your __manifest__.py file 
 'depends': ['base', 'web'],

class BaseDocumentLayout(models.TransientModel):
_inherit = 'base.document.layout'

my_field = fields.Char('My Field')
XML File
========
<record id="view_base_document_layout" model="ir.ui.view"> <field name="name">Document Layout</field> <field name="model">base.document.layout</field>
<field name="priority">99</field>
<field name="inherit_id" ref="web.view_base_document_layout" />
<field name="arch" type="xml">
<field name="logo" position="after">
<field name="my_field"/>
</field>
</field>
</record>

And ADD This XML File into __manifest__.py file. Cheers!




Thanks & Regards,

Sunny Sheth

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 25
944
4
มี.ค. 24
3530
1
ต.ค. 23
5468
1
มิ.ย. 22
6718
How to inherits only one fields แก้ไขแล้ว
4
มิ.ย. 21
16004