I have a email field sender_address computed like:
sender_address = fields.Char(
string='Sender email address', readonly=True, store=True,
compute='_compute_sender_address', index=True)
@api.multi
@api.depends('sender')
def _compute_sender_address(self):
for email in self:
if email.sender:
matches = re.search(r'<(.*@.*)>', email.sender)
if matches:
email.sender_address = matches.group(1).lower()
else:
email.sender_address = email.sender.lower()
else:
email.sender_address = False
Then I would like to use this email address to get res.users id:
# get sender user_id
sender_id = fields.Many2one(
string='Sender User ID', comodel_name='res.users', readonly=True, store=True,
compute='_compute_sender_id', index=True)
@api.multi
@api.depends('sender_address')
def _compute_sender_id(self):
for email in self:
if email.sender_address:
email.sender_id = self.env['res.users'].search([('email', 'ilike', 'email.sender_address')], limit=1)
else:
email.sender_id = False
print send_address is correct, but no sender_id.
There's no error in log, please help me how to find problem.