[PORT] port pos_environment to v 12.0

This commit is contained in:
Sylvain LE GAL 2019-07-31 10:54:34 +02:00 committed by OCA-git-bot
parent 44f9af530f
commit 097565a12c
13 changed files with 127 additions and 209 deletions

View File

@ -1,117 +1,4 @@
==========================================
Point of Sale - Custom Bill by Environment
==========================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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 <https://github.com/grap/grap-odoo-incubator/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 <https://github.com/grap/grap-odoo-incubator/issues/new?body=module:%20pos_environment%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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 <https://github.com/grap/grap-odoo-incubator/tree/8.0/pos_environment>`_ project on GitHub.
You are welcome to contribute.

View File

@ -1,2 +1 @@
# coding: utf-8
from . import models from . import models

View File

@ -1,14 +1,13 @@
# coding: utf-8
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) # Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Point of Sale - Custom Bill by Environment', 'name': 'Point of Sale - Custom Bill by Environment',
'summary': "Custom messages on the bill depending on the 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', 'category': 'Point of Sale',
'author': 'GRAP', 'author': 'GRAP,Odoo Community Association (OCA)',
'website': 'http://www.grap.coop', 'website': 'https://github.com/oca/server-env',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': [ 'depends': [
'point_of_sale', 'point_of_sale',
@ -21,7 +20,5 @@
'qweb': [ 'qweb': [
'static/src/xml/pos_environment.xml', 'static/src/xml/pos_environment.xml',
], ],
'images': [ 'installable': True,
],
'installable': False,
} }

View File

@ -1,2 +1 @@
# coding: utf-8
from . import pos_config from . import pos_config

View File

@ -1,9 +1,8 @@
# coding: utf-8
# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) # Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models from odoo import api, fields, models
from openerp.addons.server_environment import serv_config from odoo.addons.server_environment import serv_config
class PosConfig(models.Model): class PosConfig(models.Model):
@ -33,6 +32,14 @@ class PosConfig(models.Model):
@api.model @api.model
def _get_receipt_environment_part(self, part): def _get_receipt_environment_part(self, part):
section_name = 'pos_environment_%s' % part section_name = 'pos_environment_%s' % part
line_list = []
if serv_config.has_section(section_name): if serv_config.has_section(section_name):
return '\n'.join( # Parse each line
[x[1] for x in serv_config.items(section_name)]) 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)

View File

@ -5,19 +5,41 @@
* In each file, write a section like this one, depending on your environment * 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] [pos_environment_footer]
line_1 = =============================== line_1 = ===============================
line_2 = TICKET EDITED ON A TEST line_2 = THIS TICKET HAS BEEN EDITED
line_3 = ENVIRONMENT line_3 = ON A TEST ENVIRONMENT
line_4 = =============================== line_4 = -------------------------------
line_5 = IT CAN NOT BE CONSIDERED
line_6 = AS A PROOF OF PURCHASE
line_7 = ===============================
```
[pos_environment_footer] **Internationalisation**
line_1 = ===============================
line_2 = THIS TICKET HAS BEEN EDITED If you deploy Odoo in a multi languages context, you can add a suffix
line_3 = ON A TEST ENVIRONMENT ``__xx_xx`` in the name of each line, where ``xx_xx`` is the language.
line_4 = ------------------------------- The text will be displayed on the bill, depending of the language of the
line_5 = IT CAN NOT BE CONSIDERED current user. Sample :
line_6 = AS A PROOF OF PURCHASE
line_7 = =============================== ```
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

View File

@ -4,3 +4,7 @@ on your environment. (Development, , Pre Production, Production, etc...)
This module is based on the mechanism introduced by the ``server_environment`` This module is based on the mechanism introduced by the ``server_environment``
module. module.
**Note**
This module works with or without IoT Box.

View File

@ -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 = ================================

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,29 +1,25 @@
/****************************************************************************** /** ****************************************************************************
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). 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');
/************************************************************************* var order_super = models.Order.prototype;
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){ models.Order = models.Order.extend({
var order = moduleOrderParent.prototype.export_for_printing.apply(this, arguments); export_for_printing: function () {
order.receipt_environment_header = this.pos.config.receipt_environment_header; var res = order_super.export_for_printing.apply(this, arguments);
order.receipt_environment_footer = this.pos.config.receipt_environment_footer; res.receipt_environment_header =
return order; this.pos.config.receipt_environment_header;
res.receipt_environment_footer =
this.pos.config.receipt_environment_footer;
console.log(res);
return res;
}, },
}); });
});
};

View File

@ -3,35 +3,7 @@
<!-- Non Proxy Bill --> <!-- Non Proxy Bill -->
<t t-extend="PosTicket"> <t t-extend="PosTicket">
<t t-jquery="[t-if='widget.pos.config.receipt_header']" t-operation="before"> <t t-jquery="[t-if='receipt.header']" t-operation="before">
<t t-if="widget.pos.config.receipt_environment_header">
<br />
<div style='text-align:center'>
<t t-foreach="widget.pos.config.receipt_environment_header.split('\n')" t-as="line">
<t t-esc="line"/>
<br />
</t>
</div>
</t>
</t>
<t t-jquery="[t-if='widget.pos.config.receipt_footer']" t-operation="after">
<t t-if="widget.pos.config.receipt_environment_footer">
<br />
<div style='text-align:center'>
<t t-foreach="widget.pos.config.receipt_environment_footer.split('\n')" t-as="line">
<t t-esc="line"/>
<br />
</t>
</div>
</t>
</t>
</t>
<!-- Proxy Bill -->
<t t-extend="XmlReceipt">
<t t-jquery="[t-if='receipt.header']" t-operation="after">
<t t-if="widget.pos.config.receipt_environment_header"> <t t-if="widget.pos.config.receipt_environment_header">
<br /> <br />
<div style='text-align:center'> <div style='text-align:center'>
@ -56,4 +28,32 @@
</t> </t>
</t> </t>
<!-- Proxy Bill -->
<t t-extend="XmlReceipt">
<t t-jquery="[t-if='receipt.header_xml']" t-operation="after">
<t t-if="widget.pos.config.receipt_environment_header">
<br />
<div style='text-align:center'>
<t t-foreach="widget.pos.config.receipt_environment_header.split('\n')" t-as="line">
<t t-esc="line"/>
<br />
</t>
</div>
</t>
</t>
<t t-jquery="[t-if='receipt.footer_xml']" t-operation="after">
<t t-if="widget.pos.config.receipt_environment_footer">
<br />
<div style='text-align:center'>
<t t-foreach="widget.pos.config.receipt_environment_footer.split('\n')" t-as="line">
<t t-esc="line"/>
<br />
</t>
</div>
</t>
</t>
</t>
</template> </template>

View File

@ -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). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
--> -->
<openerp><data> <odoo>
<template id="point_of_sale_assets" inherit_id="point_of_sale.index"> <template id="point_of_sale_assets" inherit_id="point_of_sale.index">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
@ -13,4 +13,4 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
</xpath> </xpath>
</template> </template>
</data></openerp> </odoo>

View File

@ -4,17 +4,34 @@ Copyright (C) 2013 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
--> -->
<openerp><data> <odoo>
<record id="view_pos_config_form" model="ir.ui.view"> <record id="view_pos_config_form" model="ir.ui.view">
<field name="model">pos.config</field> <field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/> <field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="receipt_footer" position="after"> <xpath expr="//sheet" position="inside">
<field name="receipt_environment_header"/> <h2 name="order">Environment Settings</h2>
<field name="receipt_environment_footer"/> <div class="row mt16 o_settings_container">
</field> <div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="receipt_environment_header"/>
<div class="text-muted">
<field name="receipt_environment_header"/>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="receipt_environment_footer"/>
<div class="text-muted">
<field name="receipt_environment_footer"/>
</div>
</div>
</div>
</div>
</xpath>
</field> </field>
</record> </record>
</data></openerp> </odoo>