Skip to Content
Menu
This question has been flagged
1 Reply
1910 Views

Models

class GLAccount(models.Model):
_name = 'glaccount'
    ......

class SaleOrderLine(models.Model):
name = 'sale.order.line'
_inherit = 'sale.order.line'
_description = 'Sales Order Line'

x_glaccount_id = fields.Many2one(
'glaccount',
string='GL Account',
required=False
)
###################
XML View





sale.order.inherited.view.form.glaccount
sale.order



placeholder="GL Account or Reference"
/>





############################
Exception:


....

Element '' cannot be located in parent view

View name: sale.order.inherited.view.form.glaccount
Error context:
 view: ir.ui.view(1032,)
 xmlid: view_sale_inherit_glaccount
 view.model: sale.order
 view.parent: ir.ui.view(835,)

......


Avatar
Discard
Best Answer

Hello Aleksandar Rajic,

Hope you are doing well.

If you inherit any model then no need to write '_name' in model just write '_inherit' and here is the ref for the xpath

Model :

class SaleOrderLineInherit(models.Model):
_inherit = 'sale.order.line'
_description = 'Sales Order Line Inherit'

x_glaccount_id = fields.Many2one(
'glaccount',
string='GL Account',
required=False
)
Xml View : code is below in comment



Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

Code is here :

<record model="ir.ui.view" id="sale_order_form_view_update">
<field name="name">sale.order.form.view.update</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"></field>
<field name="arch" type="xml">
<xpath expr="//tree//field[@name='product_template_id']" position="after" >
<field name="x_glaccount_id"/>
</xpath>
</field>
</record>

Related Posts Replies Views Activity
1
Dec 24
185
1
Aug 24
424
2
Nov 24
760
2
Mar 24
695
3
Oct 23
13197