Odoo Help


This community 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.


Added column to purchase order line not showing up in db (pgadminIII)

Christian Parent
on 4/16/14, 3:59 PM 943 views

I am trying to access the field manufacturer_pref from the product.product table from the purchase order report.

This is the module that created the field :

class product_product(osv.osv):
_inherit = 'product.product'
_columns = {
    'manufacturer' : fields.many2one('res.partner', 'Manufacturer'),
    'manufacturer_pname' : fields.char('Manufacturer Product Name', size=64),
    'manufacturer_pref' : fields.char('Manufacturer Product Code', size=64),
    'attribute_ids': fields.one2many('product.manufacturer.attribute', 'product_id', 'Attributes'),

I went in the purchase module, edited purchase.py and added this under _columns = {

'manufacturer_pref': fields.related('order_line','manufacturer_pref', type='char', relation='product.product', string='Manufacturer'),

saved, did a

./openerp-server -db My_DB -u=all

and when I get back in pgAdminIII, when I look in purchase_order_line table, the column is not showing up.

Where I am wrong ?


Med Said BARA

--Med Said BARA--
| 5 5 7
--Med Said BARA--
Med Said BARA
On 4/16/14, 4:34 PM

Did you add it in the class purchase_order or purchase_order_line ?

For the update command try: ./openerp-server -d My_DB -u all

What if adding purchase to order_line:

    'manufacturer_pref': fields.related('purchase_order_line','manufacturer_pref', type='char', relation='product.product',   string='Manufacturer'),

it was in the wrong class indeed, still it aint showing up after moving it down to the right class. It was not in the purchase_order table. I have looked before I made the changes !

Christian Parent
on 4/16/14, 4:44 PM

Used -u all, it was a typo on my side tho as I use --update=all or --update=purchase. Still, after doing so, the new column not showing up in the purchase_order_line table. Is it something in my line that is not set properly ? The column manufacturer_ref is in product_product table. as does the product_id (which already existed) product_id is in the table but still cant get manufacturer_ref !

Christian Parent
on 4/16/14, 4:55 PM

Try adding the path to your openerp-server.conf -c ./openerp-server.conf and --addons=path to your addons folder

Med Said BARA
on 4/16/14, 5:02 PM

column manufacturer_ref or manufacturer_pref ?

Med Said BARA
on 4/16/14, 5:05 PM

Pref indeed. Typo. Will try it later on and let you know

Christian Parent
on 4/16/14, 6:50 PM

The problem realy is with my line :

'manufacturer_pref': fields.related('order_line','product_id','manufacturer_pref', type='char', relation='product.product', string='Manufacturer'),

as I have added a 'test': fields.text('Test'), and it was added to the table.

Christian Parent
on 4/17/14, 11:50 AM

Lets see it that way.

In my table purchase order line, I would like to add a column for both, the manufacturer name (manufacturer_pname) and manufacturer code(manufacturer_pref). those 2 are fields of product wich are located in product.product table.

in the table purchase.order.line, I have the field product_id which is related to my product id in product.product table

'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),

so, I would I get those 2 fields from that product.product table into purchase.order.line table ?

Christian Parent
on 4/17/14, 12:44 PM

That line did not work, in fact, my column manufacturer_pref that I had in the purchase_order_line is gone.

Christian Parent
on 4/17/14, 3:22 PM

when related, the column gets deleted from table.

changed it to 'manufacturer_pref': fields.many2one('order_line','manufacturer_pref', type='char', relation='product.product'), removing string='Manufacturer' has it gives an error, brings the column back in the table but, there is no data in it even tho I do have order lines with product that do hve manufacturer code (manufacturer_pref)

Christian Parent
on 4/17/14, 3:36 PM

store = True

Med Said BARA
on 4/17/14, 4:04 PM

still nothing

Christian Parent
on 4/17/14, 4:10 PM

Could you post the new code ?

Med Said BARA
on 4/17/14, 4:16 PM

removed the extra stuff:

columns = {

    'name': fields.text('Description', required=True),

'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),

'manufacturer_pref': fields.many2one('purchase.order.line','manufacturer_pref', type='char', relation='product.product', store=True),
Christian Parent
on 4/17/14, 4:24 PM
   'manufacturer_pref': fields.many2one('product.product','manufacturer_pref', type='char', string='Manufacturer'),
Med Said BARA
on 4/17/14, 8:55 PM

Will try this tomorrow

Christian Parent
on 4/22/14, 5:56 PM

Tried your line, no go, went back the related field type path, got the column to create itself but, still no value in the column:

'manufacturer_pref': fields.related('manufacturer_pref', type="char", relation="product.product", string="Manufacturer", store=True),
Christian Parent
on 4/23/14, 12:30 PM

Got it, was missing the first reference order_id:

'manufacturer_pref': fields.related('product_id', 'manufacturer_pref', type="char", relation="product.product", string="Manufacturer", store=True),
Christian Parent
on 4/23/14, 1:07 PM
Christian Parent
On 4/23/14, 1:08 PM

solved it: the line needed was :

'manufacturer_pref': fields.related('product_id', 'manufacturer_pref', type="char", relation="product.product", string="Manufacturer", store=True),

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 4/16/14, 3:59 PM
Seen: 943 times
Last updated: 3/16/15, 8:10 AM