跳至内容
菜单
此问题已终结
3 回复
4283 查看

Hi everyone,

I have a field:

current_roomtype_id = fields.Many2one(related='current_room_id.roomtype_id', store=True, track_visibility='onchange', readonly=True)

Every current_room_id has a not null roomtype_id, so this field should never be null, but in some cases (cannot track it down!) Odoo stores 'null' in this field, and there are no information in chatter when and how it was changed even though I put track_visibility='onchange'.

Anyone has any ideas?

形象
丢弃
编写者 最佳答案

The issue was with a OCA module: Auditlog
If I remove the rule for this model - it works just fine and related fields are stored.
If I add rule with Type=Full log - some related fields are not stored!

Made a bug report in Github:

\https://github.com/OCA/server-tools/issues/1676

形象
丢弃
最佳答案
current_roomtype_id = fields.Many2one('model_name',related='current_room_id.roomtype_id',
store=True, track_visibility='onchange', readonly=True)

Hi, 

You are missing model name in defination of Many2one field, 

please try this

current_roomtype_id = fields.Many2one('model_name',related='current_room_id.roomtype_id',
store=True, track_visibility='onchange', readonly=True)

Thanks !!!  

Aswini @ iWesabe




形象
丢弃
编写者

Thanks for your idea, I've just tried this - still not working.

I've also tried to remove readonly=True from field definition - also not working.

If I duplicate this database - the problem stays, however if I create a new database - there's no problem. Trying to figure out what's the difference.