Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar
Mejor respuesta

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
Descartar
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

Publicaciones relacionadas Respuestas Vistas Actividad
2
dic 22
5495
2
ago 23
3302
3
abr 23
2402
3
dic 22
34004
1
mar 15
5150