[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.
This commit is contained in:
Romain Derie
2018-09-20 13:49:31 +02:00
parent 4558ca95cd
commit 93b2a55b5d
+7 -11
View File
@@ -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