From a37bbcf914aa856015169a197e3d3cd48b6ddd99 Mon Sep 17 00:00:00 2001 From: Anvar Kildebekov Date: Wed, 13 Nov 2019 19:00:27 +0500 Subject: [PATCH 1/4] :ambulance: sudo() for demo-user to create session --- pos_debt_notebook/README.rst | 4 ++-- pos_debt_notebook/__manifest__.py | 2 +- pos_debt_notebook/doc/changelog.rst | 12 ++++++++++++ pos_debt_notebook/models.py | 8 ++++---- pos_debt_notebook/tests/test_pos_debt.py | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pos_debt_notebook/README.rst b/pos_debt_notebook/README.rst index ef882f0b9c..df9aff3bc4 100644 --- a/pos_debt_notebook/README.rst +++ b/pos_debt_notebook/README.rst @@ -53,9 +53,9 @@ Sponsors Further information =================== -Demo: http://runbot.it-projects.info/demo/pos-addons/9.0 +Demo: http://runbot.it-projects.info/demo/pos-addons/10.0 -HTML Description: https://apps.odoo.com/apps/modules/9.0/pos_debt_notebook/ +HTML Description: https://apps.odoo.com/apps/modules/10.0/pos_debt_notebook/ Usage instructions: ``__ diff --git a/pos_debt_notebook/__manifest__.py b/pos_debt_notebook/__manifest__.py index 74758d277d..ddf0f6d1c4 100644 --- a/pos_debt_notebook/__manifest__.py +++ b/pos_debt_notebook/__manifest__.py @@ -16,7 +16,7 @@ 'category': 'Point Of Sale', 'live_test_url': 'http://apps.it-projects.info/shop/product/pos-debt-notebook?version=10.0', "images": ['images/debt_notebook.png'], - 'version': '10.0.5.3.0', + 'version': '10.0.5.3.1', 'author': 'IT-Projects LLC, Ivan Yelizariev', "support": "pos@it-projects.info", 'website': 'https://it-projects.info', diff --git a/pos_debt_notebook/doc/changelog.rst b/pos_debt_notebook/doc/changelog.rst index 87a4903218..c397a2ac90 100644 --- a/pos_debt_notebook/doc/changelog.rst +++ b/pos_debt_notebook/doc/changelog.rst @@ -1,22 +1,32 @@ +`5.3.1` +------- + +- **FIX:** with installed pos_journal_pin, pos_invoice_postponed demo-user can't create pos-session + `5.3.0` ------- + - **Improvement:** New Balance is amount for selected journal, not for total Credits. `5.2.0` ------- + - **ADD:** Button on the ``Write-off Credits`` form. Adds all partners with debt according to the selected journal - **ADD:** Availability to write-off credits via ``Manual Credit Updates`` `5.1.4` ------- + - **FIX:** Payment mistakes on in case SERIALIZATION_FAILURE in order processing `5.1.3` ------- + - **FIX:** Error related to pos loading with the lack of customers `5.1.2` ------- + - **FIX:** Availability to buy credit top-up products with discount credits - **FIX:** Error related to automatic receipt printing - **ADD:** Mandatory Payment Method selection for return orders @@ -26,10 +36,12 @@ `5.1.1` ------- + - **FIX:** Compatibility with pos_orders_history_return module `5.1.0` ------- + - **NEW:** Wizard allow to create invoices for sets of partners: `Balance update`, `New Balance` - **FIX:** Error related to paying with not discount credit journals in POS - **FIX:** Invoices paid with credit journals now counts in partner debts diff --git a/pos_debt_notebook/models.py b/pos_debt_notebook/models.py index 489ff14049..e491b23819 100644 --- a/pos_debt_notebook/models.py +++ b/pos_debt_notebook/models.py @@ -226,7 +226,7 @@ def init_debt_journal(self): # Check if the debt journal is created already for the company. return - account_obj = self.env['account.account'] + account_obj = self.env['account.account'].sudo() debt_account_old_version = account_obj.search([ ('code', '=', 'XDEBT'), ('company_id', '=', user.company_id.id)]) if debt_account_old_version: @@ -247,7 +247,7 @@ def init_debt_journal(self): }) default_debt_limit = 0 - demo_is_on = self.env['ir.module.module'].search([('name', '=', 'pos_debt_notebook')]).demo + demo_is_on = self.env['ir.module.module'].sudo().search([('name', '=', 'pos_debt_notebook')]).demo if demo_is_on: self.create_demo_debt_journals(user, debt_account) default_debt_limit = 1000 @@ -315,7 +315,7 @@ def create_journal(self, vals): return user = vals['user'] debt_account = vals['debt_account'] - new_sequence = self.env['ir.sequence'].create({ + new_sequence = self.env['ir.sequence'].sudo().create({ 'name': vals['sequence_name'] + str(user.company_id.id), 'padding': 3, 'prefix': vals['prefix'] + str(user.company_id.id), @@ -327,7 +327,7 @@ def create_journal(self, vals): 'res_id': new_sequence.id, 'noupdate': vals['noupdate'], # If it's False, target record (res_id) will be removed while module update }) - debt_journal = self.env['account.journal'].create({ + debt_journal = self.env['account.journal'].sudo().create({ 'name': vals['journal_name'], 'code': vals['code'], 'type': vals['type'], diff --git a/pos_debt_notebook/tests/test_pos_debt.py b/pos_debt_notebook/tests/test_pos_debt.py index 2ff021d589..9fc74d0754 100644 --- a/pos_debt_notebook/tests/test_pos_debt.py +++ b/pos_debt_notebook/tests/test_pos_debt.py @@ -21,6 +21,6 @@ def test_pos_debt(self): # without a delay there might be problems on the steps whilst opening a POS # caused by a not yet loaded button's action self.phantom_js("/web", - "odoo.__DEBUG__.services['web_tour.tour'].run('tour_pos_debt_notebook', 1000)", + "odoo.__DEBUG__.services['web_tour.tour'].run('tour_pos_debt_notebook', 500)", "odoo.__DEBUG__.services['web_tour.tour'].tours.tour_pos_debt_notebook.ready", login="admin", timeout=140) From aac4fd705a41dbdbf2192955916c9e4d62a18f9d Mon Sep 17 00:00:00 2001 From: Anvar Kildebekov Date: Wed, 13 Nov 2019 18:58:45 +0500 Subject: [PATCH 2/4] :ambulance: event handler for numpad-click;sudo rights for creating session; --- pos_journal_pin/README.rst | 3 ++- pos_journal_pin/__manifest__.py | 7 ++++--- pos_journal_pin/doc/changelog.rst | 6 ++++++ pos_journal_pin/doc/index.rst | 1 + pos_journal_pin/models/models.py | 13 +++++++------ pos_journal_pin/static/src/js/main.js | 9 ++++++++- pos_journal_pin/tests/test_journal_pin.py | 10 ++++++++-- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/pos_journal_pin/README.rst b/pos_journal_pin/README.rst index e9e105d817..195bbd8b1d 100644 --- a/pos_journal_pin/README.rst +++ b/pos_journal_pin/README.rst @@ -14,6 +14,7 @@ Credits Contributors ------------ * `Kolushov Alexandr `__ +* `Anvar Kildebekov `__ Sponsors -------- @@ -44,4 +45,4 @@ Changelog: ``_ Notifications on updates: `via Atom `_, `by Email `_ -Tested on Odoo 10.0 49ca43d75cb9a97642c820c2466d454f1ce604cb +Tested on Odoo 10.0 2fc46a064d36d9de2c6debf9582976f938e3568b diff --git a/pos_journal_pin/__manifest__.py b/pos_journal_pin/__manifest__.py index 830bc7f083..2a0538e0d3 100644 --- a/pos_journal_pin/__manifest__.py +++ b/pos_journal_pin/__manifest__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2019 Kolushov Alexandr +# Copyright 2019 Kildebekov Anvar # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": """POS Payments by Manager's PIN""", @@ -7,15 +8,15 @@ "category": "Point of Sale", # "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=10.0", "images": ['images/pos_journal_pin.jpg'], - "version": "10.0.1.0.0", + "version": "10.0.1.0.1", "application": False, "author": "IT-Projects LLC, Kolushov Alexandr", "support": "apps@it-projects.info", "website": "https://it-projects.info/team/KolushovAlexandr", "license": "LGPL-3", - # "price": 9.00, - # "currency": "EUR", + "price": 80.00, + "currency": "EUR", "depends": [ "pos_pin", diff --git a/pos_journal_pin/doc/changelog.rst b/pos_journal_pin/doc/changelog.rst index 5583eb326a..d7370362d8 100644 --- a/pos_journal_pin/doc/changelog.rst +++ b/pos_journal_pin/doc/changelog.rst @@ -1,3 +1,9 @@ +`1.0.1` +------- + +- **Fix:** Adding first payment line by clicking numpad button, without asking manager's PIN, if first payment method in list require manager's PIN +- **Fix:** Creating sessions by non-administrators + `1.0.0` ------- diff --git a/pos_journal_pin/doc/index.rst b/pos_journal_pin/doc/index.rst index 458013184c..2dd2c299a7 100644 --- a/pos_journal_pin/doc/index.rst +++ b/pos_journal_pin/doc/index.rst @@ -19,6 +19,7 @@ As Administrator please follow next scenario: Journal ------- + * `Activate Developer Mode `__ * Open ``[[Point of Sale]] >> Payment Methods`` menu * Choose a journal or create one, be sure the journal is active in POS * Activate **Manager's Permission** field diff --git a/pos_journal_pin/models/models.py b/pos_journal_pin/models/models.py index c1cea91df6..392e5a0e4e 100644 --- a/pos_journal_pin/models/models.py +++ b/pos_journal_pin/models/models.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Kolushov Alexandr +# Copyright 2019 Kolushov Alexandr +# Copyright 2019 Kildebekov Anvar # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). from odoo import models, fields, api - MODULE = 'pos_journal_pin' @@ -25,7 +24,9 @@ def open_session_cb(self): def init_pin_journal(self): """Init demo Journals for current company""" - demo_is_on = self.env['ir.module.module'].search([('name', '=', MODULE)]).demo + # Access rejection of demo user, "*.sudo().*" - superuser-rights for creating session + demo_is_on = self.env['ir.module.module'].sudo().search([('name', '=', MODULE)]).demo + if not demo_is_on: return # Multi-company is not primary task for this module, but I copied this @@ -55,7 +56,7 @@ def init_pin_journal(self): def _create_pin_journal(self, vals): user = self.env.user - new_sequence = self.env['ir.sequence'].create({ + new_sequence = self.env['ir.sequence'].sudo().create({ 'name': vals['sequence_name'] + str(user.company_id.id), 'padding': 3, 'prefix': vals['prefix'] + str(user.company_id.id), @@ -67,7 +68,7 @@ def _create_pin_journal(self, vals): 'res_id': new_sequence.id, 'noupdate': True, # If it's False, target record (res_id) will be removed while module update }) - pin_journal = self.env['account.journal'].create({ + pin_journal = self.env['account.journal'].sudo().create({ 'name': vals['journal_name'], 'code': vals['code'], 'type': vals['type'], diff --git a/pos_journal_pin/static/src/js/main.js b/pos_journal_pin/static/src/js/main.js index 0ec46e2535..befb85804e 100644 --- a/pos_journal_pin/static/src/js/main.js +++ b/pos_journal_pin/static/src/js/main.js @@ -1,4 +1,5 @@ // Copyright 2019 Kolushov Alexandr +// Copyright 2019 Kildebekov Anvar // License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). odoo.define('pos_journal_pin', function (require) { 'use_strict'; @@ -7,12 +8,18 @@ var core = require('web.core'); var models = require('point_of_sale.models'); var screens = require('point_of_sale.screens'); -var QWeb = core.qweb; var _t = core._t; models.load_fields('account.journal', ['ask_manager']); screens.PaymentScreenWidget.include({ + click_numpad: function(button) { + var paymentlines = this.pos.get_order().get_paymentlines(); + if (paymentlines.length || !this.pos.cashregisters[0].journal.ask_manager) { + return this._super(button); + } + this.click_paymentmethods(this.pos.cashregisters[0].journal_id[0]); + }, click_paymentmethods: function(id) { var self = this; var cashregister = null; diff --git a/pos_journal_pin/tests/test_journal_pin.py b/pos_journal_pin/tests/test_journal_pin.py index 9bedaa7352..ce1943a4b8 100644 --- a/pos_journal_pin/tests/test_journal_pin.py +++ b/pos_journal_pin/tests/test_journal_pin.py @@ -9,11 +9,17 @@ @odoo.tests.common.post_install(True) class TestUi(odoo.tests.HttpCase): - def test_01_pos_journal_pin(self): + def main(self, login): self.phantom_js( '/web', "odoo.__DEBUG__.services['web_tour.tour'].run('pos_journal_pin_tour')", "odoo.__DEBUG__.services['web_tour.tour'].tours.pos_journal_pin_tour.ready", - login="admin", + login=login, timeout=100, ) + + def test_01_pos_journal_pin(self): + self.main("admin") + + def test_02_pos_journal_pin(self): + self.main("demo") From e664084bbc06d13ff1a972a7548268a30d1bc49b Mon Sep 17 00:00:00 2001 From: Anvar Kildebekov Date: Wed, 13 Nov 2019 18:59:52 +0500 Subject: [PATCH 3/4] :ambulance: sudo() in 'models.py' for non-administrators to create session --- pos_invoice_postponed/README.rst | 3 ++- pos_invoice_postponed/__manifest__.py | 3 ++- pos_invoice_postponed/doc/changelog.rst | 5 +++++ pos_invoice_postponed/models/models.py | 7 ++++--- pos_invoice_postponed/static/src/js/main.js | 6 ------ pos_invoice_postponed/tests/test_default.py | 11 ++++++++--- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pos_invoice_postponed/README.rst b/pos_invoice_postponed/README.rst index c38aadb8c2..943cfc399d 100644 --- a/pos_invoice_postponed/README.rst +++ b/pos_invoice_postponed/README.rst @@ -16,6 +16,7 @@ Credits Contributors ------------ * `Kolushov Alexandr `__ +* `Anvar Kildebekov `__ Sponsors -------- @@ -46,4 +47,4 @@ Changelog: ``_ Notifications on updates: `via Atom `_, `by Email `_ -Tested on Odoo 10.0 49ca43d75cb9a97642c820c2466d454f1ce604cb +Tested on Odoo 10.0 da474d0e872c9938b061e133011bd36b416eafc7 diff --git a/pos_invoice_postponed/__manifest__.py b/pos_invoice_postponed/__manifest__.py index 4445187b3e..2cd9aa8e56 100644 --- a/pos_invoice_postponed/__manifest__.py +++ b/pos_invoice_postponed/__manifest__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2019 Kolushov Alexandr +# Copyright 2019 Anvar Kildebekov # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": """Creation of Postponed invoices in POS""", @@ -7,7 +8,7 @@ "category": "Point of Sale", # "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=10.0", "images": ['images/postponed2.jpg'], - "version": "10.0.1.0.0", + "version": "10.0.1.0.1", "application": False, "author": "IT-Projects LLC, Kolushov Alexandr", diff --git a/pos_invoice_postponed/doc/changelog.rst b/pos_invoice_postponed/doc/changelog.rst index 5583eb326a..34d1378a86 100644 --- a/pos_invoice_postponed/doc/changelog.rst +++ b/pos_invoice_postponed/doc/changelog.rst @@ -1,3 +1,8 @@ +`1.0.1` +------- + +- **Fix:** Creating of session by non-administrators + `1.0.0` ------- diff --git a/pos_invoice_postponed/models/models.py b/pos_invoice_postponed/models/models.py index 09e57fb878..1f5af27c9b 100644 --- a/pos_invoice_postponed/models/models.py +++ b/pos_invoice_postponed/models/models.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2019 Kolushov Alexandr +# Copyright 2019 Anvar Kildebekov # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). import copy @@ -99,7 +100,7 @@ def open_session_cb(self): def init_postponed_journal(self): """Init demo Journals for current company""" - demo_is_on = self.env['ir.module.module'].search([('name', '=', MODULE)]).demo + demo_is_on = self.env['ir.module.module'].sudo().search([('name', '=', MODULE)]).demo if not demo_is_on: return # Multi-company is not primary task for this module, but I copied this @@ -129,7 +130,7 @@ def init_postponed_journal(self): def _create_postponed_journal(self, vals): user = self.env.user - new_sequence = self.env['ir.sequence'].create({ + new_sequence = self.env['ir.sequence'].sudo().create({ 'name': vals['sequence_name'] + str(user.company_id.id), 'padding': 3, 'prefix': vals['prefix'] + str(user.company_id.id), @@ -141,7 +142,7 @@ def _create_postponed_journal(self, vals): 'res_id': new_sequence.id, 'noupdate': True, # If it's False, target record (res_id) will be removed while module update }) - pin_journal = self.env['account.journal'].create({ + pin_journal = self.env['account.journal'].sudo().create({ 'name': vals['journal_name'], 'code': vals['code'], 'type': vals['type'], diff --git a/pos_invoice_postponed/static/src/js/main.js b/pos_invoice_postponed/static/src/js/main.js index 42af041a1b..81785e5ec1 100644 --- a/pos_invoice_postponed/static/src/js/main.js +++ b/pos_invoice_postponed/static/src/js/main.js @@ -6,14 +6,8 @@ odoo.define('pos_invoice_postponed.pos', function (require) { var models = require('point_of_sale.models'); var screens = require('point_of_sale.screens'); var core = require('web.core'); - var gui = require('point_of_sale.gui'); - var utils = require('web.utils'); - var Model = require('web.DataModel'); - var PopupWidget = require('point_of_sale.popups'); - var QWeb = core.qweb; var _t = core._t; - var round_pr = utils.round_precision; models.load_fields('account.journal', ['postponed_invoice']); diff --git a/pos_invoice_postponed/tests/test_default.py b/pos_invoice_postponed/tests/test_default.py index 70f4ec1f5f..2116612d19 100644 --- a/pos_invoice_postponed/tests/test_default.py +++ b/pos_invoice_postponed/tests/test_default.py @@ -10,12 +10,11 @@ @odoo.tests.common.post_install(True) class TestUi(odoo.tests.HttpCase): - def test_01_pos_postponed_invoice(self): - + def main(self, login): self.phantom_js('/pos/web?m=1', "odoo.__DEBUG__.services['web_tour.tour'].run('pos_invoice_postponed_tour'), 1000", "odoo.__DEBUG__.services['web_tour.tour'].tours.pos_invoice_postponed_tour.ready", - login="admin", timeout=240) + login=login, timeout=240) cr = self.registry.cursor() cr.execute('select "id" from "pos_order" order by "id" desc limit 1') @@ -26,3 +25,9 @@ def test_01_pos_postponed_invoice(self): self.assertEqual(len(order.statement_ids), 0, 'Number of statements are %s expected %s' % (len(order.statement_ids), 0)) self.assertEqual(order.amount_paid, 0, 'Amount paid is %s expected %s' % (order.amount_paid, 0)) cr.release() + + def test_01_pos_postponed_invoice(self): + self.main("admin") + + def test_02_pos_postponed_invoice(self): + self.main("demo") From bb8866a51a17576b8cb100cab3ac05642c073acb Mon Sep 17 00:00:00 2001 From: i18n-bot Date: Thu, 21 Nov 2019 12:37:24 +0000 Subject: [PATCH 4/4] :alien: Update pos_invoice_postponed.pot Done by forked MQT: https://github.com/it-projects-llc/maintainer-quality-tools/ --- pos_invoice_postponed/i18n/pos_invoice_postponed.pot | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pos_invoice_postponed/i18n/pos_invoice_postponed.pot b/pos_invoice_postponed/i18n/pos_invoice_postponed.pot index 6781002102..b56458938f 100644 --- a/pos_invoice_postponed/i18n/pos_invoice_postponed.pot +++ b/pos_invoice_postponed/i18n/pos_invoice_postponed.pot @@ -41,14 +41,14 @@ msgstr "" #. module: pos_invoice_postponed #. openerp-web -#: code:addons/pos_invoice_postponed/static/src/js/main.js:34 +#: code:addons/pos_invoice_postponed/static/src/js/main.js:28 #, python-format msgid "Customer Error" msgstr "" #. module: pos_invoice_postponed #. openerp-web -#: code:addons/pos_invoice_postponed/static/src/js/main.js:35 +#: code:addons/pos_invoice_postponed/static/src/js/main.js:29 #, python-format msgid "Customer is not set. Please set a customer to proceed postponed invoice payment" msgstr "" @@ -74,14 +74,14 @@ msgstr "" #. module: pos_invoice_postponed #. openerp-web -#: code:addons/pos_invoice_postponed/static/src/js/main.js:41 +#: code:addons/pos_invoice_postponed/static/src/js/main.js:35 #, python-format msgid "Payment Method Error" msgstr "" #. module: pos_invoice_postponed #. openerp-web -#: code:addons/pos_invoice_postponed/static/src/js/main.js:42 +#: code:addons/pos_invoice_postponed/static/src/js/main.js:36 #, python-format msgid "Please do not use postpone payment methods with regular ones" msgstr "" @@ -104,7 +104,7 @@ msgid "Ready to launch your point of sale? Click here." msgstr "" #. module: pos_invoice_postponed -#: code:addons/pos_invoice_postponed/models/models.py:63 +#: code:addons/pos_invoice_postponed/models/models.py:64 #, python-format msgid "This Postponed invoice has been created from the point of sale session: %s" msgstr ""