Skip to content

Commit

Permalink
[IMP] tg_pos: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
em230418 committed Oct 28, 2024
1 parent 567d37a commit 536d1eb
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 66 deletions.
1 change: 1 addition & 0 deletions setup/tg_pos/odoo/addons/tg_pos
6 changes: 6 additions & 0 deletions setup/tg_pos/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,
)
11 changes: 4 additions & 7 deletions tg_pos/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
"version": "14.0.0.1.0",
"author": "IT-Projects LLC, Eugene Molotov",
"support": "[email protected]",
"website": "https://www.it-projects.info",
"website": "https://github.com/it-projects-llc/tg-addons",
"license": "LGPL-3",
"depends": [
'point_of_sale',
"point_of_sale",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
"security/point_of_sale_security.xml",
'views/assets.xml',
],
"demo": [
"views/assets.xml",
],
"demo": [],
"qweb": [
"static/src/xml/Screens/PaymentScreen/PaymentScreen.xml",
"static/src/xml/Screens/PaymentScreen/PaymentScreenNumpad.xml",
"static/src/xml/Screens/PaymentScreen/PSNumpadInputButton.xml",
"static/src/xml/Screens/ProductScreen/ActionpadWidget.xml",
],

"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,

"auto_install": False,
"installable": True,
}
10 changes: 8 additions & 2 deletions tg_pos/security/point_of_sale_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
<record id="group_show_customer_button" model="res.groups">
<field name="name">Point of Sale - Show customer button</field>
<field name="category_id" ref="base.module_category_usability" />
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>

<record id="group_show_pm_in_payment_screen" model="res.groups">
<field name="name">Point of Sale - Show +/- in payment screen</field>
<field name="category_id" ref="base.module_category_usability" />
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>
</odoo>
57 changes: 28 additions & 29 deletions tg_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
odoo.define("tg_pos.PaymentScreen", function (require) {
"use strict";

const { useBarcodeReader } = require('point_of_sale.custom_hooks');
const {useBarcodeReader} = require("point_of_sale.custom_hooks");
const PaymentScreen = require("point_of_sale.PaymentScreen");
const Registries = require("point_of_sale.Registries");

const TGPaymentScreen = (x) => class extends x {
constructor() {
super(...arguments);
useBarcodeReader({
client: this._barcodeClientAction,
error: this._barcodeErrorAction,
});

}
_barcodeClientAction(code) {
const partner = this.env.pos.db.get_partner_by_barcode(code.code);
if (partner) {
if (this.currentOrder.get_client() !== partner) {
this.currentOrder.set_client(partner);
this.currentOrder.updatePricelist(partner);
const TGPaymentScreen = (x) =>
class extends x {
constructor() {
super(...arguments);
useBarcodeReader({
client: this._barcodeClientAction,
error: this._barcodeErrorAction,
});
}
_barcodeClientAction(code) {
const partner = this.env.pos.db.get_partner_by_barcode(code.code);
if (partner) {
if (this.currentOrder.get_client() !== partner) {
this.currentOrder.set_client(partner);
this.currentOrder.updatePricelist(partner);
}
return true;
}
return true;
this._barcodeErrorAction(code);
return false;
}
this._barcodeErrorAction(code);
return false;
}

_barcodeErrorAction(code) {
this.showPopup('ErrorBarcodePopup', { code: this._codeRepr(code) });
}
_barcodeErrorAction(code) {
this.showPopup("ErrorBarcodePopup", {code: this._codeRepr(code)});
}

_codeRepr(code) {
if (code.code.length > 32) {
return code.code.substring(0, 29) + '...';
} else {
_codeRepr(code) {
if (code.code.length > 32) {
return code.code.substring(0, 29) + "...";
}
return code.code;
}
}
};
};

Registries.Component.extend(PaymentScreen, TGPaymentScreen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ odoo.define("tg_pos.PaymentScreenNumpad", function (require) {
const PaymentScreenNumpad = require("point_of_sale.PaymentScreenNumpad");
const Registries = require("point_of_sale.Registries");

const TGPaymentScreenNumpad = (PaymentScreenNumpad) => class extends PaymentScreenNumpad {
get hasMinusControlRights() {
return this.env.pos.get_cashier().hasGroupShowPMInPaymentScreen;
}
};
const TGPaymentScreenNumpad = (PaymentScreenNumpad) =>
class extends PaymentScreenNumpad {
get hasMinusControlRights() {
return this.env.pos.get_cashier().hasGroupShowPMInPaymentScreen;
}
};

Registries.Component.extend(PaymentScreenNumpad, TGPaymentScreenNumpad);

Expand Down
10 changes: 7 additions & 3 deletions tg_pos/static/src/js/models.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
odoo.define('tg_pos.models', function (require) {
odoo.define("tg_pos.models", function (require) {
"use strict";

var models = require("point_of_sale.models");
Expand All @@ -12,10 +12,14 @@ odoo.define('tg_pos.models', function (require) {
);
pos_cashier.hasGroupShowCustomerButton =
cashier &&
cashier.groups_id.includes(this.env.pos.config.group_show_customer_button_id[0]);
cashier.groups_id.includes(
this.env.pos.config.group_show_customer_button_id[0]
);
pos_cashier.hasGroupShowPMInPaymentScreen =
cashier &&
cashier.groups_id.includes(this.env.pos.config.group_show_pm_in_payment_screen_id[0]);
cashier.groups_id.includes(
this.env.pos.config.group_show_pm_in_payment_screen_id[0]
);
return pos_cashier;
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="PSNumpadInputButton" t-inherit="point_of_sale.PSNumpadInputButton" t-inherit-mode="extension" owl="1">
<t
t-name="PSNumpadInputButton"
t-inherit="point_of_sale.PSNumpadInputButton"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//button" position="attributes">
<attribute name="t-att-disabled">props.disabled</attribute>
</xpath>
</t>
</templates>
</templates>
17 changes: 13 additions & 4 deletions tg_pos/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="PaymentScreen" t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="extension" owl="1">
<t
t-name="PaymentScreen"
t-inherit="point_of_sale.PaymentScreen"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//div[hasclass('customer-button')]/div" position="attributes">
<attribute name="class" />
<attribute name="t-att-class">{'button': true, 'disable': !env.pos.get_cashier().hasGroupShowCustomerButton}</attribute>
<attribute name="t-att-disabled">env.pos.get_cashier().hasGroupShowCustomerButton ? '' : 'disabled'</attribute>
<attribute
name="t-att-class"
>{'button': true, 'disable': !env.pos.get_cashier().hasGroupShowCustomerButton}</attribute>
<attribute
name="t-att-disabled"
>env.pos.get_cashier().hasGroupShowCustomerButton ? '' : 'disabled'</attribute>
</xpath>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="PaymentScreenNumpad" t-inherit="point_of_sale.PaymentScreenNumpad" t-inherit-mode="extension" owl="1">
<xpath expr="//PSNumpadInputButton[contains(@value, '-')]" position="attributes">
<attribute name="disabled">!hasMinusControlRights ? 'disabled' : ''</attribute>
<t
t-name="PaymentScreenNumpad"
t-inherit="point_of_sale.PaymentScreenNumpad"
t-inherit-mode="extension"
owl="1"
>
<xpath
expr="//PSNumpadInputButton[contains(@value, '-')]"
position="attributes"
>
<attribute
name="disabled"
>!hasMinusControlRights ? 'disabled' : ''</attribute>
<attribute
name="t-att-class"
>{'disabled-mode': !hasMinusControlRights}</attribute>
</xpath>
</t>
</templates>
</templates>
17 changes: 13 additions & 4 deletions tg_pos/static/src/xml/Screens/ProductScreen/ActionpadWidget.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="ActionpadWidget" t-inherit="point_of_sale.ActionpadWidget" t-inherit-mode="extension" owl="1">
<t
t-name="ActionpadWidget"
t-inherit="point_of_sale.ActionpadWidget"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//button[hasclass('set-customer')]" position="attributes">
<attribute name="t-att-disabled">env.pos.get_cashier().hasGroupShowCustomerButton ? '' : 'disabled'</attribute>
<attribute name="t-att-class">{'decentered': isLongName, 'disable': !env.pos.get_cashier().hasGroupShowCustomerButton}</attribute>
<attribute
name="t-att-disabled"
>env.pos.get_cashier().hasGroupShowCustomerButton ? '' : 'disabled'</attribute>
<attribute
name="t-att-class"
>{'decentered': isLongName, 'disable': !env.pos.get_cashier().hasGroupShowCustomerButton}</attribute>
</xpath>
</t>
</templates>
14 changes: 10 additions & 4 deletions tg_pos/views/assets.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/tg_pos/static/src/css/pos.css" />
<script type="text/javascript" src="/tg_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js"></script>
<script type="text/javascript" src="/tg_pos/static/src/js/Screens/PaymentScreen/PaymentScreenNumpad.js"></script>
<script type="text/javascript" src="/tg_pos/static/src/js/models.js"></script>
<script
type="text/javascript"
src="/tg_pos/static/src/js/Screens/PaymentScreen/PaymentScreen.js"
/>
<script
type="text/javascript"
src="/tg_pos/static/src/js/Screens/PaymentScreen/PaymentScreenNumpad.js"
/>
<script type="text/javascript" src="/tg_pos/static/src/js/models.js" />
</xpath>
</template>
</odoo>

0 comments on commit 536d1eb

Please sign in to comment.