[IMP] pos_environment: black, isort, prettier

This commit is contained in:
Sylvain LE GAL 2023-04-19 21:00:38 +02:00 committed by OCA-git-bot
parent e2ebd44de8
commit ed4cb66cae
8 changed files with 79 additions and 55 deletions

View File

@ -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,
} }

View File

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

View File

@ -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;
}, },
}); });

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<template> <template>
<!-- Non Proxy Bill --> <!-- Non Proxy Bill -->
@ -7,8 +7,11 @@
<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 t-esc="line"/> t-foreach="widget.pos.config.receipt_environment_header.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br /> <br />
</t> </t>
</div> </div>
@ -19,8 +22,11 @@
<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 t-esc="line"/> t-foreach="widget.pos.config.receipt_environment_footer.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br /> <br />
</t> </t>
</div> </div>
@ -35,8 +41,11 @@
<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 t-esc="line"/> t-foreach="widget.pos.config.receipt_environment_header.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br /> <br />
</t> </t>
</div> </div>
@ -47,8 +56,11 @@
<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 t-esc="line"/> t-foreach="widget.pos.config.receipt_environment_footer.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br /> <br />
</t> </t>
</div> </div>

View File

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<!-- <!--
Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) 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>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" ?>
<!-- <!--
Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) 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)
@ -6,26 +6,26 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
--> -->
<odoo> <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.pos_config_view_form"/> <field name="inherit_id" ref="point_of_sale.pos_config_view_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//sheet" position="inside"> <xpath expr="//sheet" position="inside">
<h2 name="order">Environment Settings</h2> <h2 name="order">Environment Settings</h2>
<div class="row mt16 o_settings_container"> <div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane"> <div class="o_setting_right_pane">
<label for="receipt_environment_header"/> <label for="receipt_environment_header" />
<div class="text-muted"> <div class="text-muted">
<field name="receipt_environment_header"/> <field name="receipt_environment_header" />
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane"> <div class="o_setting_right_pane">
<label for="receipt_environment_footer"/> <label for="receipt_environment_footer" />
<div class="text-muted"> <div class="text-muted">
<field name="receipt_environment_footer"/> <field name="receipt_environment_footer" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1 @@
../../../../pos_environment

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)