diff --git a/pos_environment/README.rst b/pos_environment/README.rst new file mode 100644 index 0000000..b97c091 --- /dev/null +++ b/pos_environment/README.rst @@ -0,0 +1,4 @@ +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/pos_environment/__init__.py b/pos_environment/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/pos_environment/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_environment/__manifest__.py b/pos_environment/__manifest__.py new file mode 100644 index 0000000..72fa352 --- /dev/null +++ b/pos_environment/__manifest__.py @@ -0,0 +1,24 @@ +# 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': '12.0.1.0.0', + 'category': 'Point of Sale', + 'author': 'GRAP,Odoo Community Association (OCA)', + 'website': 'https://github.com/oca/server-env', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + 'server_environment', + ], + 'data': [ + 'views/templates.xml', + 'views/view_pos_config.xml', + ], + 'qweb': [ + 'static/src/xml/pos_environment.xml', + ], + 'installable': True, +} diff --git a/pos_environment/i18n/fr.po b/pos_environment/i18n/fr.po new file mode 100644 index 0000000..00d5d14 --- /dev/null +++ b/pos_environment/i18n/fr.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_environment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-07-31 13:08+0000\n" +"PO-Revision-Date: 2019-07-31 13:08+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: pos_environment +#: model_terms:ir.ui.view,arch_db:pos_environment.view_pos_config_form +msgid "Environment Settings" +msgstr "Paramétrages liés à l'environnement" + +#. module: pos_environment +#: model:ir.model,name:pos_environment.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Paramétrage du point de vente" + +#. module: pos_environment +#: model:ir.model.fields,field_description:pos_environment.field_pos_config__receipt_environment_footer +msgid "Receipt Environment Footer" +msgstr "Pied du ticket (selon environnement)" + +#. module: pos_environment +#: model:ir.model.fields,field_description:pos_environment.field_pos_config__receipt_environment_header +msgid "Receipt Environment Header" +msgstr "Entête du ticket (selon environnement)" + diff --git a/pos_environment/models/__init__.py b/pos_environment/models/__init__.py new file mode 100644 index 0000000..db8634a --- /dev/null +++ b/pos_environment/models/__init__.py @@ -0,0 +1 @@ +from . import pos_config diff --git a/pos_environment/models/pos_config.py b/pos_environment/models/pos_config.py new file mode 100644 index 0000000..2624b8f --- /dev/null +++ b/pos_environment/models/pos_config.py @@ -0,0 +1,45 @@ +# 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 odoo import api, fields, models +from odoo.addons.server_environment import serv_config + + +class PosConfig(models.Model): + _inherit = 'pos.config' + + # Columns section + receipt_environment_header = fields.Text( + string='Receipt Environment Header', + compute='_compute_receipt_environment_header') + + receipt_environment_footer = fields.Text( + string='Receipt Environment Footer', + compute='_compute_receipt_environment_footer') + + @api.multi + def _compute_receipt_environment_header(self): + for config in self: + config.receipt_environment_header =\ + self._get_receipt_environment_part('header') + + @api.multi + def _compute_receipt_environment_footer(self): + for config in self: + config.receipt_environment_footer =\ + self._get_receipt_environment_part('footer') + + @api.model + def _get_receipt_environment_part(self, part): + section_name = 'pos_environment_%s' % part + line_list = [] + if serv_config.has_section(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 new file mode 100644 index 0000000..d41180b --- /dev/null +++ b/pos_environment/readme/CONFIGURE.rst @@ -0,0 +1,45 @@ +* 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 + +.. code-block:: + + [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 = =============================== + +**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 : + +.. code-block:: + + 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/CONTRIBUTORS.rst b/pos_environment/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..e1525ce --- /dev/null +++ b/pos_environment/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL (https://www.twitter.com/legalsylvain) diff --git a/pos_environment/readme/DESCRIPTION.rst b/pos_environment/readme/DESCRIPTION.rst new file mode 100644 index 0000000..58ab5cf --- /dev/null +++ b/pos_environment/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ +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. + +**Note** + +This module works with or without IoT Box. diff --git a/pos_environment/readme/USAGE.rst b/pos_environment/readme/USAGE.rst new file mode 100644 index 0000000..8f348e8 --- /dev/null +++ b/pos_environment/readme/USAGE.rst @@ -0,0 +1,7 @@ +* Open Your Point of Sale + +* Realize a sale + +* The printed bill will display the custom message + +.. figure:: ../static/description/receipt.png 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/description/receipt.png b/pos_environment/static/description/receipt.png new file mode 100644 index 0000000..f522216 Binary files /dev/null and b/pos_environment/static/description/receipt.png differ diff --git a/pos_environment/static/src/js/models.js b/pos_environment/static/src/js/models.js new file mode 100644 index 0000000..34a0a03 --- /dev/null +++ b/pos_environment/static/src/js/models.js @@ -0,0 +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). + *****************************************************************************/ + +odoo.define('pos_environment.models', function (require) { + 'use strict'; + + var models = require('point_of_sale.models'); + + var order_super = models.Order.prototype; + + 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 new file mode 100644 index 0000000..9a88cff --- /dev/null +++ b/pos_environment/static/src/xml/pos_environment.xml @@ -0,0 +1,59 @@ + + diff --git a/pos_environment/views/templates.xml b/pos_environment/views/templates.xml new file mode 100644 index 0000000..ed5c6bc --- /dev/null +++ b/pos_environment/views/templates.xml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/pos_environment/views/view_pos_config.xml b/pos_environment/views/view_pos_config.xml new file mode 100644 index 0000000..70a85ba --- /dev/null +++ b/pos_environment/views/view_pos_config.xml @@ -0,0 +1,37 @@ + + + + + + pos.config + + + +

Environment Settings

+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
diff --git a/server_environment_files_sample/dev/pos_environment.conf b/server_environment_files_sample/dev/pos_environment.conf new file mode 100644 index 0000000..8df3fbd --- /dev/null +++ b/server_environment_files_sample/dev/pos_environment.conf @@ -0,0 +1,14 @@ +[pos_environment_header] +line_1 = =============================== +line_2 = BILL PRINTED ON +line_3 = DEV ENVIRONMNENT +line_4 = =============================== + +[pos_environment_footer] +line_1 = =============================== +line_2 = BILL PRINTED ON +line_3 = DEV ENVIRONMNENT +line_4 = =============================== +line_5 = THIS BILL DOESN't CONSTITUTE +line_6 = PROOF OF PURCHASE +line_7 = ===============================