The website_theme_install needs to reference the module category whose
xml_id is base.module_category_theme_hidden. The problem was that it
needs to do this in a context where the category might not exist (as
auto-created only if a module defines its category as "Theme/Hidden").
To solve the problem, the category was explicitly created by the
website_theme_install module to be able to reference it.
Commit 11812b0b9e removed the "base." part
of the xml_id thinking it was a record which had to be created by the
module. This then wrongly showed the Theme/Hidden modules in the list.
Now the solution came from commit https://github.com/odoo/odoo/commit/c6983137#diff-07193f47475ccdd78f39773a368ce05bL386
which now allows to use the second parameter of ref in a domain
context. This allows to tell the system to not raise an exception if
the ref we want to find does not exist.
80 lines
4.3 KiB
XML
80 lines
4.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<!-- Custom module kanban : install button (even if already installed) which redirects to website after (fake or not) installation + live preview button -->
|
|
<record model="ir.ui.view" id="theme_view_kanban">
|
|
<field name="name">Themes Kanban</field>
|
|
<field name="model">ir.module.module</field>
|
|
<field name="arch" type="xml">
|
|
<kanban create="false" class="o_theme_kanban" default_order="sequence,name">
|
|
<field name="icon"/>
|
|
<field name="name"/>
|
|
<field name="state"/>
|
|
<field name="url"/>
|
|
<field name="image_ids"/>
|
|
<templates>
|
|
<div t-name="kanban-box">
|
|
<t t-set="has_screenshot" t-value="record.image_ids.raw_value.length > 0"/>
|
|
<div t-if="has_screenshot" class="o_screenshot" t-attf-style="background-image: url(web/image/#{record.image_ids.raw_value[0]});"/>
|
|
<div t-if="!has_screenshot" t-attf-style="background-image: url(#{record.icon.value});"/>
|
|
<div class="o_button_area">
|
|
<button type="object" name="button_choose_theme" states="uninstalled" class="btn btn-primary btn-sm">Install</button>
|
|
<button type="action" name="website.action_website" states="installed" class="btn btn-primary btn-sm">Install</button>
|
|
<a t-if="record.url.value" class="btn btn-sm btn-primary" t-att-href="record.url.value" target="_blank">Live Preview</a>
|
|
</div>
|
|
</div>
|
|
</templates>
|
|
</kanban>
|
|
</field>
|
|
</record>
|
|
<record model="ir.ui.view" id="theme_view_search">
|
|
<field name="name">Themes Search</field>
|
|
<field name="model">ir.module.module</field>
|
|
<field name="priority">50</field>
|
|
<field name="arch" type="xml">
|
|
<search>
|
|
<field name="name" filter_domain="['|', '|', ('summary', 'ilike', self), ('shortdesc', 'ilike', self), ('name', 'ilike', self)]" string="Theme"/>
|
|
<group>
|
|
<filter string="Author" domain="[]" context="{'group_by':'author'}"/>
|
|
<filter string="Category" domain="[]" context="{'group_by':'category_id'}"/>
|
|
</group>
|
|
</search>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Actions to list themes with custom kanban (launched on module installation) -->
|
|
<record id="theme_install_kanban_action" model="ir.actions.act_window">
|
|
<field name="name">Choose Your Theme</field>
|
|
<field name="res_model">ir.module.module</field>
|
|
<field name="view_mode">kanban</field>
|
|
<field name="view_id" ref="theme_view_kanban"/>
|
|
<field name="search_view_id" ref="theme_view_search"/>
|
|
<field name="domain" eval="[
|
|
'|', ('category_id', 'not in', [ref('base.module_category_hidden', False), ref('base.module_category_theme_hidden', False)]), ('name', '=', 'theme_default'),
|
|
'|', ('category_id', '=', ref('base.module_category_theme', False)), ('category_id.parent_id', '=', ref('base.module_category_theme', False))
|
|
]"/>
|
|
</record>
|
|
<record id="theme_install_todo_action" model="ir.actions.server">
|
|
<field name="name">Choose Your Theme Todo Action</field>
|
|
<field name="model_id" ref="model_ir_module_module"/>
|
|
<field name="code">
|
|
model.update_list()
|
|
action = {
|
|
'type': 'ir.actions.act_url',
|
|
'url': '/web?reload#action=website_theme_install.theme_install_kanban_action', # the ?reload option is there to fool the webclient into thinking it is a different location and so to force a reload
|
|
'target': 'self',
|
|
}
|
|
</field>
|
|
</record>
|
|
<record id="theme_install_todo" model="ir.actions.todo">
|
|
<field name="action_id" ref="theme_install_todo_action"/>
|
|
<field name="type">automatic</field>
|
|
</record>
|
|
|
|
<!-- Add link to theme install in default customize modal -->
|
|
<template id="customize_modal" inherit_id="website.theme_customize" priority="1">
|
|
<xpath expr="//div[hasclass('modal-header')]" position="inside">
|
|
<a href="/web#action=website_theme_install.theme_install_kanban_action">See themes here</a>
|
|
</xpath>
|
|
</template>
|
|
</odoo>
|