콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4951 화면

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 ?

아바타
취소
베스트 답변

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 !

작성자

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 !

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

column manufacturer_ref or manufacturer_pref ?

작성자

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

작성자

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.

작성자

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 ?

작성자

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

작성자

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)

store = True

작성자

still nothing

Could you post the new code ?

작성자

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),
   'manufacturer_pref': fields.many2one('product.product','manufacturer_pref', type='char', string='Manufacturer'),
작성자

Will try this tomorrow

작성자

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),
작성자

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),
작성자 베스트 답변

solved it: the line needed was :

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