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.
"""
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

7
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):

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 {
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);

Loading…
Cancel
Save