From 574d95283faa6754a56df379201d3758c10fd18f Mon Sep 17 00:00:00 2001 From: Khushi Vakil Date: Mon, 12 Jun 2023 08:42:31 +0000 Subject: [PATCH] [IMP] l10n_in_pos: error on order from POS Before commit: If state is not set in the company,it gives error on order confirmation. After commit: If state is not set in the company, now it gives error when opening POS session. task id: 3360161 closes odoo/odoo#149594 X-original-commit: 803b122585d93bf226edd40c3f184a0108e8d40a Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Khushi Vakil (khva) --- addons/l10n_in_pos/i18n/l10n_in_pos.pot | 54 +++++++++++++++++++++++++ addons/l10n_in_pos/models/__init__.py | 1 + addons/l10n_in_pos/models/pos_config.py | 24 +++++++++++ 3 files changed, 79 insertions(+) create mode 100644 addons/l10n_in_pos/i18n/l10n_in_pos.pot create mode 100644 addons/l10n_in_pos/models/pos_config.py diff --git a/addons/l10n_in_pos/i18n/l10n_in_pos.pot b/addons/l10n_in_pos/i18n/l10n_in_pos.pot new file mode 100644 index 00000000000..34ee4cd99c6 --- /dev/null +++ b/addons/l10n_in_pos/i18n/l10n_in_pos.pot @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_in_pos +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-12 07:24+0000\n" +"PO-Revision-Date: 2023-06-12 07:24+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_in_pos +#: code:addons/l10n_in_pos/models/pos_config.py:0 +#, python-format +msgid "Go to Company configuration" +msgstr "" + +#. module: l10n_in_pos +#. openerp-web +#: code:addons/l10n_in_pos/static/src/xml/pos_receipt.xml:0 +#, python-format +msgid "HSN Code:" +msgstr "" + +#. module: l10n_in_pos +#. openerp-web +#: code:addons/l10n_in_pos/static/src/xml/pos_receipt.xml:0 +#, python-format +msgid "Phone:" +msgstr "" + +#. module: l10n_in_pos +#: model:ir.model,name:l10n_in_pos.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: l10n_in_pos +#: model:ir.model,name:l10n_in_pos.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: l10n_in_pos +#: code:addons/l10n_in_pos/models/pos_config.py:0 +#, python-format +msgid "" +"Your company %s needs to have a correct address in order to open the session.\n" +"Set the address of your company (Don't forget the State field)" +msgstr "" diff --git a/addons/l10n_in_pos/models/__init__.py b/addons/l10n_in_pos/models/__init__.py index 9fb4d858140..d1d0d79d296 100644 --- a/addons/l10n_in_pos/models/__init__.py +++ b/addons/l10n_in_pos/models/__init__.py @@ -3,3 +3,4 @@ from . import pos_order from . import pos_session +from . import pos_config diff --git a/addons/l10n_in_pos/models/pos_config.py b/addons/l10n_in_pos/models/pos_config.py new file mode 100644 index 00000000000..ad3159df512 --- /dev/null +++ b/addons/l10n_in_pos/models/pos_config.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import models +from odoo.exceptions import RedirectWarning +from odoo.tools.translate import _ + + +class PosConfig(models.Model): + _inherit = 'pos.config' + + def open_ui(self): + for config in self: + if config.company_id.country_id.code == 'IN' and not config.company_id.state_id: + msg = _("Your company %s needs to have a correct address in order to open the session.\n" + "Set the address of your company (Don't forget the State field)") % (config.company_id.name) + action = { + "view_mode": "form", + "res_model": "res.company", + "type": "ir.actions.act_window", + "res_id" : config.company_id.id, + "views": [[self.env.ref("base.view_company_form").id, "form"]], + } + raise RedirectWarning(msg, action, _('Go to Company configuration')) + return super(PosConfig, self).open_ui()