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

I have a field on stock_picking table I would like to relate it with stock_move

_inherit= 'stock.picking'

_column={

'user_id': fields.many2one('res.users', 'user', select=True),

}

I would like to relate the field user_id with stock_move
I tried this

_inherit= 'stock.move'

_column={

  'user_id': fields.related('picking_id', 'user_id', relation="res.users", type='many2one', string="user", store=True, readonly=True)

}

any Idea brothers?

頭像
捨棄
最佳答案

I think model in inherit it should be as follows:

_inherit= 'stock.picking'

_columns={ 'user_id': fields.many2one('res.users', 'user', select=True), }

_inherit= 'stock.move'

_columns={ 'user_id': fields.related('picking_id', 'user_id', relation="res.users", type='many2one', string="user", store=True, readonly=True) }

頭像
捨棄
作者

no value stored in the table on the field user_id !!!

ans edited... check it.. wrongly spelled _columns ans _column.

作者

the column user_id couldn't be updated, I droped it from the table & I tried it work fine now

最佳答案

Hello rachid,

 

you have added field in wrong model. try this,

_inherit= 'stock.move'

_columns={

  'user_id': fields.related('picking_id', 'user_id', relation="res.users", type='many2one', string="user", store=True, readonly=True)

}

and yeah this code is correct.

_inherit= 'stock.picking'

_columns={

'user_id': fields.many2one('res.users', 'user', select=True),

}

Hope this will help you. for more details on related field check this.

 

頭像
捨棄
作者

the column user_id couldn't be updated, I droped it from the table & I tried it work fine now

相關帖文 回覆 瀏覽次數 活動
2
3月 24
1637
0
3月 23
2890
1
8月 22
6681
1
1月 22
3412
1
1月 19
3497