Hello All,
I have class called _name = "stock.request.order"
on this class i have a fields :
warehouse_id = fields.Many2one('stock.warehouse', string="Warehouse",)
warehouse_user_on_requist = fields.Many2one('res.users', string="User ID", default=lambda self: self.env.user)
and i have inherit the stock.warehouse and add on field:
class StockWarehouse(models.Model):
_inherit = "stock.warehouse"
warehouse_user = fields.Many2one('res.users', string="Warehouse User")
now what i want to do is that i will register a user on each warehouse warehouse_user
and on the class "stock.request.order"
i will call all the warehouses on warehouse_id filed but only if the current user is registered on the warehouse
it is simple a filter for the many2one filed that shouwing the requord if the current user is the same one that on the warehouse_user filed on the stock.warehouse class
i have try many thing but its not working for me
using def
warehouse_id = fields.Many2one('stock.warehouse', string="Warehouse",)
warehouse_user = fields.Many2one('res.users', string="User ID", default=lambda self: self.env.user)
def _calc_user(self):
userr_id = 0
if self.warehouse_id:
userr_id = self.warehouse_id.warehouse_user.id
return {"domain": {'warehouse_id': [('id', '=', userr_id)]}}
not working
using domain
warehouse_id = fields.Many2one('stock.warehouse', string="Warehouse", domain="[('warehouse_user', '=', warehouse_user)]")
warehouse_user = fields.Many2one('res.users', string="User ID", default=lambda self: self.env.user)
not working
please help