Browse Source

May 02: [FIX] Bug Fixed 'multi_currency_payment_in_pos'

pull/278/merge
RisvanaCybro 1 year ago
parent
commit
b679d97f9c
  1. 5
      multi_currency_payment_in_pos/models/pos_session.py
  2. 7
      multi_currency_payment_in_pos/models/res_config_settings.py
  3. 23
      multi_currency_payment_in_pos/static/src/js/pos_multicurrency.js

5
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. """Retrieve currency information for the POS session's user interface.
""" """
result = super()._get_pos_ui_res_currency(params) result = super()._get_pos_ui_res_currency(params)
pp_search_params = params.get('params', {}).get('search_params', {}) currencies = self.config_id.currency_ids
currency_params = self.env['res.currency'].search_read( currency_params = self.env['res.currency'].search_read([('id', 'in', currencies.ids)])
**pp_search_params)
result['currency_params'] = currency_params result['currency_params'] = currency_params
return result return result

7
multi_currency_payment_in_pos/models/res_config_settings.py

@ -30,13 +30,10 @@ class ResConfigSettings(models.TransientModel):
string="Currencies", string="Currencies",
related="pos_config_id.currency_ids", related="pos_config_id.currency_ids",
readonly=False, readonly=False,
help="The list of currencies supported by" help="The list of currencies supported by this Point of Sale configuration.")
" this Point of Sale "
"configuration.")
enable_currency = fields.Boolean(string="Enable Currency", enable_currency = fields.Boolean(string="Enable Currency",
config_parameter="pos.enable_currency", config_parameter="pos.enable_currency",
help="Enable or disable currency" help="Enable or disable currency for this POS configuration.")
" for this POS configuration.")
@api.onchange('enable_currency') @api.onchange('enable_currency')
def _onchange_value(self): def _onchange_value(self):

23
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 { const PaymentScreenMultiCurrency = PaymentScreen => class extends PaymentScreen {
setup() { setup() {
super.setup(); super.setup();
current_currency = {
rate: 1,
};
useListener('multi-payment-line', this.multi_currency_payment_line); useListener('multi-payment-line', this.multi_currency_payment_line);
var currency = [] var currency = []
onMounted(this.enable_multi_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. //Adding entered currency amount in payment line.
async multi_currency_payment_line(ev){ async multi_currency_payment_line(ev){
if(this.env.pos.config.enable_multicurrency == true){
var amount_val = parseFloat($('.multicurrency_input').val()) var amount_val = parseFloat($('.multicurrency_input').val())
var total_val var total_val
var remaining_val var remaining_val
@ -99,6 +103,7 @@ odoo.define('POS_multi_currency.MultiCurrency', function(require) {
$('.multicurrency_input').css({'border':'1.5px solid red'}) $('.multicurrency_input').css({'border':'1.5px solid red'})
} }
} }
}
} }
//For deleting payment line. //For deleting payment line.
deletePaymentLine(event) { deletePaymentLine(event) {
@ -108,13 +113,17 @@ odoo.define('POS_multi_currency.MultiCurrency', function(require) {
} }
//Function for updating the payment line dynamically //Function for updating the payment line dynamically
_updateSelectedPaymentline(){ _updateSelectedPaymentline(){
super._updateSelectedPaymentline(...arguments); super._updateSelectedPaymentline(...arguments);
var change_amount=this.selectedPaymentLine.amount*current_currency.rate if(this.env.pos.config.enable_multicurrency == true){
this.selectedPaymentLine.converted_currency = { if (this.selectedPaymentLine) {
'name': current_currency.display_name, var change_amount = this.selectedPaymentLine.amount * current_currency.rate;
'symbol': current_currency.symbol, this.selectedPaymentLine.converted_currency = {
'amount': change_amount 'name': current_currency.display_name,
} 'symbol': current_currency.symbol,
'amount': change_amount
};
}
}
} }
}; };
Registries.Component.extend(PaymentScreen, PaymentScreenMultiCurrency); Registries.Component.extend(PaymentScreen, PaymentScreenMultiCurrency);

Loading…
Cancel
Save