如何通过继承改变Many2one字段的域?

How to change the domain of the Many2one field by inheritance?

我的意思是说;

名称为 "stock.return.picking" 的模型有 "location_id" 字段。

当我单击 return 按钮时,我想查看所有 location_id。但是 location_id 有域:

location_id = fields.Many2one(
    comodel_name='stock.location',
    string='Return Location',
    domain="['|', ('id', '=', original_location_id),'&', ('return_location', '=', True), ('id', 'child_of',     parent_location_id)]"
)

如何更改此域名?

您必须重新定义 location_id 字段,继承自 stock.return.picking 模型。你可以这样做:

location_id = fields.Many2one(
    comodel_name='stock.location',
    domain="[('id', '!=', 0)]",
)