Přejít na obsah
Menu
This question has been flagged

Hey i have duplicated purchase order module and now i am adding field only to that duplicated view. I am able to add fields in the header part but when i try to add field in the line view it gives error like

'field partner does not exist'

Can you tell how i am suppose to do that

class PurchaseInvestment(models.Model):
_name = 'purchase.investment'
_inherit = 'purchase.order'

partner = fields.Many2one('res.partner', string='Investor')

This is my py file and here is my xml
<record model="ir.ui.view" id="tata_mod_pr_investment">
<field name="name">Purchase Order Investment</field>
<field name="model">purchase.investment</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page[1]/field/tree" position="inside">
<field name="partner"/>
</xpath>

</field>
</record>
Avatar
Zrušit
Nejlepší odpověď

probably you might need to update the module. When you do that, you will find that your form is not correct because you are adding a field "partner" to the purchase order. Try using  <field name="mode">primary</field> after  <field name="inherit_id".

Also, I suggest you look at the code, there are lot's of nice examples there

Avatar
Zrušit
Autor

Hey Thanks for replying ,What would this mode field do? not working in my case though

using xml inherit_id will only change existing form, to create a new one we use that mode. On a new object maybe you just should create the form from scratch or copy paste the purchase order and change

Related Posts Odpovědi Zobrazení Aktivita
2
pro 22
5468
2
srp 23
3282
3
dub 23
2386
3
pro 22
33976
1
bře 15
5132