Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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>
Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
2
gru 22
5485
2
sie 23
3285
3
kwi 23
2390
3
gru 22
33991
1
mar 15
5140