From a177cb568db18ec1813f720156152e798c0bdabd Mon Sep 17 00:00:00 2001 From: KolushovAlexandr Date: Thu, 31 Oct 2019 14:28:39 +0500 Subject: [PATCH 1/9] :ambulance: access error for poses created for different companies --- pos_multi_session/__manifest__.py | 2 +- pos_multi_session/doc/changelog.rst | 5 ++++ .../views/pos_multi_session_views.xml | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pos_multi_session/__manifest__.py b/pos_multi_session/__manifest__.py index 8676ef45ba..8727583fa6 100644 --- a/pos_multi_session/__manifest__.py +++ b/pos_multi_session/__manifest__.py @@ -9,7 +9,7 @@ "category": "Point Of Sale", # "live_test_url": 'http://apps.it-projects.info/shop/product/pos-multi-session?version=11.0', "images": ["images/pos-multi-session.png"], - "version": "11.0.4.2.10", + "version": "11.0.4.2.11", "application": False, "author": "IT-Projects LLC, Ivan Yelizariev", diff --git a/pos_multi_session/doc/changelog.rst b/pos_multi_session/doc/changelog.rst index 9e1e6e53b5..5cd782cd96 100644 --- a/pos_multi_session/doc/changelog.rst +++ b/pos_multi_session/doc/changelog.rst @@ -1,3 +1,8 @@ +`4.2.11` +-------- + +- **Fix:** Access error for poses created for different companies + `4.2.10` -------- diff --git a/pos_multi_session/views/pos_multi_session_views.xml b/pos_multi_session/views/pos_multi_session_views.xml index 16f1df3656..70f9e4a071 100644 --- a/pos_multi_session/views/pos_multi_session_views.xml +++ b/pos_multi_session/views/pos_multi_session_views.xml @@ -88,6 +88,29 @@ + +

Accounting

+
+
+
+
+
+
+
From 7014006495a1273536b0f0e5340182ac384b64a7 Mon Sep 17 00:00:00 2001 From: diga Date: Wed, 10 Apr 2019 18:21:47 +0500 Subject: [PATCH 2/9] :ambulance: Error during installation in multi-company mode --- .../data/pos_multi_session_data.xml | 15 ++----- pos_multi_session/demo/demo.xml | 4 +- pos_multi_session/doc/changelog.rst | 1 + .../models/pos_multi_session_models.py | 41 ++++++++++++++----- .../views/pos_multi_session_views.xml | 2 +- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/pos_multi_session/data/pos_multi_session_data.xml b/pos_multi_session/data/pos_multi_session_data.xml index 6eb62f7085..4479e1c284 100644 --- a/pos_multi_session/data/pos_multi_session_data.xml +++ b/pos_multi_session/data/pos_multi_session_data.xml @@ -1,19 +1,10 @@ - - - Default Multi Session - False - - - - - - - - + + diff --git a/pos_multi_session/demo/demo.xml b/pos_multi_session/demo/demo.xml index 3dbb931b6b..c112f93fd0 100644 --- a/pos_multi_session/demo/demo.xml +++ b/pos_multi_session/demo/demo.xml @@ -1,6 +1,6 @@ @@ -26,7 +26,6 @@ Demo User2 - demo2@yourcompany.example.com Avenue des Dessus-de-Lives2, 2 @@ -38,7 +37,6 @@ demo2 demo2 --Mr Demo2 - 0410100000013 diff --git a/pos_multi_session/doc/changelog.rst b/pos_multi_session/doc/changelog.rst index 5cd782cd96..b451a4a0f9 100644 --- a/pos_multi_session/doc/changelog.rst +++ b/pos_multi_session/doc/changelog.rst @@ -2,6 +2,7 @@ -------- - **Fix:** Access error for poses created for different companies +- **Fix:** Error during installation in multi-company mode `4.2.10` -------- diff --git a/pos_multi_session/models/pos_multi_session_models.py b/pos_multi_session/models/pos_multi_session_models.py index eca87fa79e..3c587c1330 100644 --- a/pos_multi_session/models/pos_multi_session_models.py +++ b/pos_multi_session/models/pos_multi_session_models.py @@ -1,7 +1,7 @@ # Copyright 2015-2016 Ivan Yelizariev # Copyright 2016 Ilyas Rakhimkulov # Copyright 2017 Kolushov Alexandr -# Copyright 2016-2018 Dinar Gabbasov +# Copyright 2016-2019 Dinar Gabbasov # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). import logging @@ -18,8 +18,7 @@ class PosConfig(models.Model): multi_session_id = fields.Many2one('pos.multi_session', 'Multi-session', help='Set the same value for POSes where orders should be synced.' 'Uncheck the box "Active" if the POS should not use syncing.' - 'Before updating you need to close active session', - default=lambda self: self.env.ref('pos_multi_session.default_multi_session', raise_if_not_found=False)) + 'Before updating you need to close active session') multi_session_accept_incoming_orders = fields.Boolean('Accept incoming orders', default=True) multi_session_replace_empty_order = fields.Boolean('Replace empty order', default=True, help='Empty order is deleted whenever new order is come from another POS') multi_session_deactivate_empty_order = fields.Boolean('Deactivate empty order', default=False, help='POS is switched to new foreign Order, if current order is empty') @@ -27,7 +26,8 @@ class PosConfig(models.Model): sync_server = fields.Char(related='multi_session_id.sync_server') autostart_longpolling = fields.Boolean(default=False) fiscal_position_ids = fields.Many2many(related='multi_session_id.fiscal_position_ids') - company_id = fields.Many2one(related='multi_session_id.company_id') + company_id = fields.Many2one(related='multi_session_id.company_id', store=True, default=lambda self: self.env.user.company_id) + stock_location_id = fields.Many2one(related='multi_session_id.stock_location_id', store=True) def _search_current_session_state(self, operator, value): ids = map(lambda x: x.id, self.env["pos.config"].search([])) @@ -45,6 +45,9 @@ def _search_current_session_state(self, operator, value): class PosMultiSession(models.Model): _name = 'pos.multi_session' + def _get_default_location(self): + return self.env['stock.warehouse'].search([('company_id', '=', self.env.user.company_id.id)], limit=1).lot_stock_id + name = fields.Char('Name') multi_session_active = fields.Boolean(string="Active", help="Select the checkbox to enable synchronization for POSes", default=True) pos_ids = fields.One2many('pos.config', 'multi_session_id', string='POSes in Multi-session') @@ -56,18 +59,34 @@ class PosMultiSession(models.Model): "It's used to prevent synchronization of old orders") fiscal_position_ids = fields.Many2many('account.fiscal.position', string='Fiscal Positions', ondelete="restrict") company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.user.company_id) + stock_location_id = fields.Many2one( + 'stock.location', string='Stock Location', + domain=[('usage', '=', 'internal')], required=True, default=_get_default_location) - @api.multi + @api.model def action_set_default_multi_session(self): """ - during installation of the module set default multi-session + during installation of the module set default multi-sessions (separate default multi-session for every company) for all POSes for which multi_session_id is not specified """ - self.ensure_one() - configs = self.env['pos.config'].search([('multi_session_id', '=', False)]) - configs.write({ - 'multi_session_id': self.id - }) + companies = self.env['res.company'].search([]) + for company in companies: + configs = self.env['pos.config'].search([('multi_session_id', '=', False), ('company_id', '=', company.id)]) + + # If exist POSes with the company then we need to create default multi-session + if configs: + # Create default multi-session for current company + stock_location = self.env['stock.warehouse'].search([('company_id', '=', company.id)], limit=1).lot_stock_id + multi_session = self.create({ + 'name': 'Default Multi Session (%s)' % company.name, + 'multi_session_active': False, + 'company_id': company.id, + 'stock_location_id': stock_location.id + }) + for c in configs: + c.write({ + 'multi_session_id': multi_session.id + }) @api.multi def name_get(self): diff --git a/pos_multi_session/views/pos_multi_session_views.xml b/pos_multi_session/views/pos_multi_session_views.xml index 70f9e4a071..0e11d409e8 100644 --- a/pos_multi_session/views/pos_multi_session_views.xml +++ b/pos_multi_session/views/pos_multi_session_views.xml @@ -45,7 +45,7 @@ POS3 - - + Demo User2 diff --git a/pos_multi_session/models/pos_multi_session_models.py b/pos_multi_session/models/pos_multi_session_models.py index db00fb865e..43e2fcdcc5 100644 --- a/pos_multi_session/models/pos_multi_session_models.py +++ b/pos_multi_session/models/pos_multi_session_models.py @@ -83,7 +83,6 @@ def action_set_default_multi_session(self): companies = self.env['res.company'].search([]) for company in companies: configs = self.env['pos.config'].search([('multi_session_id', '=', False), ('company_id', '=', company.id)]) - # If there are POSes with the company then we need to create default multi-session if configs: # Create default multi-session for current company diff --git a/pos_multi_session/multi_session_view.xml b/pos_multi_session/multi_session_view.xml index 4f2ade8248..8d84a28442 100644 --- a/pos_multi_session/multi_session_view.xml +++ b/pos_multi_session/multi_session_view.xml @@ -16,7 +16,6 @@