[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) <dle@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
This commit is contained in:
Thomas Lefebvre (thle)
2024-02-16 13:51:55 +00:00
parent f6212e4554
commit a80fa972fd
2 changed files with 13 additions and 1 deletions
@@ -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
+7 -1
View File
@@ -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()]