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

HI,

I created one field in one model like field_1,field_2_field_3 in demo.demo.
but i want show all these field to sale order view in odoo and also i want 

inserted value from sale order save in field_1,field_2_field_3, in demo.demo with sale.order id..
please tell me how to inherit sale order view with different model(demo.demo in this case).
or any other way to achieve solution.
Thanks..

Avatar
Discard
Best Answer

Hello Himanshu,

Here you need to use the concept of one2many field type of your custom model i.e demo.demo in sale_order


demo_demo.py

---------------------------------------

class DemoDemo(models.Model):

    _name = 'demo.demo'


    field1 = 

    field2 = 

    field3 =

    sale_order_id = fields.One2many('sale.order', string="Sale Order")


sale_order.py

---------------------------------------

class SaleOrder(models.Model):

    _inherit = 'sale.order'


    demo_ids = fields.One2many('demo.demo', sale_order_id, string="Demo")



From xml side you need to inherit the sale_order form view i.e "view_order_form"


sale_order_view.xml

--------------------------------


<record id="view_order_form" model="ir.ui.view">

    <field name="name">sale.order.form</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

    <field name="arch" type="xml">

<xpath expr="//form/sheet/notebook" position="inside">

    <page string="Demo Lines">

                <field name="demo_ids">

<tree string="Demo Lines" editable="bottom">

            <field name="field1"/>

            <field name="field2"/>

    <field name="field3"/>

                        </tree>

</field>

   </page>

</xpath>

    </field>

</record>


For detailed information regarding field type in odoo, you may refer this link https://www.cybrosys.com/blog/fields-and-parameters-in-odoo

And for inherit view -> http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html


Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Discard
Author

Thanks , i will try this.