Not send email in case has not assignee

This commit is contained in:
Raimon Esteve 2022-03-01 19:02:50 +01:00
parent 6b8261ecb8
commit 1ea6ead8c1
1 changed files with 7 additions and 0 deletions

View File

@ -53,6 +53,8 @@ class Work(metaclass=PoolMeta):
super().write(*args)
for record in cls.browse(previous.keys()):
if not record.assignee:
continue
if(record.assignee != previous.get(record.id)):
after[record.id] = {
'assignee': record.assignee,
@ -63,11 +65,16 @@ class Work(metaclass=PoolMeta):
def send_assignee_mail(self, previous, after):
pool = Pool()
User = pool.get('res.user')
if not self.assignee:
return
users = User.search([('id', '=', self.write_uid)], limit=1)
if users:
user, = users
else:
user = None
body = []
previous_assignee = previous.get('assignee')
if previous_assignee: