diff --git a/addons/l10n_be_pos_sale/__init__.py b/addons/l10n_be_pos_sale/__init__.py new file mode 100644 index 00000000000..a449448a63f --- /dev/null +++ b/addons/l10n_be_pos_sale/__init__.py @@ -0,0 +1 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. diff --git a/addons/l10n_be_pos_sale/__manifest__.py b/addons/l10n_be_pos_sale/__manifest__.py new file mode 100644 index 00000000000..822b22d8420 --- /dev/null +++ b/addons/l10n_be_pos_sale/__manifest__.py @@ -0,0 +1,21 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + + +{ + 'name': 'l10n_be_pos_sale', + 'version': '1.0', + 'category': 'Hidden', + 'sequence': 6, + 'summary': 'Link module between pos_sale and l10n_be', + 'depends': ['pos_sale', 'l10n_be'], + 'auto_install': True, + 'assets': { + 'point_of_sale._assets_pos': [ + 'l10n_be_pos_sale/static/src/js/**/*', + ], + 'web.assets_tests': [ + 'l10n_be_pos_sale/static/tests/**/*', + ], + }, + 'license': 'LGPL-3', +} diff --git a/addons/l10n_be_pos_sale/i18n/l10n_be_pos_sale.pot b/addons/l10n_be_pos_sale/i18n/l10n_be_pos_sale.pot new file mode 100644 index 00000000000..6b600d52fa5 --- /dev/null +++ b/addons/l10n_be_pos_sale/i18n/l10n_be_pos_sale.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_be_pos_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-30 09:20+0000\n" +"PO-Revision-Date: 2023-10-30 09:20+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_be_pos_sale +#. odoo-javascript +#: code:addons/l10n_be_pos_sale/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "" +"If you do not invoice imported orders you will encounter issues in your " +"accounting. Especially in the EC Sale List report" +msgstr "" + +#. module: l10n_be_pos_sale +#. odoo-javascript +#: code:addons/l10n_be_pos_sale/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "This order needs to be invoiced" +msgstr "" diff --git a/addons/l10n_be_pos_sale/static/src/js/PaymentScreen.js b/addons/l10n_be_pos_sale/static/src/js/PaymentScreen.js new file mode 100644 index 00000000000..c12c450e0e4 --- /dev/null +++ b/addons/l10n_be_pos_sale/static/src/js/PaymentScreen.js @@ -0,0 +1,21 @@ +/** @odoo-module **/ + +import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; +import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; + +patch(PaymentScreen.prototype, { + toggleIsToInvoice() { + const has_origin_order = this.currentOrder.get_orderlines().some(line => line.sale_order_origin_id); + if(this.currentOrder.is_to_invoice() && this.pos.company.country && this.pos.company.country.code === "BE" && has_origin_order){ + this.popup.add(ErrorPopup, { + title: _t('This order needs to be invoiced'), + body: _t('If you do not invoice imported orders you will encounter issues in your accounting. Especially in the EC Sale List report'), + }); + } + else{ + super.toggleIsToInvoice(...arguments); + } + } +}); diff --git a/addons/l10n_be_pos_sale/static/src/js/models.js b/addons/l10n_be_pos_sale/static/src/js/models.js new file mode 100644 index 00000000000..acad385b6fa --- /dev/null +++ b/addons/l10n_be_pos_sale/static/src/js/models.js @@ -0,0 +1,14 @@ +/** @odoo-module **/ + +import { patch } from "@web/core/utils/patch"; +import { Order } from "@point_of_sale/app/store/models"; + +patch(Order.prototype, { + async pay() { + const has_origin_order = this.get_orderlines().some(line => line.sale_order_origin_id); + if (this.pos.company.country && this.pos.company.country.code === "BE" && has_origin_order) { + this.to_invoice = true; + } + return super.pay(...arguments); + } +}); diff --git a/addons/l10n_be_pos_sale/static/tests/tours/l10n_be_pos_sale_tour.js b/addons/l10n_be_pos_sale/static/tests/tours/l10n_be_pos_sale_tour.js new file mode 100644 index 00000000000..c57e735ce17 --- /dev/null +++ b/addons/l10n_be_pos_sale/static/tests/tours/l10n_be_pos_sale_tour.js @@ -0,0 +1,24 @@ +/** @odoo-module */ + +import * as ErrorPopup from "@point_of_sale/../tests/tours/helpers/ErrorPopupTourMethods"; +import * as PaymentScreen from "@point_of_sale/../tests/tours/helpers/PaymentScreenTourMethods"; +import * as ProductScreenPos from "@point_of_sale/../tests/tours/helpers/ProductScreenTourMethods"; +import * as ProductScreenSale from "@pos_sale/../tests/helpers/ProductScreenTourMethods"; +const ProductScreen = { ...ProductScreenPos, ...ProductScreenSale }; +import { registry } from "@web/core/registry"; + +registry.category("web_tour.tours").add("PosSettleOrderIsInvoice", { + test: true, + url: "/pos/ui", + steps: () => + [ + ProductScreen.confirmOpeningPopup(), + ProductScreen.clickQuotationButton(), + ProductScreen.selectFirstOrder(), + ProductScreen.clickPayButton(), + PaymentScreen.isInvoiceButtonChecked(), + PaymentScreen.clickInvoiceButton(), + PaymentScreen.isInvoiceButtonChecked(), + ErrorPopup.clickConfirm(), + ].flat(), +}); diff --git a/addons/l10n_be_pos_sale/tests/__init__.py b/addons/l10n_be_pos_sale/tests/__init__.py new file mode 100644 index 00000000000..bed27b0190d --- /dev/null +++ b/addons/l10n_be_pos_sale/tests/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_l10n_be_pos_sale diff --git a/addons/l10n_be_pos_sale/tests/test_l10n_be_pos_sale.py b/addons/l10n_be_pos_sale/tests/test_l10n_be_pos_sale.py new file mode 100644 index 00000000000..35bd2b973cd --- /dev/null +++ b/addons/l10n_be_pos_sale/tests/test_l10n_be_pos_sale.py @@ -0,0 +1,40 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import odoo + +from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon +from odoo import Command + +@odoo.tests.tagged('post_install_l10n', 'post_install', '-at_install') +class TestPoSSaleL10NBe(TestPointOfSaleHttpCommon): + + @classmethod + def setUpClass(cls, chart_template_ref='be_comp'): + super().setUpClass(chart_template_ref=chart_template_ref) + + def test_settle_order_is_invoice(self): + #Change company country to Belgium + self.env.user.company_id.country_id = self.env.ref('base.be') + + self.product_a = self.env['product.product'].create({ + 'name': 'Product A', + 'type': 'product', + 'list_price': 10, + 'taxes_id': False, + 'available_in_pos': True, + }) + + sale_order = self.env['sale.order'].create({ + 'partner_id': self.partner_a.id, + 'order_line': [Command.create({ + 'product_id': self.product_a.id, + 'product_uom_qty': 10, + 'product_uom': self.product_a.uom_id.id, + 'price_unit': 10, + 'tax_id': False, + })], + }) + + sale_order.action_confirm() + self.main_pos_config.open_ui() + self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PosSettleOrderIsInvoice', login="accountman") diff --git a/addons/point_of_sale/static/tests/tours/helpers/PaymentScreenTourMethods.js b/addons/point_of_sale/static/tests/tours/helpers/PaymentScreenTourMethods.js index 431d4230dac..e5ae5b147dc 100644 --- a/addons/point_of_sale/static/tests/tours/helpers/PaymentScreenTourMethods.js +++ b/addons/point_of_sale/static/tests/tours/helpers/PaymentScreenTourMethods.js @@ -254,3 +254,13 @@ export function pay(method, amount) { steps.push(...clickValidate()); return steps; } + +export function isInvoiceButtonChecked() { + return [ + { + content: 'check invoice button is checked', + trigger: '.js_invoice.highlight', + run: () => {}, + } + ] +}