Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How to add a specific column on sale.order table?

Subscribe

Get notified when there's activity on this post

This question has been flagged
modulecolumnsale.order.formsale.order
5 Replies
16719 Views
Avatar
wizardz

Hello,

I want to make a new column after product_id here in sale.order (see screenshot)

http://diezcode.ch/spalte-einsetzten.PNG


I have made a module with a new field(char) for product. But I want it in the column in sale.order , 



Ok I found a way like this:

With this way you can add a column in the sale.order.line and then you can edit it with no problems:

 <record model="ir.ui.view" id="sale_margin_percent_1"> 
    <field name="name">sale.margin.percent.view.form</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='order_line']/form//field[@name='product_id']" position="before">
            <field name="new_field"/>
        </xpath>
     </field> </record>
<record model="ir.ui.view" id="sale_margin_percent_2">
    <field name="name">sale.order.line.tree.margin.view.form</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='order_line']/tree//field[@name='product_id']" position="before">
            <field name="new_field"/>
        </xpath>
    </field>
</record> 
0
Avatar
Discard
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Best Answer

Hi Stephane,

You should inherit that view and use an xpath to add the custom field in it. An example that adds a field:

    <record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//tree[@string='Sales Order Lines']/field[@name='name']" position="after">
<field name="yourCustomField"/>
</xpath>
</field>
</record>

Yenthe

1
Avatar
Discard
wizardz
Author

and how I make it when the field comes from product.product ? It says to me that the field does not exist. I wanna put the field from product to sale.order lines.

Maurice Agée

I have also same problem . See https://www.odoo.com/fr_FR/forum/help-1/question/how-to-add-a-new-field-in-a-class-from-another-which-is-already-inherited-91356

Avatar
Akhil P Sivan
Best Answer

Hi,

So you have defined the new Char field in product.product right?

Then one option is to define a new related field in sale.order.line. And call that related field, like Yenthe described above.

Hope you are working v8.

For eg:

in your py file:

class sale_order_line(models.Model):

_inherit = 'sale.order.line'

new_field = fields.Char(related='product_id.your_field', string='New Field')

in your xml file, like Yenthe told:

<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//tree[@string='Sales Order Lines']/field[@name='name']" position="after">
<field name="new_field"/>
</xpath>
</field>
</record>
1
Avatar
Discard
Avatar
Sehrish
Best Answer

In Odoo/OpenERP we can inherit or use existing modules object/class/model and views. We can also inherit single field of existing modules. The question is why we need such inheritance.

The purpose of inheritance or why we need inheritance is given below:

  1. To change attributes of some fields which exists on existing/custom model (e.g. making fields readonly,invisible)

  2. To add/modify/delete old or new fields in existing/custom model (e.g. Product, Sales, HR, Fleet Management, Attendance modules model etc)

  3. We can also add buttons in already existing/custom model (form and tree) view by using inheritance

Get .py and .xml code from here:

http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to inherit sale.order into my custom module
sales module custom sale.order.form sale.order
Avatar
Avatar
Avatar
2
Aug 23
3865
Modificación Lista de Productos en una Orden de Venta Solved
sale.order.line sale.order.form sale.order
Avatar
Avatar
2
Apr 25
1640
How to enter a batch of order lines in Sales Order?
sale.order.line sale.order.form sale.order
Avatar
0
Mar 15
6038
How to add a new status to the sales app(quotation) using studio? Solved
sale.order.form sale.order developer v14
Avatar
Avatar
Avatar
2
Jul 25
4937
Change Sale Order Behavior when use ENTER Key
javascript sale.order.line sale.order.form sale.order
Avatar
Avatar
2
Mar 21
3664
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now