# HG changeset patch # User Axel Prel <axel.prel@xcg-consulting.fr> # Date 1741707439 -3600 # Tue Mar 11 16:37:19 2025 +0100 # Branch 18.0 # Node ID a1e1e12a5fa33fb915395663db00c97ddb3fe694 # Parent e27b5297cef42eceb72b355b5f12bd2d39da1f33 # EXP-Topic RED-514 redner: new menu for template list and server config accessible with group conditionnality diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -5,6 +5,12 @@ 18.0.1.7.0 ---------- +Add a redner menu in "Apps" containing: +- the redner template management page (create, list, update, delete templates) +- a configuration wizard allowing quick server configuration (apikey, account, url) +The redner template management page is accessible if you are an admin or a redner user +The configuration page is accessible if you are an admin or a redner_admin + Res config: add redner integration parameters (server_url, account, api_key) Template locale is by default user locale, not fr_FR diff --git a/__manifest__.py b/__manifest__.py --- a/__manifest__.py +++ b/__manifest__.py @@ -29,8 +29,11 @@ # converter: https://orus.io/xcg/odoo-modules/converter "depends": ["converter", "mail", "web"], "data": [ + "security/groups.xml", + "security/ir.model.access.csv", "wizard/mail_compose_message_views.xml", "wizard/template_list_view.xml", + "wizard/redner_configurator_wizard.xml", "security/ir.model.access.csv", "views/redner_template.xml", "views/mail_template.xml", @@ -38,6 +41,9 @@ "views/res_config_settings_view.xml", "views/menu.xml", ], + "demo": [ + "demo/users.xml", + ], "assets": { "web.assets_backend": [ "redner/static/src/js/redner_report_action.esm.js", diff --git a/demo/users.xml b/demo/users.xml new file mode 100644 --- /dev/null +++ b/demo/users.xml @@ -0,0 +1,31 @@ +<odoo> + <data noupdate="1"> + <!-- Redner Admin User --> + <record id="redner_admin_demo" model="res.users"> + <field name="name">Redner Admin</field> + <field name="login">radmin</field> + <field name="email">redner_admin@example.com</field> + <field name="password">radmin</field> + <field name="company_id" ref="base.main_company" /> + <field name="company_ids" eval="[(6, 0, [ref('base.main_company')])]" /> + <field + name="groups_id" + eval="[(6, 0, [ref('redner.group_redner_admin')])]" + /> + </record> + + <!-- Redner User --> + <record id="redner_user_demo" model="res.users"> + <field name="name">Redner User</field> + <field name="login">ruser</field> + <field name="email">redner_user@example.com</field> + <field name="password">ruser</field> + <field name="company_id" ref="base.main_company" /> + <field name="company_ids" eval="[(6, 0, [ref('base.main_company')])]" /> + <field + name="groups_id" + eval="[(6, 0, [ref('redner.group_redner_user')])]" + /> + </record> + </data> +</odoo> diff --git a/security/groups.xml b/security/groups.xml new file mode 100644 --- /dev/null +++ b/security/groups.xml @@ -0,0 +1,23 @@ +<odoo> + <data noupdate="0"> + <!-- Category --> + <record id="module_category_redner" model="ir.module.category"> + <field name="name">Redner</field> + <field name="sequence">10</field> + </record> + + <!-- User Group --> + <record id="group_redner_user" model="res.groups"> + <field name="name">Redner User</field> + <field name="category_id" ref="module_category_redner" /> + <field name="implied_ids" eval="[(4, ref('base.group_user'))]" /> + </record> + + <!-- Admin Group --> + <record id="group_redner_admin" model="res.groups"> + <field name="name">Redner Administrator</field> + <field name="category_id" ref="module_category_redner" /> + <field name="implied_ids" eval="[(4, ref('base.group_user'))]" /> + </record> + </data> +</odoo> diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,5 +1,25 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_redner_report,access_redner_report,model_redner_report,base.group_no_one,1,1,1,1 -access_redner_template,access_redner_template,model_redner_template,base.group_no_one,1,1,1,1 -access_redner_substitution,access_redner_substitution,model_redner_substitution,base.group_no_one,1,1,1,1 -access_redner_template_list,access_redner_template_list,model_template_list_wizard,base.group_no_one,1,1,1,1 +access_redner_report_system,access_redner_report_system,model_redner_report,base.group_system,1,1,1,1 +access_redner_report_user,access_redner_report_user,model_redner_report,base.group_user,1,0,0,0 +access_redner_report_redner_user,access_redner_report_redner_user,model_redner_report,redner.group_redner_user,1,1,1,1 +access_redner_report_redner_admin,access_redner_report_redner_admin,model_redner_report,redner.group_redner_admin,1,0,0,0 + +access_redner_template_system,access_redner_template_system,model_redner_template,base.group_system,1,1,1,1 +access_redner_template_user,access_redner_template_user,model_redner_template,base.group_user,1,0,0,0 +access_redner_template_redner_user,access_redner_template_redner_user,model_redner_template,redner.group_redner_user,1,1,1,1 +access_redner_template_redner_admin,access_redner_template_redner_admin,model_redner_template,redner.group_redner_admin,1,0,0,0 + +access_redner_substitution_system,access_redner_substitution_system,model_redner_substitution,base.group_system,1,1,1,1 +access_redner_substitution_user,access_redner_substitution_user,model_redner_substitution,base.group_user,1,0,0,0 +access_redner_substitution_redner_user,access_redner_substitution_redner_user,model_redner_substitution,redner.group_redner_user,1,1,1,1 +access_redner_substitution_redner_admin,access_redner_substitution_redner_admin,model_redner_substitution,redner.group_redner_admin,1,0,0,0 + +access_redner_template_list_system,access_redner_template_list_system,model_template_list_wizard,base.group_system,1,1,1,1 +access_redner_template_list_user,access_redner_template_list_user,model_template_list_wizard,base.group_user,1,0,0,0 +access_redner_template_list_redner_user,access_redner_template_list_redner_user,model_template_list_wizard,redner.group_redner_user,1,1,1,1 +access_redner_template_list_redner_admin,access_redner_template_list_redner_admin,model_template_list_wizard,redner.group_redner_admin,1,0,0,0 + +access_redner_configurator_wizard_system,access_redner_configurator_wizard_system,model_redner_configurator_wizard,base.group_system,1,1,1,1 +access_redner_configurator_wizard_user,access_redner_configurator_wizard_user,model_redner_configurator_wizard,base.group_user,0,0,0,0 +access_redner_configurator_wizard_redner_user,access_redner_configurator_wizard_redner_user,model_redner_configurator_wizard,redner.group_redner_user,0,0,0,0 +access_redner_configurator_wizard_redner_admin,access_redner_configurator_wizard_redner_admin,model_redner_configurator_wizard,redner.group_redner_admin,1,1,1,1 diff --git a/views/menu.xml b/views/menu.xml --- a/views/menu.xml +++ b/views/menu.xml @@ -10,4 +10,32 @@ action="redner_template_action" sequence="8" /> + + <!-- Redner main menu item --> + <menuitem + id="redner_main_menu" + name="Redner" + parent="base.menu_management" + sequence="15" + groups="base.group_system,redner.group_redner_user,redner.group_redner_admin" + /> + <!-- Templates submenu --> + <menuitem + id="redner_template_main_menu" + name="Templates" + parent="redner_main_menu" + action="redner_template_action" + groups="base.group_system,redner.group_redner_user" + sequence="151" + /> + + <!-- Configuration submenu --> + <menuitem + id="redner_config_main_menu" + name="Configuration" + parent="redner_main_menu" + action="redner_config_action" + groups="base.group_system,redner.group_redner_admin" + sequence="152" + /> </odoo> diff --git a/wizard/__init__.py b/wizard/__init__.py --- a/wizard/__init__.py +++ b/wizard/__init__.py @@ -1,4 +1,5 @@ from . import ( mail_compose_message, + redner_configurator_wizard, template_list, ) diff --git a/wizard/redner_configurator_wizard.py b/wizard/redner_configurator_wizard.py new file mode 100644 --- /dev/null +++ b/wizard/redner_configurator_wizard.py @@ -0,0 +1,62 @@ +############################################################################## +# +# Redner Odoo module +# Copyright © 2016, 2023-2025 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from odoo import api, fields, models +from odoo.exceptions import AccessError + + +class RednerConfiguratorWizard(models.TransientModel): + _name = "redner.configurator.wizard" + _description = "Redner Configuration Wizard" + + server_url = fields.Char(string="Server URL") + account = fields.Char(string="Account") + api_key = fields.Char(string="API Key") + + @api.model + def default_get(self, fields_list): + """Load default values from ir.config_parameter""" + res = super().default_get(fields_list) + Param = self.env["ir.config_parameter"].sudo() + + res.update( + { + "server_url": Param.get_param("redner.server_url", default=""), + "account": Param.get_param("redner.account", default=""), + "api_key": Param.get_param("redner.api_key", default=""), + } + ) + return res + + def action_apply(self): + """Save values back to ir.config_parameter""" + if not self.env.user.has_group( + "redner.group_redner_admin" + ) and not self.env.user.has_group("base.group_system"): + raise AccessError( + "You do not have permission to modify Redner configuration." + ) + + Param = self.env["ir.config_parameter"].sudo() + Param.set_param("redner.server_url", self.server_url or "") + Param.set_param("redner.account", self.account or "") + Param.set_param("redner.api_key", self.api_key or "") + + return {"type": "ir.actions.act_window_close"} diff --git a/wizard/redner_configurator_wizard.xml b/wizard/redner_configurator_wizard.xml new file mode 100644 --- /dev/null +++ b/wizard/redner_configurator_wizard.xml @@ -0,0 +1,32 @@ +<odoo> + <record id="view_redner_configurator_wizard" model="ir.ui.view"> + <field name="name">redner.configurator.wizard.form</field> + <field name="model">redner.configurator.wizard</field> + <field name="arch" type="xml"> + <form string="Redner Configuration"> + <group> + <field name="server_url" /> + <field name="account" /> + <field name="api_key" /> + </group> + <footer> + <button + string="Apply" + type="object" + name="action_apply" + class="oe_highlight" + /> + <button string="Cancel" class="oe_link" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="redner_config_action" model="ir.actions.act_window"> + <field name="name">Redner Configuration</field> + <field name="res_model">redner.configurator.wizard</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_redner_configurator_wizard" /> + <field name="target">new</field> + </record> +</odoo> # HG changeset patch # User Axel Prel <axel.prel@xcg-consulting.fr> # Date 1741797223 -3600 # Wed Mar 12 17:33:43 2025 +0100 # Branch 18.0 # Node ID c3797452927ded2d4242abfff7d1a286e3e8d8da # Parent a1e1e12a5fa33fb915395663db00c97ddb3fe694 # EXP-Topic RED-514 simplify ir_model_access names diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,25 +1,25 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_redner_report_system,access_redner_report_system,model_redner_report,base.group_system,1,1,1,1 -access_redner_report_user,access_redner_report_user,model_redner_report,base.group_user,1,0,0,0 -access_redner_report_redner_user,access_redner_report_redner_user,model_redner_report,redner.group_redner_user,1,1,1,1 -access_redner_report_redner_admin,access_redner_report_redner_admin,model_redner_report,redner.group_redner_admin,1,0,0,0 +report_system,report_system,model_redner_report,base.group_system,1,1,1,1 +report_user,report_user,model_redner_report,base.group_user,1,0,0,0 +report_redner_user,report_redner_user,model_redner_report,redner.group_redner_user,1,1,1,1 +report_redner_admin,report_redner_admin,model_redner_report,redner.group_redner_admin,1,0,0,0 -access_redner_template_system,access_redner_template_system,model_redner_template,base.group_system,1,1,1,1 -access_redner_template_user,access_redner_template_user,model_redner_template,base.group_user,1,0,0,0 -access_redner_template_redner_user,access_redner_template_redner_user,model_redner_template,redner.group_redner_user,1,1,1,1 -access_redner_template_redner_admin,access_redner_template_redner_admin,model_redner_template,redner.group_redner_admin,1,0,0,0 +template_system,template_system,model_redner_template,base.group_system,1,1,1,1 +template_user,template_user,model_redner_template,base.group_user,1,0,0,0 +template_redner_user,template_redner_user,model_redner_template,redner.group_redner_user,1,1,1,1 +template_redner_admin,template_redner_admin,model_redner_template,redner.group_redner_admin,1,0,0,0 -access_redner_substitution_system,access_redner_substitution_system,model_redner_substitution,base.group_system,1,1,1,1 -access_redner_substitution_user,access_redner_substitution_user,model_redner_substitution,base.group_user,1,0,0,0 -access_redner_substitution_redner_user,access_redner_substitution_redner_user,model_redner_substitution,redner.group_redner_user,1,1,1,1 -access_redner_substitution_redner_admin,access_redner_substitution_redner_admin,model_redner_substitution,redner.group_redner_admin,1,0,0,0 +substitution_system,substitution_system,model_redner_substitution,base.group_system,1,1,1,1 +substitution_user,substitution_user,model_redner_substitution,base.group_user,1,0,0,0 +substitution_redner_user,substitution_redner_user,model_redner_substitution,redner.group_redner_user,1,1,1,1 +substitution_redner_admin,substitution_redner_admin,model_redner_substitution,redner.group_redner_admin,1,0,0,0 -access_redner_template_list_system,access_redner_template_list_system,model_template_list_wizard,base.group_system,1,1,1,1 -access_redner_template_list_user,access_redner_template_list_user,model_template_list_wizard,base.group_user,1,0,0,0 -access_redner_template_list_redner_user,access_redner_template_list_redner_user,model_template_list_wizard,redner.group_redner_user,1,1,1,1 -access_redner_template_list_redner_admin,access_redner_template_list_redner_admin,model_template_list_wizard,redner.group_redner_admin,1,0,0,0 +template_list_system,template_list_system,model_template_list_wizard,base.group_system,1,1,1,1 +template_list_user,template_list_user,model_template_list_wizard,base.group_user,1,0,0,0 +template_list_redner_user,template_list_redner_user,model_template_list_wizard,redner.group_redner_user,1,1,1,1 +template_list_redner_admin,template_list_redner_admin,model_template_list_wizard,redner.group_redner_admin,1,0,0,0 -access_redner_configurator_wizard_system,access_redner_configurator_wizard_system,model_redner_configurator_wizard,base.group_system,1,1,1,1 -access_redner_configurator_wizard_user,access_redner_configurator_wizard_user,model_redner_configurator_wizard,base.group_user,0,0,0,0 -access_redner_configurator_wizard_redner_user,access_redner_configurator_wizard_redner_user,model_redner_configurator_wizard,redner.group_redner_user,0,0,0,0 -access_redner_configurator_wizard_redner_admin,access_redner_configurator_wizard_redner_admin,model_redner_configurator_wizard,redner.group_redner_admin,1,1,1,1 +configurator_system,configurator_system,model_redner_configurator_wizard,base.group_system,1,1,1,1 +configurator_user,configurator_user,model_redner_configurator_wizard,base.group_user,0,0,0,0 +configurator_redner_user,configurator_redner_user,model_redner_configurator_wizard,redner.group_redner_user,0,0,0,0 +configurator_redner_admin,configurator_redner_admin,model_redner_configurator_wizard,redner.group_redner_admin,1,1,1,1