[FIX] website: edit website.page's menu URL not saving

Before this commit, editing a website.menu (linked to a website.page (m2o))
would not save the URL on the website.page record but only on the
website.menu.
But since the URL retrieved to display the website navbar is:
  1. The website.page url if the menu has a page_id
  2. The website.menu url otherwise
It would never get the edited URL stored on website.menu
This commit is contained in:
Romain Derie
2017-12-12 17:50:41 +01:00
parent 294dc70a38
commit 9d2d9a3528
+4 -1
View File
@@ -866,11 +866,14 @@ class Menu(models.Model):
new_menu = self.create({'name': menu['name']})
replace_id(mid, new_menu.id)
for menu in data['data']:
menu_id = self.browse(menu['id'])
if menu_id.page_id:
menu_id.page_id.write({'url': menu['url']})
# if the url match a website.page, set the m2o relation
page = self.env['website.page'].search([('url', '=', menu['url'])], limit=1)
if page:
menu['page_id'] = page.id
self.browse(menu['id']).write(menu)
menu_id.write(menu)
return True