From 7ed73b6d62abeda6b4e64739615d82707b358a96 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 22 Jun 2016 12:24:43 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=C2=A0point=5Fof=5Fsale:=20creation=20of?= =?UTF-8?q?=20a=20pos=20session=20as=20a=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an pos session is created, a bank statement is created and it must be linked to the pos session. A pos user doesn't have the rights to write and read on a bank statement. This is why the creation of the pos session and the creation of bank statement have to be done as super user. opw:678970 --- addons/point_of_sale/point_of_sale.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 16f3e17a88a..1d785ea7c08 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -502,6 +502,7 @@ class pos_session(osv.osv): jobj = self.pool.get('pos.config') pos_config = jobj.browse(cr, uid, config_id, context=context) context.update({'company_id': pos_config.company_id.id}) + is_pos_user = self.pool['res.users'].has_group(cr, uid, 'point_of_sale.group_pos_user') if not pos_config.journal_id: jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id'] if jid: @@ -522,7 +523,7 @@ class pos_session(osv.osv): jobj.write(cr, SUPERUSER_ID, [pos_config.id], {'journal_ids': [(6,0, cashids)]}) statements = [] - create_statement = partial(self.pool['account.bank.statement'].create, cr, uid) + create_statement = partial(self.pool['account.bank.statement'].create, cr, is_pos_user and SUPERUSER_ID or uid) for journal in pos_config.journal_ids: # set the journal_id which should be used by # account.bank.statement to set the opening balance of the @@ -540,7 +541,7 @@ class pos_session(osv.osv): 'config_id': config_id }) - return super(pos_session, self).create(cr, uid, values, context=context) + return super(pos_session, self).create(cr, is_pos_user and SUPERUSER_ID or uid, values, context=context) def unlink(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context):