[IMP] pos_environment: black, isort, prettier
This commit is contained in:
parent
e2ebd44de8
commit
ed4cb66cae
|
|
@ -2,23 +2,23 @@
|
||||||
# @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': '12.0.1.0.1',
|
"version": "12.0.1.0.1",
|
||||||
'category': 'Point of Sale',
|
"category": "Point of Sale",
|
||||||
'author': 'GRAP,Odoo Community Association (OCA)',
|
"author": "GRAP,Odoo Community Association (OCA)",
|
||||||
'website': 'https://github.com/OCA/server-env',
|
"website": "https://github.com/OCA/server-env",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'depends': [
|
"depends": [
|
||||||
'point_of_sale',
|
"point_of_sale",
|
||||||
'server_environment',
|
"server_environment",
|
||||||
],
|
],
|
||||||
'data': [
|
"data": [
|
||||||
'views/templates.xml',
|
"views/templates.xml",
|
||||||
'views/view_pos_config.xml',
|
"views/view_pos_config.xml",
|
||||||
],
|
],
|
||||||
'qweb': [
|
"qweb": [
|
||||||
'static/src/xml/pos_environment.xml',
|
"static/src/xml/pos_environment.xml",
|
||||||
],
|
],
|
||||||
'installable': True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,44 +2,49 @@
|
||||||
# @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 odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
from odoo.addons.server_environment import serv_config
|
from odoo.addons.server_environment import serv_config
|
||||||
|
|
||||||
|
|
||||||
class PosConfig(models.Model):
|
class PosConfig(models.Model):
|
||||||
_inherit = 'pos.config'
|
_inherit = "pos.config"
|
||||||
|
|
||||||
# Columns section
|
# Columns section
|
||||||
receipt_environment_header = fields.Text(
|
receipt_environment_header = fields.Text(
|
||||||
string='Receipt Environment Header',
|
string="Receipt Environment Header",
|
||||||
compute='_compute_receipt_environment_header')
|
compute="_compute_receipt_environment_header",
|
||||||
|
)
|
||||||
|
|
||||||
receipt_environment_footer = fields.Text(
|
receipt_environment_footer = fields.Text(
|
||||||
string='Receipt Environment Footer',
|
string="Receipt Environment Footer",
|
||||||
compute='_compute_receipt_environment_footer')
|
compute="_compute_receipt_environment_footer",
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_receipt_environment_header(self):
|
def _compute_receipt_environment_header(self):
|
||||||
for config in self:
|
for config in self:
|
||||||
config.receipt_environment_header =\
|
config.receipt_environment_header = self._get_receipt_environment_part(
|
||||||
self._get_receipt_environment_part('header')
|
"header"
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_receipt_environment_footer(self):
|
def _compute_receipt_environment_footer(self):
|
||||||
for config in self:
|
for config in self:
|
||||||
config.receipt_environment_footer =\
|
config.receipt_environment_footer = self._get_receipt_environment_part(
|
||||||
self._get_receipt_environment_part('footer')
|
"footer"
|
||||||
|
)
|
||||||
|
|
||||||
@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 = []
|
line_list = []
|
||||||
if serv_config.has_section(section_name):
|
if serv_config.has_section(section_name):
|
||||||
# Parse each line
|
# Parse each line
|
||||||
for item in serv_config.items(section_name):
|
for item in serv_config.items(section_name):
|
||||||
if '__' not in item[0]:
|
if "__" not in item[0]:
|
||||||
# Universal line
|
# Universal line
|
||||||
line_list.append(item[1])
|
line_list.append(item[1])
|
||||||
elif '__%s' % (self.env.user.lang) in item[0]:
|
elif "__%s" % (self.env.user.lang) in item[0]:
|
||||||
# depend of the language
|
# depend of the language
|
||||||
line_list.append(item[1])
|
line_list.append(item[1])
|
||||||
return '\n'.join(line_list)
|
return "\n".join(line_list)
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,18 @@
|
||||||
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).
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
odoo.define('pos_environment.models', function (require) {
|
odoo.define("pos_environment.models", function (require) {
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
var models = require('point_of_sale.models');
|
var models = require("point_of_sale.models");
|
||||||
|
|
||||||
var order_super = models.Order.prototype;
|
var order_super = models.Order.prototype;
|
||||||
|
|
||||||
models.Order = models.Order.extend({
|
models.Order = models.Order.extend({
|
||||||
export_for_printing: function () {
|
export_for_printing: function () {
|
||||||
var res = order_super.export_for_printing.apply(this, arguments);
|
var res = order_super.export_for_printing.apply(this, arguments);
|
||||||
res.receipt_environment_header =
|
res.receipt_environment_header = this.pos.config.receipt_environment_header;
|
||||||
this.pos.config.receipt_environment_header;
|
res.receipt_environment_footer = this.pos.config.receipt_environment_footer;
|
||||||
res.receipt_environment_footer =
|
|
||||||
this.pos.config.receipt_environment_footer;
|
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@
|
||||||
<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'>
|
||||||
<t t-foreach="widget.pos.config.receipt_environment_header.split('\n')" t-as="line">
|
<t
|
||||||
|
t-foreach="widget.pos.config.receipt_environment_header.split('\n')"
|
||||||
|
t-as="line"
|
||||||
|
>
|
||||||
<t t-esc="line" />
|
<t t-esc="line" />
|
||||||
<br />
|
<br />
|
||||||
</t>
|
</t>
|
||||||
|
|
@ -19,7 +22,10 @@
|
||||||
<t t-if="widget.pos.config.receipt_environment_footer">
|
<t t-if="widget.pos.config.receipt_environment_footer">
|
||||||
<br />
|
<br />
|
||||||
<div style='text-align:center'>
|
<div style='text-align:center'>
|
||||||
<t t-foreach="widget.pos.config.receipt_environment_footer.split('\n')" t-as="line">
|
<t
|
||||||
|
t-foreach="widget.pos.config.receipt_environment_footer.split('\n')"
|
||||||
|
t-as="line"
|
||||||
|
>
|
||||||
<t t-esc="line" />
|
<t t-esc="line" />
|
||||||
<br />
|
<br />
|
||||||
</t>
|
</t>
|
||||||
|
|
@ -35,7 +41,10 @@
|
||||||
<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'>
|
||||||
<t t-foreach="widget.pos.config.receipt_environment_header.split('\n')" t-as="line">
|
<t
|
||||||
|
t-foreach="widget.pos.config.receipt_environment_header.split('\n')"
|
||||||
|
t-as="line"
|
||||||
|
>
|
||||||
<t t-esc="line" />
|
<t t-esc="line" />
|
||||||
<br />
|
<br />
|
||||||
</t>
|
</t>
|
||||||
|
|
@ -47,7 +56,10 @@
|
||||||
<t t-if="widget.pos.config.receipt_environment_footer">
|
<t t-if="widget.pos.config.receipt_environment_footer">
|
||||||
<br />
|
<br />
|
||||||
<div style='text-align:center'>
|
<div style='text-align:center'>
|
||||||
<t t-foreach="widget.pos.config.receipt_environment_footer.split('\n')" t-as="line">
|
<t
|
||||||
|
t-foreach="widget.pos.config.receipt_environment_footer.split('\n')"
|
||||||
|
t-as="line"
|
||||||
|
>
|
||||||
<t t-esc="line" />
|
<t t-esc="line" />
|
||||||
<br />
|
<br />
|
||||||
</t>
|
</t>
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,14 @@ 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).
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<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">
|
||||||
<script type="text/javascript" src="/pos_environment/static/src/js/models.js"></script>
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/pos_environment/static/src/js/models.js"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../pos_environment
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue