Search code examples
pythonpython-3.xodoostockodoo-11

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


What I mean is that;

Model with name "stock.return.picking" has "location_id" field.

When I click on the return button , I want to see all the location_id. But location_id has domain:

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)]"
)

How can I change this domain?


Solution

  • You have to redefine the location_id field, inheriting from stock.return.picking model. You could do something like this:

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