From 2799d8b75f6330973e011c2a5a24249c2001e7a6 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Tue, 18 Jul 2023 11:21:48 +0000 Subject: [PATCH] [FIX] point_of_sale: Correctly set fiscal position on refunded order Current behavior: If you apply a fiscal position on a POS order, then refund it, the fiscal position is not applied on the refund order. Steps to reproduce: - Create a fiscal position that match 15% of taxes to 0% of taxes - Create a POS order with a product that has 15% of taxes - Apply the fiscal position on the order - Refund the order - Check the taxes on the refund order, they are not correct opw-3371028 closes odoo/odoo#132768 X-original-commit: 09dbf51e88ea76934634e1b2f4c0292e83f4c9e4 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Robin Engels (roen) --- addons/point_of_sale/i18n/point_of_sale.pot | 16 ++++++++++++++++ .../app/screens/ticket_screen/ticket_screen.js | 9 +++++++++ .../point_of_sale/static/src/app/store/models.js | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index 0772e943ce2..0cf10889e07 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -2383,6 +2383,13 @@ msgstr "" msgid "Fiscal Position" msgstr "" +#. module: point_of_sale +#. odoo-javascript +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 +#, python-format +msgid "Fiscal Position not found" +msgstr "" + #. module: point_of_sale #: model:ir.model.fields,field_description:point_of_sale.field_pos_config__fiscal_position_ids #: model:ir.model.fields,field_description:point_of_sale.field_res_config_settings__pos_fiscal_position_ids @@ -6392,6 +6399,15 @@ msgid "" "The fiscal data module encountered an error while receiving your order." msgstr "" +#. module: point_of_sale +#. odoo-javascript +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 +#, python-format +msgid "" +"The fiscal position used in the original order is not loaded. Make sure it " +"is loaded by adding it in the pos configuration." +msgstr "" + #. module: point_of_sale #. odoo-python #: code:addons/point_of_sale/models/pos_session.py:0 diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js index ba9c1423f83..6ecac76a537 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js @@ -261,6 +261,15 @@ export class TicketScreen extends Component { refundDetail.destinationOrderUid = destinationOrder.uid; } + //Add a check too see if the fiscal position exist in the pos + if (order.fiscal_position_not_found) { + this.showPopup('ErrorPopup', { + title: this.env._t('Fiscal Position not found'), + body: this.env._t('The fiscal position used in the original order is not loaded. Make sure it is loaded by adding it in the pos configuration.') + }); + return; + } + destinationOrder.fiscal_position = order.fiscal_position; // Set the partner to the destinationOrder. this.setPartnerToRefundOrder(partner, destinationOrder); diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index a42442723ad..be1be19e4b8 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -1331,7 +1331,8 @@ export class Order extends PosModel { if (fiscal_position) { this.fiscal_position = fiscal_position; } else { - console.error("ERROR: trying to load a fiscal position not available in the pos"); + this.fiscal_position_not_found = true; + console.error('ERROR: trying to load a fiscal position not available in the pos'); } }