diff --git a/pos_environment/README.rst b/pos_environment/README.rst index e4911fb..b97c091 100644 --- a/pos_environment/README.rst +++ b/pos_environment/README.rst @@ -1,117 +1,4 @@ -========================================== -Point of Sale - Custom Bill by Environment -========================================== - .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fgrap--odoo--incubator-lightgray.png?logo=github - :target: https://github.com/grap/grap-odoo-incubator/tree/8.0/pos_environment - :alt: grap/grap-odoo-incubator - -|badge1| |badge2| |badge3| - -This module extends the Odoo point of sale module to allow administrator -to customize the bill printed by the point of sale, with a text depending -on your environment. (Development, , Pre Production, Production, etc...) - -This module is based on the mechanism introduced by the ``server_environment`` -module. - -**Table of contents** - -.. contents:: - :local: - -Configuration -============= - -* Open your module ``server_environment_files`` - -* In each environment folder, create a new file named ``pos_environment.conf`` - (for exemple) - -* In each file, write a section like this one, depending on your environment - -:: - - [pos_environment_header] - line_1 = =============================== - line_2 = TICKET EDITED ON A TEST - line_3 = ENVIRONMENT - line_4 = =============================== - - [pos_environment_footer] - line_1 = =============================== - line_2 = THIS TICKET HAS BEEN EDITED - line_3 = ON A TEST ENVIRONMENT - line_4 = ------------------------------- - line_5 = IT CAN NOT BE CONSIDERED - line_6 = AS A PROOF OF PURCHASE - line_7 = =============================== - -Usage -===== - -* Open Your Point of Sale - -* Realize a sale - -* The printed bill will display the custom message - -.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/pos_environment/static/description/receipt.png - -Known issues / Roadmap -====================== - -* make this module working in a multi localization context (many languages), - inserting a pattern in the key of each lines. sample: - -:: - - [pos_environment_header] - line_1 = ================================ - line_2_en_US = TICKET EDITED ON A TEST ENV - line_2_fr_FR = TICKET EDITE SUR SERVEUR DE TEST - line_3 = ================================ - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* GRAP - -Contributors -~~~~~~~~~~~~ - -* Sylvain LE GAL (https://www.twitter.com/legalsylvain) - -Maintainers -~~~~~~~~~~~ - - - -This module is part of the `grap/grap-odoo-incubator `_ project on GitHub. - - -You are welcome to contribute. diff --git a/pos_environment/__init__.py b/pos_environment/__init__.py index 042e239..0650744 100644 --- a/pos_environment/__init__.py +++ b/pos_environment/__init__.py @@ -1,2 +1 @@ -# coding: utf-8 from . import models diff --git a/pos_environment/__openerp__.py b/pos_environment/__manifest__.py similarity index 79% rename from pos_environment/__openerp__.py rename to pos_environment/__manifest__.py index d648501..72fa352 100644 --- a/pos_environment/__openerp__.py +++ b/pos_environment/__manifest__.py @@ -1,14 +1,13 @@ -# coding: utf-8 # Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Point of Sale - Custom Bill by Environment', 'summary': "Custom messages on the bill depending on the environment", - 'version': '8.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Point of Sale', - 'author': 'GRAP', - 'website': 'http://www.grap.coop', + 'author': 'GRAP,Odoo Community Association (OCA)', + 'website': 'https://github.com/oca/server-env', 'license': 'AGPL-3', 'depends': [ 'point_of_sale', @@ -21,7 +20,5 @@ 'qweb': [ 'static/src/xml/pos_environment.xml', ], - 'images': [ - ], - 'installable': False, + 'installable': True, } diff --git a/pos_environment/models/__init__.py b/pos_environment/models/__init__.py index 32f0091..db8634a 100644 --- a/pos_environment/models/__init__.py +++ b/pos_environment/models/__init__.py @@ -1,2 +1 @@ -# coding: utf-8 from . import pos_config diff --git a/pos_environment/models/pos_config.py b/pos_environment/models/pos_config.py index 12a9639..2624b8f 100644 --- a/pos_environment/models/pos_config.py +++ b/pos_environment/models/pos_config.py @@ -1,9 +1,8 @@ -# coding: utf-8 # Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models -from openerp.addons.server_environment import serv_config +from odoo import api, fields, models +from odoo.addons.server_environment import serv_config class PosConfig(models.Model): @@ -33,6 +32,14 @@ class PosConfig(models.Model): @api.model def _get_receipt_environment_part(self, part): section_name = 'pos_environment_%s' % part + line_list = [] if serv_config.has_section(section_name): - return '\n'.join( - [x[1] for x in serv_config.items(section_name)]) + # Parse each line + for item in serv_config.items(section_name): + if '__' not in item[0]: + # Universal line + line_list.append(item[1]) + elif '__%s' % (self.env.user.lang) in item[0]: + # depend of the language + line_list.append(item[1]) + return '\n'.join(line_list) diff --git a/pos_environment/readme/CONFIGURE.rst b/pos_environment/readme/CONFIGURE.rst index 8eb1a46..ca62bb3 100644 --- a/pos_environment/readme/CONFIGURE.rst +++ b/pos_environment/readme/CONFIGURE.rst @@ -5,19 +5,41 @@ * In each file, write a section like this one, depending on your environment -:: +``` +[pos_environment_header] +line_1 = =============================== +line_2 = TICKET EDITED ON A TEST +line_3 = ENVIRONMENT +line_4 = =============================== - [pos_environment_header] - line_1 = =============================== - line_2 = TICKET EDITED ON A TEST - line_3 = ENVIRONMENT - line_4 = =============================== +[pos_environment_footer] +line_1 = =============================== +line_2 = THIS TICKET HAS BEEN EDITED +line_3 = ON A TEST ENVIRONMENT +line_4 = ------------------------------- +line_5 = IT CAN NOT BE CONSIDERED +line_6 = AS A PROOF OF PURCHASE +line_7 = =============================== +``` - [pos_environment_footer] - line_1 = =============================== - line_2 = THIS TICKET HAS BEEN EDITED - line_3 = ON A TEST ENVIRONMENT - line_4 = ------------------------------- - line_5 = IT CAN NOT BE CONSIDERED - line_6 = AS A PROOF OF PURCHASE - line_7 = =============================== +**Internationalisation** + +If you deploy Odoo in a multi languages context, you can add a suffix +``__xx_xx`` in the name of each line, where ``xx_xx`` is the language. +The text will be displayed on the bill, depending of the language of the +current user. Sample : + +``` +line_1 = =============================== +line_2__en_US = TICKET EDITED ON A TEST SERVER +line_2__fr_FR = TICKET EDITE SUR SERVEUR DE TEST +line_3 = ------------------------------- +``` + +**Note** + +To be sure that your server is correctly configured, you can check the settings +in the Point of Sale configuration. + + +.. figure:: ../static/description/pos_config_form.png diff --git a/pos_environment/readme/DESCRIPTION.rst b/pos_environment/readme/DESCRIPTION.rst index 5aacf04..58ab5cf 100644 --- a/pos_environment/readme/DESCRIPTION.rst +++ b/pos_environment/readme/DESCRIPTION.rst @@ -4,3 +4,7 @@ on your environment. (Development, , Pre Production, Production, etc...) This module is based on the mechanism introduced by the ``server_environment`` module. + +**Note** + +This module works with or without IoT Box. diff --git a/pos_environment/readme/ROADMAP.rst b/pos_environment/readme/ROADMAP.rst deleted file mode 100644 index 9251cd5..0000000 --- a/pos_environment/readme/ROADMAP.rst +++ /dev/null @@ -1,10 +0,0 @@ -* make this module working in a multi localization context (many languages), - inserting a pattern in the key of each lines. sample: - -:: - - [pos_environment_header] - line_1 = ================================ - line_2_en_US = TICKET EDITED ON A TEST ENV - line_2_fr_FR = TICKET EDITE SUR SERVEUR DE TEST - line_3 = ================================ diff --git a/pos_environment/static/description/pos_config_form.png b/pos_environment/static/description/pos_config_form.png new file mode 100644 index 0000000..277049a Binary files /dev/null and b/pos_environment/static/description/pos_config_form.png differ diff --git a/pos_environment/static/src/js/models.js b/pos_environment/static/src/js/models.js index e161805..34a0a03 100644 --- a/pos_environment/static/src/js/models.js +++ b/pos_environment/static/src/js/models.js @@ -1,29 +1,25 @@ -/****************************************************************************** +/** **************************************************************************** Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) @author: Sylvain LE GAL (https://twitter.com/legalsylvain) License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). *****************************************************************************/ -'use strict'; -openerp.pos_environment = function(instance, local) { +odoo.define('pos_environment.models', function (require) { + 'use strict'; - var module = instance.point_of_sale; + var models = require('point_of_sale.models'); - /************************************************************************* - Extend module.Order: - add environment header and footer in export_for_printing - to make print via proxy working - */ - var moduleOrderParent = module.Order; - module.Order = module.Order.extend({ + var order_super = models.Order.prototype; - export_for_printing: function(attributes){ - var order = moduleOrderParent.prototype.export_for_printing.apply(this, arguments); - order.receipt_environment_header = this.pos.config.receipt_environment_header; - order.receipt_environment_footer = this.pos.config.receipt_environment_footer; - return order; + models.Order = models.Order.extend({ + export_for_printing: function () { + var res = order_super.export_for_printing.apply(this, arguments); + res.receipt_environment_header = + this.pos.config.receipt_environment_header; + res.receipt_environment_footer = + this.pos.config.receipt_environment_footer; + console.log(res); + return res; }, - }); - -}; +}); diff --git a/pos_environment/static/src/xml/pos_environment.xml b/pos_environment/static/src/xml/pos_environment.xml index 03788c0..9a88cff 100644 --- a/pos_environment/static/src/xml/pos_environment.xml +++ b/pos_environment/static/src/xml/pos_environment.xml @@ -3,35 +3,7 @@ - - -
-
- - -
-
-
-
-
- - - -
-
- - -
-
-
-
-
-
- - - - - +
@@ -56,4 +28,32 @@ + + + + + +
+
+ + +
+
+
+
+
+ + + +
+
+ + +
+
+
+
+
+
+ diff --git a/pos_environment/views/templates.xml b/pos_environment/views/templates.xml index 0ae0b09..ed5c6bc 100644 --- a/pos_environment/views/templates.xml +++ b/pos_environment/views/templates.xml @@ -5,7 +5,7 @@ Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> - + - + diff --git a/pos_environment/views/view_pos_config.xml b/pos_environment/views/view_pos_config.xml index 6e080f5..70a85ba 100644 --- a/pos_environment/views/view_pos_config.xml +++ b/pos_environment/views/view_pos_config.xml @@ -4,17 +4,34 @@ Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) @author: Sylvain LE GAL (https://twitter.com/legalsylvain) License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> - + - + pos.config - + - - - - + +

Environment Settings

+
+
+
+
+
+
+
+
+
+
+
-
+