Add module pos_config_single_user

Several usability enhancements in sale, purchase, product and account
This commit is contained in:
Alexis de Lattre
2016-12-09 08:35:00 +01:00
parent 9aa4613dd7
commit c268e28b3d
5 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (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
class PosConfig(models.Model):
_inherit = 'pos.config'
allowed_user_id = fields.Many2one(
'res.users', string="Allowed User",
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):
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()