[ADD] website_menus form view & set default website in newly created menus

This commit is contained in:
Siddharth Bhalgami 2018-01-11 16:42:55 +05:30
parent fe79fe27e6
commit c4ea35d938
2 changed files with 25 additions and 3 deletions

View File

@ -904,8 +904,9 @@ class Menu(models.Model):
page_id = fields.Many2one('website.page', 'Related Page') page_id = fields.Many2one('website.page', 'Related Page')
new_window = fields.Boolean('New Window') new_window = fields.Boolean('New Window')
sequence = fields.Integer(default=_default_sequence) sequence = fields.Integer(default=_default_sequence)
website_id = fields.Many2one('website', 'Website') # TODO: support multiwebsite once done for ir.ui.views website_id = fields.Many2one('website', 'Website', required=True,
parent_id = fields.Many2one('website.menu', 'Parent Menu', index=True, ondelete="cascade") default=lambda self: self.env.ref('website.default_website')) # TODO: support multiwebsite once done for ir.ui.views
parent_id = fields.Many2one('website.menu', 'Parent Menu', index=True, ondelete="cascade", domain="[('website_id','=', website_id)]")
child_id = fields.One2many('website.menu', 'parent_id', string='Child Menus') child_id = fields.One2many('website.menu', 'parent_id', string='Child Menus')
parent_left = fields.Integer('Parent Left', index=True) parent_left = fields.Integer('Parent Left', index=True)
parent_right = fields.Integer('Parent Rigth', index=True) parent_right = fields.Integer('Parent Rigth', index=True)

View File

@ -169,10 +169,31 @@
<record id="action_website_menu" model="ir.actions.act_window"> <record id="action_website_menu" model="ir.actions.act_window">
<field name="name">Website Menu</field> <field name="name">Website Menu</field>
<field name="res_model">website.menu</field> <field name="res_model">website.menu</field>
<field name="view_mode">list</field> <field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_my_websites':1}</field> <field name="context">{'search_default_my_websites':1}</field>
</record> </record>
<record id="menu_from" model="ir.ui.view">
<field name="name">website.menu.form</field>
<field name="model">website.menu</field>
<field name="arch" type="xml">
<form string="Website menu">
<sheet>
<group>
<field name="name"/>
<field name="url"/>
</group>
<group>
<field name="website_id" options="{'no_create': True}"/>
<field name="new_window"/>
<field name="parent_id"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="menu_tree" model="ir.ui.view"> <record id="menu_tree" model="ir.ui.view">
<field name="name">website.menu.tree</field> <field name="name">website.menu.tree</field>
<field name="model">website.menu</field> <field name="model">website.menu</field>