Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions payment_lyra/models/payment_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _get_compatible_providers(self, *args, currency_id=None, **kwargs):
@api.model
def multi_add(self, filename, noupdate):
if (constants.LYRA_PLUGIN_FEATURES.get('multi') == True):
module_upgrade = request.env['ir.module.module'].search([('state', '=', 'to upgrade'), ('name', '=', 'payment_lyra')])
module_upgrade = self.env['ir.module.module'].search([('state', '=', 'to upgrade'), ('name', '=', 'payment_lyra')])
file = path.join(path.dirname(path.dirname(path.abspath(__file__)))) + filename
mode = 'update' if module_upgrade else 'init'
convert_xml_import(self.env, 'payment_lyra', file, None, mode, noupdate)
Expand Down Expand Up @@ -272,7 +272,7 @@ def lyra_form_generate_values(self, values):
return lyra_tx_values

def lyra_generate_values_from_order(self, data):
sale_order = request.env['sale.order'].sudo().search([('id', '=', data['order_id'])]).exists()
sale_order = self.env['sale.order'].sudo().search([('id', '=', data['order_id'])]).exists()

currency = self._lyra_get_currency(data['currency_id'])
amount = float(sale_order.amount_total)
Expand Down Expand Up @@ -410,7 +410,7 @@ def _lyra_get_embedded_payment_means(self):

def _lyra_get_currency(self, currency_id):
# Give the iso and the number of decimal toward the smallest monetary unit from the id of the currency.
currency_name = tools.find_currency(self.env['res.currency'].search([('id', '=', currency_id)]).exists().name)
currency_name = tools.find_currency(self.env['res.currency'].search([('id', '=', currency_id)]).exists().name)
for currency in constants.LYRA_CURRENCIES:
if currency[1] == str(currency_name):
return (currency[0], currency[2])
Expand All @@ -420,7 +420,7 @@ def _lyra_get_currency(self, currency_id):
def _lyra_get_inline_form_values(
self, amount, currency, partner_id, is_validation, payment_method_sudo, sale_order_id, **kwargs
):
sale_order = request.env['sale.order'].sudo().search([('id', '=', sale_order_id)]).exists()
sale_order = self.env['sale.order'].sudo().search([('id', '=', sale_order_id)]).exists()
values = {
"provider_id": self.id,
"provider_code" : "lyra",
Expand All @@ -447,4 +447,4 @@ def _should_build_inline_form(self, is_validation=True):

return False

return super()._should_build_inline_form(is_validation=True)
return super()._should_build_inline_form(is_validation=True)
4 changes: 2 additions & 2 deletions payment_lyra/views/payment_lyra_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</template>

<template id="lyra_inline_embedded">
<t t-set="payment_provider_model" t-value="request.env['payment.provider'].search([('code', '=', 'lyra')])[0]" />
<t t-set="payment_provider_model" t-value="request.env['payment.provider'].sudo().search([('code', '=', 'lyra')])[0]" />
<t t-set="inline_form_values"
t-value="payment_provider_model._lyra_get_inline_form_values(
amount,
Expand Down Expand Up @@ -98,4 +98,4 @@
<div id="lyra-embedded-wrapper"></div>
</body>
</template>
</odoo>
</odoo>