From 93b2a55b5d70a1d247f6133112bc7fac1e44aed1 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 19 Sep 2018 11:51:23 +0200 Subject: [PATCH] [FIX] website: avoid translation issue with copy on inherited record Since Odoo saas-11.3, copying a record with it's inherited record in the copy dict values will trigger translation of the inherited record's fields which it shouldn't. This issue will be fixed with #27108 In the meantime, we can avoid this issue by not copying the view separately from the page as this code is a residue from the old implementation (no inheritS between `website.page` and `ir.ui.view` + they both had `name` field) and is not usefull anymore. --- addons/website/models/website.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 006d2c353a1..c80fd11e97c 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -729,17 +729,13 @@ class Page(models.Model): @api.multi @api.returns('self', lambda value: value.id) def copy(self, default=None): - view = self.env['ir.ui.view'].browse(self.view_id.id) - # website.page's ir.ui.view should have a different key than the one it - # is copied from. - # (eg: website_version: an ir.ui.view record with the same key is - # expected to be the same ir.ui.view but from another version) - new_view = view.copy({'key': view.key + '.copy', 'name': '%s %s' % (view.name, _('(copy)'))}) - default = { - 'name': '%s %s' % (self.name, _('(copy)')), - 'url': self.env['website'].get_unique_path(self.url), - 'view_id': new_view.id, - } + # website.page's ir.ui.view should have a different key than the one + # it is copied from (website_version, multi-website..) + default = dict(default or {}) + default.update( + name='%s %s' % (self.name, _('(copy)')), + url=self.env['website'].get_unique_path(self.url), + key=self.key + '.copy') return super(Page, self).copy(default=default) @api.model