Files
odoo_source/addons/lunch/views/res_config_settings.xml
T
Victor Feyens fba6ea5a47 [IMP] *: do not force admins to be app admins
For bugfix purposes, app administration groups have been given to
(implied by) the "Settings" group because without those rights,
opening/saving the settings crashed.

1) Do not load hidden view content

This commit uses the conditional inheritance of views
(depending on user groups) to avoid loading unnecessary view
& record content client-side.

This improves performance for admins without the specific application
admin rights, but also fixes the main bugfix problem,
caused by the webclient querying name_get for the records in relational
fields content.

Example:

sale_management adds a res.config.settings field to specify
the default sale.order.template for the current company.

If a 'Settings' user without 'sale.group_sale_manager' opens the
settings, he won't see this setting, but if a default template is
specified for the current company, the webclient will still request
the name_get of this template to the server, because the field
was present in the view, only hidden with a groups attribute.

With this commit change in sale, the field won't be in the view unless
you have the Sale manager group, avoiding the error/traceback/bug.

2) Remove implied application administration groups

Do not force the specific application groups on all 'Settings' user,
they globally do not need those rights, and if they need it, they
can add it to their account themselves.

3) Add a test to make sure settings user are able to manage settings.

4) Enforce 'settings' -> 'access rights' -> 'internal user' groups

As the previous test highlighted some 'false positives' because
it considered a settings user unable to read `crm.team`
and `stock.warehouse` records, we also took the opportunity to enforce
the fact that 'Settings' & 'Access rights' users must be internal users.

It makes no sense for a portal/public user to have access to the
settings, and didn't work anyway.

Part-of: odoo/odoo#91909
2022-06-23 23:48:29 +02:00

63 lines
3.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.lunch</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="90"/>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="groups_id" eval="[(4, ref('lunch.group_lunch_manager'), 0)]"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div class="app_settings_block" data-string="Lunch" string="Lunch" data-key="lunch" groups="lunch.group_lunch_manager">
<field name="currency_id" invisible="1"/>
<h2>Lunch</h2>
<div class="row mt16 o_settings_container" name="lunch_overdraft_setting_container">
<div class="col-12 col-lg-6 o_setting_box" id="lunch_minimum_threshold"
title="None">
<div class="o_setting_right_pane">
<span class="o_form_label">Lunch Overdraft</span>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-muted">
Maximum overdraft that your employees can reach
</div>
<div class="content-group">
<div class="mt16 row">
<label for="company_lunch_minimum_threshold" string="Overdraft" class="col-3 col-lg-3 o_light_label"/>
<field name="company_lunch_minimum_threshold" widget="monetary"/>
</div>
</div>
</div>
</div>
</div>
<div class="row mt16 o_settings_container" name="lunch_notification_setting_container">
<div class="col-12 col-lg-6 o_setting_box" id="lunch_notification">
<div class="o_setting_right_pane">
<span class="o_form_label">Reception notification</span>
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." aria-label="Values set here are company-specific." groups="base.group_multi_company" role="img"/>
<div class="text-mutex">
Send this message to your users when their order has been delivered.
</div>
<div class="content-group">
<div class="mt16 row">
<field name="company_lunch_notify_message" widget="html" class="col col-lg w-100"/>
</div>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
<record id="lunch_config_settings_action" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.config.settings</field>
<field name="view_id" ref="res_config_settings_view_form"/>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field name="context">{'module' : 'lunch', 'bin_size': False}</field>
</record>
</odoo>