diff --git a/pos_environment/README.rst b/pos_environment/README.rst new file mode 100644 index 0000000..e4911fb --- /dev/null +++ b/pos_environment/README.rst @@ -0,0 +1,117 @@ +========================================== +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 new file mode 100644 index 0000000..042e239 --- /dev/null +++ b/pos_environment/__init__.py @@ -0,0 +1,2 @@ +# coding: utf-8 +from . import models diff --git a/pos_environment/__openerp__.py b/pos_environment/__openerp__.py new file mode 100644 index 0000000..d648501 --- /dev/null +++ b/pos_environment/__openerp__.py @@ -0,0 +1,27 @@ +# 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', + 'category': 'Point of Sale', + 'author': 'GRAP', + 'website': 'http://www.grap.coop', + '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', + ], + 'images': [ + ], + 'installable': False, +} diff --git a/pos_environment/i18n/fr.po b/pos_environment/i18n/fr.po new file mode 100644 index 0000000..f4c7deb --- /dev/null +++ b/pos_environment/i18n/fr.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_environment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-02-07 14:53+0000\n" +"PO-Revision-Date: 2019-02-07 14:53+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 +#: field:pos.config,receipt_environment_footer:0 +msgid "Receipt Environment Footer" +msgstr "Pied du ticket (selon environnement)" + +#. module: pos_environment +#: field:pos.config,receipt_environment_header:0 +msgid "Receipt Environment Header" +msgstr "En-tĂȘ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..32f0091 --- /dev/null +++ b/pos_environment/models/__init__.py @@ -0,0 +1,2 @@ +# coding: utf-8 +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..12a9639 --- /dev/null +++ b/pos_environment/models/pos_config.py @@ -0,0 +1,38 @@ +# 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 + + +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 + if serv_config.has_section(section_name): + return '\n'.join( + [x[1] for x in serv_config.items(section_name)]) diff --git a/pos_environment/readme/CONFIGURE.rst b/pos_environment/readme/CONFIGURE.rst new file mode 100644 index 0000000..8eb1a46 --- /dev/null +++ b/pos_environment/readme/CONFIGURE.rst @@ -0,0 +1,23 @@ +* 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 = =============================== 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..5aacf04 --- /dev/null +++ b/pos_environment/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +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. diff --git a/pos_environment/readme/ROADMAP.rst b/pos_environment/readme/ROADMAP.rst new file mode 100644 index 0000000..9251cd5 --- /dev/null +++ b/pos_environment/readme/ROADMAP.rst @@ -0,0 +1,10 @@ +* 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/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/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..e161805 --- /dev/null +++ b/pos_environment/static/src/js/models.js @@ -0,0 +1,29 @@ +/****************************************************************************** + 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) { + + var module = instance.point_of_sale; + + /************************************************************************* + 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({ + + 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; + }, + + }); + +}; 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..03788c0 --- /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..0ae0b09 --- /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..6e080f5 --- /dev/null +++ b/pos_environment/views/view_pos_config.xml @@ -0,0 +1,20 @@ + + + + + + pos.config + + + + + + + + + +