[IMP] website: button to easily back to page manager from form view
Before this commit: When you were on the page manager and you were editing a website.page's content, it would redirect you to the website.page's ir.ui.view's form view in the backend. From there, you would'nt have an easy way to get back to the page manager: your only option was to go to the website module and click on 'go to website' and then click on menu/manage pages. It was not convenient when you were editing multiple page quickly or just taking a look into some pages. Now, you have a button on the ir.ui.view's form view to get directly on the page manager. Note: this back button is obviously invisible for ir.ui.view not related to a website.page
This commit is contained in:
@@ -20,6 +20,13 @@ class View(models.Model):
|
||||
|
||||
customize_show = fields.Boolean("Show As Optional Inherit", default=False)
|
||||
website_id = fields.Many2one('website', ondelete='cascade', string="Website")
|
||||
page_ids = fields.One2many('website.page', compute='_compute_page_ids', store=False)
|
||||
|
||||
@api.one
|
||||
def _compute_page_ids(self):
|
||||
self.page_ids = self.env['website.page'].search(
|
||||
[('view_id', '=', self.id)]
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
@@ -142,3 +149,11 @@ class View(models.Model):
|
||||
return lang_code
|
||||
else:
|
||||
return super(View, self).get_default_lang_code()
|
||||
|
||||
@api.multi
|
||||
def redirect_to_page_manager(self):
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/website/pages',
|
||||
'target': 'self',
|
||||
}
|
||||
|
||||
@@ -209,12 +209,17 @@
|
||||
|
||||
<field name="inherit_id" ref="base.view_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<field name="name" position="after">
|
||||
<field name="website_id" readonly="1"/>
|
||||
<field name="key" readonly="1"/>
|
||||
<field name="page_ids" invisible="1" />
|
||||
</field>
|
||||
|
||||
<sheet position="before">
|
||||
<header>
|
||||
<button name="redirect_to_page_manager" string="Go to Page Manager"
|
||||
type="object" attrs="{'invisible': [('page_ids', '=', [])]}"/>
|
||||
</header>
|
||||
</sheet>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user