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