Dear All,
We are in development of store request module, that a department user request items to store and they will deliver based on the request. So in department module we created dept_location_id = fields.Many2one('stock.location', 'Department Location'). Its working fine. My problem is I need this value in my custom module store request. So i create a compute function in store request module. Raise error is showing correct location id, But the function is not returning any value. Any help is highly appreciated. Thanks.
#---------------------------To find Department warehouse Location----------------------
@api.one
@api.depends('partner_id')
def _compute_department_location(self):
loc_id = 1
if (self.partner_id.id == False):
#self.department_id = None
loc_id = None
return
employee = self.env['hr.employee'].search([('work_email', '=', self.partner_id.email)])
if (len(employee) > 0):
self.department_id = employee[0].department_id.id
dept_id = self.env['hr.department'].search([('id', '=', self.department_id.id)])
if (len(dept_id) > 0):
loc_id = dept_id[0].dept_location_id.id
# raise UserError(_('Test - %s') % loc_id)
else:
loc_id = None
else:
loc_id = None
# raise UserError(_('Test - %s') % loc_id)
return loc_id
dept_location_id = fields.Many2one('stock.location', 'Department Location',
compute='_compute_department_location',ondelete="cascade",store=True)