Skip to content

Commit

Permalink
[IMP] pos_environment: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain authored and OCA-git-bot committed Jan 2, 2024
1 parent e2ebd44 commit ed4cb66
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 55 deletions.
32 changes: 16 additions & 16 deletions pos_environment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# @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.1',
'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',
"name": "Point of Sale - Custom Bill by Environment",
"summary": "Custom messages on the bill depending on the environment",
"version": "12.0.1.0.1",
"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',
"data": [
"views/templates.xml",
"views/view_pos_config.xml",
],
'qweb': [
'static/src/xml/pos_environment.xml',
"qweb": [
"static/src/xml/pos_environment.xml",
],
'installable': True,
"installable": True,
}
31 changes: 18 additions & 13 deletions pos_environment/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,49 @@
# @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'
_inherit = "pos.config"

# Columns section
receipt_environment_header = fields.Text(
string='Receipt Environment Header',
compute='_compute_receipt_environment_header')
string="Receipt Environment Header",
compute="_compute_receipt_environment_header",
)

receipt_environment_footer = fields.Text(
string='Receipt Environment Footer',
compute='_compute_receipt_environment_footer')
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')
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')
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
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]:
if "__" not in item[0]:
# Universal line
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
line_list.append(item[1])
return '\n'.join(line_list)
return "\n".join(line_list)
12 changes: 5 additions & 7 deletions pos_environment/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*****************************************************************************/

odoo.define('pos_environment.models', function (require) {
'use strict';
odoo.define("pos_environment.models", function (require) {
"use strict";

var models = require('point_of_sale.models');
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;
res.receipt_environment_header = this.pos.config.receipt_environment_header;
res.receipt_environment_footer = this.pos.config.receipt_environment_footer;
return res;
},
});
Expand Down
30 changes: 21 additions & 9 deletions pos_environment/static/src/xml/pos_environment.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<template>

<!-- Non Proxy Bill -->
Expand All @@ -7,8 +7,11 @@
<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"/>
<t
t-foreach="widget.pos.config.receipt_environment_header.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br />
</t>
</div>
Expand All @@ -19,8 +22,11 @@
<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"/>
<t
t-foreach="widget.pos.config.receipt_environment_footer.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br />
</t>
</div>
Expand All @@ -35,8 +41,11 @@
<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"/>
<t
t-foreach="widget.pos.config.receipt_environment_header.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br />
</t>
</div>
Expand All @@ -47,8 +56,11 @@
<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"/>
<t
t-foreach="widget.pos.config.receipt_environment_footer.split('\n')"
t-as="line"
>
<t t-esc="line" />
<br />
</t>
</div>
Expand Down
8 changes: 5 additions & 3 deletions pos_environment/views/templates.xml
Original file line number Diff line number Diff line change
@@ -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)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

<template id="point_of_sale_assets" inherit_id="point_of_sale.index">
<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>
</template>

Expand Down
14 changes: 7 additions & 7 deletions pos_environment/views/view_pos_config.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2013 - 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>

<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="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">
<xpath expr="//sheet" position="inside">
<h2 name="order">Environment Settings</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="receipt_environment_header"/>
<label for="receipt_environment_header" />
<div class="text-muted">
<field name="receipt_environment_header"/>
<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"/>
<label for="receipt_environment_footer" />
<div class="text-muted">
<field name="receipt_environment_footer"/>
<field name="receipt_environment_footer" />
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions setup/pos_environment/odoo/addons/pos_environment
6 changes: 6 additions & 0 deletions setup/pos_environment/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit ed4cb66

Please sign in to comment.