Skip to content

Commit

Permalink
[FIX] mail: prevent useless write
Browse files Browse the repository at this point in the history
In database with frontend and live chat there are lot of bad query error.
bad query: UPDATE "mail_channel_partner" SET "write_uid"=5,"write_date"=(now() at time zone 'UTC') WHERE id IN (328111)

closes odoo#71291

Error: Could not serialize access due to concurrent update
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
  • Loading branch information
fmdl committed May 26, 2021
1 parent ee859a1 commit f10e04e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions addons/mail/models/mail_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,14 @@ def channel_fold(self, uuid, state=None):
state = 'folded'
else:
state = 'open'
session_state.write({
'fold_state': state,
'is_minimized': bool(state != 'closed'),
})
is_minimized = bool(state != 'closed')
vals = {}
if session_state.fold_state != state:
vals['fold_state'] = state
if session_state.is_minimized != is_minimized:
vals['is_minimized'] = is_minimized
if vals:
session_state.write(vals)
self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), session_state.channel_id.channel_info()[0])

@api.model
Expand Down

0 comments on commit f10e04e

Please sign in to comment.