Odoo Help


How to add a column to Sales Order Lines?

Anabela Damas
on 3/18/13, 3:07 PM 6,004 views

Hi, First of all I had a new parameter to the product. Then I need that new parameter in Sales Order Lines for each product in the sales order.

I've tried to add but I had some problems regarding to being inheriting a view from sales.order and adding a parameter from products.

I've done this:

<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="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit']" position="before">
         <field name="new_field_from_product"/> 

Thanks, sorry my English.


AJ Schrafel Paper Corp

--AJ Schrafel Paper Corp--
| 4 5 8
Bronx, United States
--AJ Schrafel Paper Corp--

Exploring OpenERP for business

AJ Schrafel Paper Corp
On 3/18/13, 4:05 PM

First, The code you posted is trying to insert your new field into the view_ORDER_form, you need to insert it on the view_ORDER_LINE_form.

Second, the python code must also inherit and add the new field, if you are not doing that, there is no way your XML will work right.

Third, when you ask for help, please include the error message. Without the error message those trying to help you are flying blind.

I've changed the code to: <record id="view_order_line_form_inherit" model="ir.ui.view"> <field name="name">sale.order.line.form.inherit</field> <field name="model">sale.order.line</field> <field name="inherit_id" ref="sale.view_order_line_form2"/> <field name="arch" type="xml"> <xpath expr="/form/sheet/group/group/field[@name='price_unit']" position="before"> <field name="vi_adr"/> </xpath> </field> </record>

Versão Integral, Anabela Damas
on 3/19/13, 11:47 AM

In the second point you said that I've to inherit and and the new field, class product_product(osv.osv): _inherit = "product.product" _name = "product.product" _columns = { 'vi_adr': fields.boolean('ADR', help="Check this box if the product needs ADR (Accord europeen relatif au transport international des marchandises Dangereuses par Route)"), } product_product() Is this that you mean or is to add the new field in the sale.order.line?

Versão Integral, Anabela Damas
on 3/19/13, 11:56 AM

And the error that I've with the new code is: Can't find field 'vi_adr' in the following view parts composing the view of object model 'sale.order.line': * sale.order.line.form.inherit Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model openerp.addons.base.ir.ir_ui_view: Can't render view mutante.view_order_line_form_inherit for model: sale.order.line

Versão Integral, Anabela Damas
on 3/19/13, 11:56 AM

you must upload your code, then stop and start your server to get openERP to recognize the new fields you added in your python file.

AJ Schrafel Paper Corp
on 3/19/13, 11:58 AM

I'm stoping and starting the server by doing this : ./openerp-server -c install/openerp-server.conf --update=mynewmodule, but the error that I've mentioned is always there..

Versão Integral, Anabela Damas
on 3/19/13, 12:02 PM

that is wrong, you must FIRST stop the server. ./openerp-server stop SECOND run the command to confirm the server has stopped - ps aux | grep openerp THIRD kill any other running processes FINALLY start the server again ./openerp-server start capitals are for readability because you cannot put new lines in the comments.

AJ Schrafel Paper Corp
on 3/19/13, 12:03 PM

I've this error doing like you told me to: ./openerp-server start No handlers could be found for logger "openerp.addons.google_docs.google_docs" Traceback (most recent call last): File "./openerp-server", line 5, in <module> openerp.cli.main() File "/opt/openerp-7.0/openerp/cli/__init__.py", line 51, in main __import__(m) File "/opt/openerp-7.0/openerp/modules/module.py", line 133, in load_module mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)

Versão Integral, Anabela Damas
on 3/19/13, 12:13 PM

File "/opt/openerp-7.0/openerp/addons/base_action_rule/__init__.py", line 23, in <module> import test_models File "/opt/openerp-7.0/openerp/addons/base_action_rule/test_models.py", line 1, in <module> from osv import osv, fields

Versão Integral, Anabela Damas
on 3/19/13, 12:13 PM

I've put this working but the error is still here: " Can't find field 'vi_adr' ..."

Versão Integral, Anabela Damas
on 3/19/13, 12:55 PM

you must add the attribute to class sale_order_line(osv.osv): if you want to record that information in an order line. If you have a product that is or is not ADR it would be much easier for you to just create 2 different products. I do not know what ADR is, so i cannot adivse you.

AJ Schrafel Paper Corp
on 3/19/13, 4:06 PM

So if I had a field to products and if I want that field to appear in the sale_order_line I have to add this field to the class sale_order_line(osv.osv)? ADR - "Accord europeen relatif au transport international des marchandises Dangereuses par Route" Thanks

Versão Integral, Anabela Damas
on 3/20/13, 6:35 AM

Yes, but it would probably be easier for you to create a product ADR, and add that to orders that require ADR. Or create 2 product entries - one with ADR and one without, for each of your products. That would remove the need for you to do any custom coding.

AJ Schrafel Paper Corp
on 3/20/13, 10:28 AM

Hi, please share all module, tnks

Jhon Felipe Urrego Mejia
on 3/19/14, 6:47 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/18/13, 3:07 PM
Seen: 6004 times
Last updated: 3/16/15, 8:10 AM