Files
odoo_source/addons/website/views/website_controller_pages_views.xml
T
198e226f5b [IMP] website: Expose models on the website
This commit implements a way to expose any model publicly on the website. Both manual and
existing models can create such pages called 'Model Pages'.
A manual model is a model that has been created by the user at runtime, via the technical menu,
via studio, or with an xml declaration.

The main interface to easily create such page is in Studio, in the tab Website Integration. But a
partner or developer could easily import those without studio installed. That's the reason most of
the code to handle the display of such pages is present in the website module directly.

The listing can handle two display modes (Grid or List). Once the user changes the display mode,
the latest value is set in the session to be remembered for the next visit of the page.
A default_layout can be set and is customizable in the website editor or from the backend of Website.
This value is linked to the page to display, so each listing page can use a different layout by default.

The route on which the models are exposed is:
"/model/<string:page_name_slugified>",

With the derived routes:
"/model/<string:page_name_slugified>/page/<int:page_number>",
"/model/<string:page_name_slugified>/<string:record_slug>"

task-id-3231144

Part-of: odoo/odoo#130544
Co-authored-by: Florent Dardenne (dafl) <dafl@odoo.com>
Co-authored-by: Luca Vitali (luvi) <luvi@odoo.com>
2023-10-26 12:10:08 +00:00

84 lines
3.6 KiB
XML

<?xml version="1.0"?>
<odoo>
<record id="website_controller_pages_form_view" model="ir.ui.view">
<field name="name">website.controller.page.form</field>
<field name="model">website.controller.page</field>
<field name="arch" type="xml">
<form string="Website Model Page Settings">
<sheet>
<group col="2" string="Page Details">
<group colspan="1" string="Page">
<field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/>
<field name="page_name"/>
<label for="name_slugified" string="URL"/>
<div>
<span>/model/</span>
<field name="name_slugified" nolabel="1" class="d-inline bg-300" force_save="True"/>
<span invisible="name_slugified" class="bg-300">...</span>
<span invisible="page_type == 'listing'">
/my-little-record-23
</span>
</div>
<field name="website_published" />
</group>
<group colspan="1" string="Settings">
<field name="model" invisible="1"/>
<field name="record_domain" widget="domain" options="{'in_dialog': True, 'model': 'model'}"/>
<field name="page_type" required="1"/>
<field name="default_layout" invisible="page_type != 'listing'" />
</group>
</group>
<notebook groups="base.group_no_one">
<page string="View">
<group>
<field name="view_id" context="{'display_website': True}"/>
<field name="name"/>
</group>
</page>
<page string="Menus">
<label for="menu_ids" string="Related Menu Items"/>
<field name="menu_ids"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="website_controller_pages_tree_view" model="ir.ui.view">
<field name="name">website.controller.page.list</field>
<field name="model">website.controller.page</field>
<field name="priority">99</field>
<field name="arch" type="xml">
<tree>
<field name="name" string="Page Title"/>
<field name="name_slugified"/>
<field name="page_type"/>
<field name="view_id" column_invisible="True"/>
<!-- website_id should be shown only in multi website environment
when the group is enabled, but we need the field to be there all the
time for `PageRendererMixin`'s `recordFilter' to be able to filter
correctly. -->
<field name="website_id" column_invisible="True"/>
<field name="website_id" groups="website.group_multi_website"/>
</tree>
</field>
</record>
<record id="action_website_controller_pages_list" model="ir.actions.act_window">
<field name="name">Website Model Pages</field>
<field name="res_model">website.controller.page</field>
<field name="view_mode">tree,kanban,form</field>
</record>
<menuitem id="menu_website_controller_pages_list"
parent="menu_content"
sequence="10"
name="Model Pages"
groups="base.group_no_one"
action="action_website_controller_pages_list" />
</odoo>