Skip to Content
Menu
This question has been flagged
2 Replies
2332 Views

 I develop module with name "sites" in odoo 10v i have few fields in this module,


class sites(models.Model):
    _name = 'sites.sites'
    customer_site_name = fields.Char('Site Name')
  
I checked the data in my table  using query "select customer_site_name from sites_sites"

i just want to show my column "customer_site_name" in sales order form in many2one relation (dropdownlist)

please help out me with sample code
Avatar
Discard
Best Answer

To add a new field to sale order form

py file:

class SomeClassName(models.Model):

     _inherit = 'sale.order'

     _rec_name=' your_ref_field'            #if you want to see this field's name in sale order


     your_ref_field = fields.Many2one('sites.sites', string='Some Name')

xml file

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

            <field name="name">my.name</field>

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

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

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

                <xpath expr="field[@name='partner_id']" position="after">

                    <field name="your_ref_field"/>

                </xpath>

            </field>

</record>

Avatar
Discard
Author Best Answer

Thank you so much its working now but tell me one more thing 

I want to expose more than 1 field in sales order how i can achieve it by,

  _rec_name=' your_ref_field'   


Avatar
Discard