跳至內容
選單
此問題已被標幟
4 回覆
13364 瀏覽次數

I have a model

class fbv_use_carrier(models.TransientModel):

pickings = fields.Many2many('stock.picking', 'fbv_use_carrier_line', 'fbv_id', 'picking_id', 'Picking List') 
 class fbv_use_carrier_line(models.TransientModel):
_name=
'fbv.use.carrier.line'


picking_id = fields.Many2one('stock.picking', string='List Piking')
fbv_id = fields.Many2one('fbv.use.carrier', string='FBV Use Carrier ID'

But i have error!

 ProgrammingError: column "id" does not exist
LINE 1: SELECT id FROM fbv_use_carrier_line WHERE COALESCE(write_dat...

Hoping for some feedback!

Thanks

頭像
捨棄

Did you defined name for your class ? like _name = 'fbv.use.carrier'

最佳答案

Hello,

Your problem is "very very" simple,

Solution : 

Just modify the name of table in M2M field definition. Like as below, ( I have marked as bold + italic + underline )

pickings = fields.Many2many('stock.picking', 'fbv_use_carrier_line', 'fbv_id', 'picking_id', 'Picking List')

Reason of Error :

When you define many2many field, 2nd argument creates the table. Now you have given the same name of the table which you have used while defining following class, ( I have marked bold + italic + underline )

class fbv_use_carrier_line(models.TransientModel):
_name='fbv.use.carrier.line'
picking_id = fields.Many2one('stock.picking', string='List Piking')
fbv_id = fields.Many2one('fbv.use.carrier', string='FBV Use Carrier ID'

By adding same name of new M2M table, system overrides new table definition and of course "ID" column will be removed. ( FYI : M2M table stores only 2 columns ). That is why when system evaluates following line,

fbv_id = fields.Many2one('fbv.use.carrier', string='FBV Use Carrier ID'

it shows you error. ( ProgrammingError: column "id" does not exist )

Hope this answer will lead to exact solution of your problem !

頭像
捨棄
最佳答案

Hello I have issue above error while installing ecommerce module.

psycopg2.ProgrammingError: column s.warehouse_id does not exist
LINE 34:         , s.website_id as website_id, s.warehouse_id as ware...


頭像
捨棄
最佳答案

Tazan,

You probably have misunderstood the concept of Many2Many. Its used when you are linking an existing records of another model.

What I read from your code is, you are trying to establish the one2many relation to lines, but you miss it. One2many is used to link multiple lines on dynamism.

If you have written the one2many field, the reference field should be named as fbv_id which is defined as Many2one in carrier lines.

carrier_line_ids = fields.One2many('fbv.use.carrier.line','flv_id', 'Lines').

Hope this helps.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
4月 24
1935
4
11月 23
6034
0
10月 23
1788
0
12月 22
2679
2
12月 23
19449