跳至內容
選單
此問題已被標幟

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>
頭像
捨棄
最佳答案

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

頭像
捨棄
作者

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

相關帖文 回覆 瀏覽次數 活動
2
12月 22
5521
2
8月 23
3328
3
4月 23
2426
3
12月 22
34051
1
3月 15
5173