[MIG] pos_config_single_user
This commit is contained in:
@@ -1,3 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import pos
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2014-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'POS Config Single User',
|
||||
'version': '10.0.1.0.0',
|
||||
'version': '14.0.1.0.0',
|
||||
'category': 'Point Of Sale',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Configure on each pos.config a single user allowed to start it',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2014-2020 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from openerp.exceptions import UserError
|
||||
from odoo import fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class PosConfig(models.Model):
|
||||
@@ -14,14 +14,13 @@ class PosConfig(models.Model):
|
||||
help="If you select a user, only this user will be allowed to start "
|
||||
"sessions for this POS", ondelete='restrict')
|
||||
|
||||
@api.multi
|
||||
def open_session_cb(self):
|
||||
def open_session_cb(self, check_coa=True):
|
||||
self.ensure_one()
|
||||
if (
|
||||
self.allowed_user_id and
|
||||
self.allowed_user_id != self.env.user):
|
||||
raise UserError(_(
|
||||
"The POS '%s' can be used only by user '%s'.") % (
|
||||
self.name,
|
||||
self.allowed_user_id.name))
|
||||
return super(PosConfig, self).open_session_cb()
|
||||
self.display_name,
|
||||
self.allowed_user_id.display_name))
|
||||
return super().open_session_cb(check_coa=check_coa)
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
Copyright 2016-2020 Akretion France (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="view_pos_config_form" model="ir.ui.view">
|
||||
<record id="pos_config_view_form" model="ir.ui.view">
|
||||
<field name="name">pos_config_single_user.pos.config</field>
|
||||
<field name="model">pos.config</field>
|
||||
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
|
||||
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="sequence_id" position="after">
|
||||
<field name="allowed_user_id"/>
|
||||
</field>
|
||||
<xpath expr="//field[@name='start_category']/../.." position="after">
|
||||
<div class="col-12 col-lg-6 o_setting_box" id="allowed_user">
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="allowed_user_id"/>
|
||||
<div class="text-muted">
|
||||
If set, only this user will be able to start a session
|
||||
</div>
|
||||
<div class="content-group mt16">
|
||||
<field name="allowed_user_id" options="{'no_create': True}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user