From e032acc44eb3e4ef69b8d178cf365f481f9618d2 Mon Sep 17 00:00:00 2001 From: lejeune quentin Date: Wed, 19 Oct 2022 11:08:09 +0000 Subject: [PATCH] [IMP] point_of_sale: Add the possiblity to enable auto validate order Actually if the customer pay with a electronic payment method the order is automatically validated. With this commit we add the possibility to activate or not this functionality closes odoo/odoo#103569 Signed-off-by: Masereel Pierre --- addons/point_of_sale/models/pos_config.py | 1 + addons/point_of_sale/models/res_config_settings.py | 1 + .../src/js/Screens/PaymentScreen/PaymentScreen.js | 3 ++- .../point_of_sale/views/res_config_settings_views.xml | 11 +++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index c227c861656..0c4d8f69c01 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -173,6 +173,7 @@ class PosConfig(models.Model): "In the meantime, you can use the 'Load Customers' button to load partners from database.") limited_partners_amount = fields.Integer(default=100) partner_load_background = fields.Boolean(default=True) + auto_validate_terminal_payment = fields.Boolean(default=True, help="Automatically validates orders paid with a payment terminal.") @api.depends('payment_method_ids') def _compute_cash_control(self): diff --git a/addons/point_of_sale/models/res_config_settings.py b/addons/point_of_sale/models/res_config_settings.py index 09d5325acb8..ff162c92b38 100644 --- a/addons/point_of_sale/models/res_config_settings.py +++ b/addons/point_of_sale/models/res_config_settings.py @@ -100,6 +100,7 @@ class ResConfigSettings(models.TransientModel): pos_use_pricelist = fields.Boolean(related='pos_config_id.use_pricelist', readonly=False) pos_warehouse_id = fields.Many2one(related='pos_config_id.warehouse_id', readonly=False, string="Warehouse (PoS)") point_of_sale_use_ticket_qr_code = fields.Boolean(related='company_id.point_of_sale_use_ticket_qr_code', readonly=False) + pos_auto_validate_terminal_payment = fields.Boolean(related='pos_config_id.auto_validate_terminal_payment', readonly=False, string="Automatically validates orders paid with a payment terminal.") @api.model_create_multi def create(self, vals_list): diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js index 79cbf4c7c1b..c9dea799140 100644 --- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js @@ -396,7 +396,8 @@ odoo.define('point_of_sale.PaymentScreen', function (require) { // the current order is fully paid and due is zero. if ( this.currentOrder.is_paid() && - utils.float_is_zero(this.currentOrder.get_due(), this.env.pos.currency.decimal_places) + utils.float_is_zero(this.currentOrder.get_due(), this.env.pos.currency.decimal_places) && + this.env.pos.config.auto_validate_terminal_payment ) { this.trigger('validate-order'); } diff --git a/addons/point_of_sale/views/res_config_settings_views.xml b/addons/point_of_sale/views/res_config_settings_views.xml index 3cbbe07b377..47429c43044 100644 --- a/addons/point_of_sale/views/res_config_settings_views.xml +++ b/addons/point_of_sale/views/res_config_settings_views.xml @@ -397,6 +397,17 @@ +
+
+ +
+
+
+