Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
17211 Представления

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

Related Posts Ответы Просмотры Активность
2
мар. 24
1637
0
мар. 23
2887
1
авг. 22
6678
1
янв. 22
3411
1
янв. 19
3497