This question has been flagged
4 Replies
6079 Views

(odoo 10)I tried to create a primary form that inherits the vendor bills form to hide the field 'purchase_id'. 

The problem is that the system raised error saying the field was not found in the parent.

The field 'purchase_id' is originally in an extension view of the parent. I tried inheriting from the parent and the extension but both doesn't work. Can anyone help? 



Here is the code:

<record id="view_coop_member_sell_share_vendor_bill_form" model="ir.ui.view">
<field name="name">coop.member.sell.share.vendor.bill.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form" />
<field name="mode">primary</field>
<field eval="20" name="priority"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='purchase_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
                 ....


Here is the parent:

<record id="invoice_supplier_form" model="ir.ui.view">
<field name="name">account.invoice.supplier.form</field>
<field name="model">account.invoice</field>
<field name="priority">2</field>
<field name="arch" type="xml">
<form string="Vendor Bill">
<header>
                ...


Here is the extension where the 'purchase_id' is

<ecordid="view_invoice_supplier_purchase_form"model="ir.ui.view">
<field name="name">account.invoice.supplier.purchase</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<field name="reference" position="after" >
<field name="purchase_id" attrs="{'invisible': [('state', '=', 'purchase')]}" class="oe_edit_only"
options="{'no_create': True}"/>
</field>
             ....
Avatar
Discard
Best Answer

Hi,

Change the inherit_id.

<field name="inherit_id" ref="purchase.view_invoice_supplier_purchase_form" />

Thank you

Avatar
Discard
Author Best Answer

Hi Avinash, I tried that too but it didn't work

Error context:
View `coop.member.sell.share.vendor.bill.form`
[view_id: 852, xml_id: coop_member.view_coop_member_sell_share_vendor_bill_form, model: account.invoice, parent_id: 727]
2017-08-17 08:56:20,329 13512 INFO Test14AUG3 odoo.addons.base.ir.ir_ui_view: Can't validate view:
Field `purchase_id` does not exist
SOLVED:
Poor me. Just noticed that I did not add 'purchase' module to the 'depends' list in the manifest file.
'depends': ['product','sale','account','hr','purchase'],
Now either inherit from the parent or from the extension, both works!

Thank you!
Avatar
Discard

Try this code,

<data>

<record model="ir.ui.view" id="view_coop_member_sell_share_vendor_bill_form">

<field name="name">coop.member.sell.share.vendor.bill.form</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="purchase.view_invoice_supplier_purchase_form"/>

<field name="arch" type="xml">

<xpath expr="//field[@name='purchase_id']" position="attributes">

<attribute name="invisible">1</attribute>

</xpath>

</field>

</record>

</data>

Author

SOLVED:

Poor me. Just noticed that I did not add 'purchase' module to the 'depends' list in the manifest file.

'depends': ['product','sale','account','hr','purchase'],

Now either inherit from the parent or from the extension, both works!

Thank you!