diff --git a/multi_currency_payment_in_pos/models/pos_session.py b/multi_currency_payment_in_pos/models/pos_session.py index ce85b5870..9e5ad03b9 100644 --- a/multi_currency_payment_in_pos/models/pos_session.py +++ b/multi_currency_payment_in_pos/models/pos_session.py @@ -43,8 +43,7 @@ class PosSession(models.Model): """Retrieve currency information for the POS session's user interface. """ result = super()._get_pos_ui_res_currency(params) - pp_search_params = params.get('params', {}).get('search_params', {}) - currency_params = self.env['res.currency'].search_read( - **pp_search_params) + currencies = self.config_id.currency_ids + currency_params = self.env['res.currency'].search_read([('id', 'in', currencies.ids)]) result['currency_params'] = currency_params return result diff --git a/multi_currency_payment_in_pos/models/res_config_settings.py b/multi_currency_payment_in_pos/models/res_config_settings.py index 63732e44a..81e33ccbe 100644 --- a/multi_currency_payment_in_pos/models/res_config_settings.py +++ b/multi_currency_payment_in_pos/models/res_config_settings.py @@ -30,13 +30,10 @@ class ResConfigSettings(models.TransientModel): string="Currencies", related="pos_config_id.currency_ids", readonly=False, - help="The list of currencies supported by" - " this Point of Sale " - "configuration.") + help="The list of currencies supported by this Point of Sale configuration.") enable_currency = fields.Boolean(string="Enable Currency", config_parameter="pos.enable_currency", - help="Enable or disable currency" - " for this POS configuration.") + help="Enable or disable currency for this POS configuration.") @api.onchange('enable_currency') def _onchange_value(self): diff --git a/multi_currency_payment_in_pos/static/src/js/pos_multicurrency.js b/multi_currency_payment_in_pos/static/src/js/pos_multicurrency.js index 83a494200..8a1e73f18 100644 --- a/multi_currency_payment_in_pos/static/src/js/pos_multicurrency.js +++ b/multi_currency_payment_in_pos/static/src/js/pos_multicurrency.js @@ -12,6 +12,9 @@ odoo.define('POS_multi_currency.MultiCurrency', function(require) { const PaymentScreenMultiCurrency = PaymentScreen => class extends PaymentScreen { setup() { super.setup(); + current_currency = { + rate: 1, + }; useListener('multi-payment-line', this.multi_currency_payment_line); var currency = [] onMounted(this.enable_multi_currency) @@ -68,6 +71,7 @@ odoo.define('POS_multi_currency.MultiCurrency', function(require) { } //Adding entered currency amount in payment line. async multi_currency_payment_line(ev){ + if(this.env.pos.config.enable_multicurrency == true){ var amount_val = parseFloat($('.multicurrency_input').val()) var total_val var remaining_val @@ -99,6 +103,7 @@ odoo.define('POS_multi_currency.MultiCurrency', function(require) { $('.multicurrency_input').css({'border':'1.5px solid red'}) } } + } } //For deleting payment line. deletePaymentLine(event) { @@ -108,13 +113,17 @@ odoo.define('POS_multi_currency.MultiCurrency', function(require) { } //Function for updating the payment line dynamically _updateSelectedPaymentline(){ - super._updateSelectedPaymentline(...arguments); - var change_amount=this.selectedPaymentLine.amount*current_currency.rate - this.selectedPaymentLine.converted_currency = { - 'name': current_currency.display_name, - 'symbol': current_currency.symbol, - 'amount': change_amount - } + super._updateSelectedPaymentline(...arguments); + if(this.env.pos.config.enable_multicurrency == true){ + if (this.selectedPaymentLine) { + var change_amount = this.selectedPaymentLine.amount * current_currency.rate; + this.selectedPaymentLine.converted_currency = { + 'name': current_currency.display_name, + 'symbol': current_currency.symbol, + 'amount': change_amount + }; + } + } } }; Registries.Component.extend(PaymentScreen, PaymentScreenMultiCurrency);