diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/l10n_fr_pos_cert/static/src | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/l10n_fr_pos_cert/static/src')
4 files changed, 144 insertions, 0 deletions
diff --git a/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js b/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js new file mode 100644 index 00000000..ad6f0948 --- /dev/null +++ b/addons/l10n_fr_pos_cert/static/src/js/NumpadWidget.js @@ -0,0 +1,20 @@ +odoo.define('l10n_fr_pos_cert.NumpadWidget', function(require) { + 'use strict'; + + const NumpadWidget = require('point_of_sale.NumpadWidget'); + const Registries = require('point_of_sale.Registries'); + + const PosFrNumpadWidget = NumpadWidget => class extends NumpadWidget { + get hasPriceControlRights() { + if (this.env.pos.is_french_country()) { + return false; + } else { + return super.hasPriceControlRights; + } + } + }; + + Registries.Component.extend(NumpadWidget, PosFrNumpadWidget); + + return NumpadWidget; + }); diff --git a/addons/l10n_fr_pos_cert/static/src/js/PaymentScreen.js b/addons/l10n_fr_pos_cert/static/src/js/PaymentScreen.js new file mode 100644 index 00000000..1ec68f9b --- /dev/null +++ b/addons/l10n_fr_pos_cert/static/src/js/PaymentScreen.js @@ -0,0 +1,29 @@ +odoo.define('l10n_fr_pos_cert.PaymentScreen', function(require) { + + const PaymentScreen = require('point_of_sale.PaymentScreen'); + const Registries = require('point_of_sale.Registries'); + const session = require('web.session'); + + const PosFrPaymentScreen = PaymentScreen => class extends PaymentScreen { + async _postPushOrderResolve(order, order_server_ids) { + try { + if(this.env.pos.is_french_country()) { + let result = await this.rpc({ + model: 'pos.order', + method: 'search_read', + domain: [['id', 'in', order_server_ids]], + fields: ['l10n_fr_hash'], + context: session.user_context, + }); + order.set_l10n_fr_hash(result[0].l10n_fr_hash || false); + } + } finally { + return super._postPushOrderResolve(...arguments); + } + } + }; + + Registries.Component.extend(PaymentScreen, PosFrPaymentScreen); + + return PaymentScreen; +}); diff --git a/addons/l10n_fr_pos_cert/static/src/js/pos.js b/addons/l10n_fr_pos_cert/static/src/js/pos.js new file mode 100644 index 00000000..86dc047e --- /dev/null +++ b/addons/l10n_fr_pos_cert/static/src/js/pos.js @@ -0,0 +1,84 @@ +odoo.define('l10n_fr_pos_cert.pos', function (require) { +"use strict"; + +const { Gui } = require('point_of_sale.Gui'); +var models = require('point_of_sale.models'); +var rpc = require('web.rpc'); +var session = require('web.session'); +var core = require('web.core'); +var utils = require('web.utils'); + +var _t = core._t; +var round_di = utils.round_decimals; + +var _super_posmodel = models.PosModel.prototype; +models.PosModel = models.PosModel.extend({ + is_french_country: function(){ + var french_countries = ['FR', 'MF', 'MQ', 'NC', 'PF', 'RE', 'GF', 'GP', 'TF']; + if (!this.company.country) { + Gui.showPopup("ErrorPopup", { + 'title': _t("Missing Country"), + 'body': _.str.sprintf(_t('The company %s doesn\'t have a country set.'), this.company.name), + }); + return false; + } + return _.contains(french_countries, this.company.country.code); + }, + delete_current_order: function () { + if (this.is_french_country() && this.get_order().get_orderlines().length) { + Gui.showPopup("ErrorPopup", { + 'title': _t("Fiscal Data Module error"), + 'body': _t("Deleting of orders is not allowed."), + }); + } else { + _super_posmodel.delete_current_order.apply(this, arguments); + } + }, + + disallowLineQuantityChange() { + let result = _super_posmodel.disallowLineQuantityChange.bind(this)(); + return this.is_french_country() || result; + } +}); + + +var _super_order = models.Order.prototype; +models.Order = models.Order.extend({ + initialize: function() { + _super_order.initialize.apply(this,arguments); + this.l10n_fr_hash = this.l10n_fr_hash || false; + this.save_to_db(); + }, + export_for_printing: function() { + var result = _super_order.export_for_printing.apply(this,arguments); + result.l10n_fr_hash = this.get_l10n_fr_hash(); + return result; + }, + set_l10n_fr_hash: function (l10n_fr_hash){ + this.l10n_fr_hash = l10n_fr_hash; + }, + get_l10n_fr_hash: function() { + return this.l10n_fr_hash; + }, + wait_for_push_order: function() { + var result = _super_order.wait_for_push_order.apply(this,arguments); + result = Boolean(result || this.pos.is_french_country()); + return result; + } +}); + +var orderline_super = models.Orderline.prototype; +models.Orderline = models.Orderline.extend({ + can_be_merged_with: function(orderline) { + let order = this.pos.get_order(); + let lastId = order.orderlines.last().cid; + + if(this.pos.is_french_country() && (order.orderlines._byId[lastId].product.id !== orderline.product.id || order.orderlines._byId[lastId].quantity < 0)) { + return false; + } else { + return orderline_super.can_be_merged_with.apply(this, arguments); + } + } +}); + +}); diff --git a/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml b/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml new file mode 100644 index 00000000..bb77291a --- /dev/null +++ b/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates id="template" xml:space="preserve"> + <t t-name="OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension" owl="1"> + <xpath expr="//div[hasclass('pos-receipt-order-data')]" position="inside"> + <t t-if="receipt.l10n_fr_hash !== false"> + <br/> + <div style="word-wrap:break-word;"><t t-esc="receipt.l10n_fr_hash"/></div> + </t> + </xpath> + </t> +</templates> |
