From a80fa972fdfa150b83207d66ee0a01a49d49ee15 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Fri, 26 Jan 2024 10:09:47 +0000 Subject: [PATCH] [FIX] point_of_sale: correct pos config view Correct/improve the view of the point of sale configuration by hiding certain unnecessary parts for certain user groups. closes odoo/odoo#154359 X-original-commit: 1a2009387756f5bf41ed3c7a3ec3a892a1e4336a Signed-off-by: Denis Ledoux (dle) Signed-off-by: Thomas Lefebvre (thle) --- addons/point_of_sale/i18n/point_of_sale.pot | 6 ++++++ addons/point_of_sale/models/pos_config.py | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index 65e0414bc51..e3dd330e2f9 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -3972,6 +3972,12 @@ msgid "" "modify the quantity to be refunded." msgstr "" +#. module: point_of_sale +#: code:addons/point_of_sale/models/pos_config.py:0 +#, python-format +msgid "Only administrators can edit receipt headers and footers" +msgstr "" + #. module: point_of_sale #: model:ir.model.fields,field_description:point_of_sale.field_pos_config__only_round_cash_method #: model:ir.model.fields,field_description:point_of_sale.field_res_config_settings__pos_only_round_cash_method diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 69d67883352..38472c3b7d1 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -7,7 +7,7 @@ import pytz from odoo import api, fields, models, _, Command from odoo.osv.expression import OR, AND -from odoo.exceptions import ValidationError, UserError +from odoo.exceptions import AccessError, ValidationError, UserError class PosConfig(models.Model): @@ -368,9 +368,14 @@ class PosConfig(models.Model): else: config.display_name = f"{config.name} ({last_session.user_id.name})" + def _check_header_footer(self, values): + if not self.env.is_admin() and {'is_header_or_footer', 'receipt_header', 'receipt_footer'} & values.keys(): + raise AccessError(_('Only administrators can edit receipt headers and footers')) + @api.model_create_multi def create(self, vals_list): for vals in vals_list: + self._check_header_footer(vals) IrSequence = self.env['ir.sequence'].sudo() val = { 'name': _('POS Order %s', vals['name']), @@ -405,6 +410,7 @@ class PosConfig(models.Model): prepa_printers_menuitem.active = self.sudo().env['pos.config'].search_count([('is_order_printer', '=', True)], limit=1) > 0 def write(self, vals): + self._check_header_footer(vals) self._reset_default_on_vals(vals) if ('is_order_printer' in vals and not vals['is_order_printer']): vals['printer_ids'] = [fields.Command.clear()]