[FIX] im_livechat: fix traceback when clicking on create button

Before this commit:

When trying to create a record in the live chat it shows traceback.
because the record.id is an object but it requires an integer value.

After this commit:

No traceback while clicking on the create button.

Explanation:

Following commit 488e334fc8
`onchange` methods must handle being called on new record.

Task-2347091
opw-2350463

closes odoo/odoo#59462

X-original-commit: 96d0627a966bfa0e71e5350277d306c0e08cc131
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Kamesh Patel
2020-10-08 08:12:40 +00:00
committed by Sébastien Theys
parent 5a594fd8a7
commit 721c9f7d90
@@ -65,12 +65,12 @@ class ImLivechatChannel(models.Model):
}
for record in self:
values["channel_id"] = record.id
record.script_external = view._render(values)
record.script_external = view._render(values) if record.id else False
def _compute_web_page_link(self):
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
for record in self:
record.web_page = "%s/im_livechat/support/%i" % (base_url, record.id)
record.web_page = "%s/im_livechat/support/%i" % (base_url, record.id) if record.id else False
@api.depends('channel_ids')
def _compute_nbr_channel(self):