diff --git a/l10n_mx_edi_extends/__init__.py b/l10n_mx_edi_extends/__init__.py new file mode 100644 index 0000000..5305644 --- /dev/null +++ b/l10n_mx_edi_extends/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models \ No newline at end of file diff --git a/l10n_mx_edi_extends/__manifest__.py b/l10n_mx_edi_extends/__manifest__.py new file mode 100644 index 0000000..8e5ec6f --- /dev/null +++ b/l10n_mx_edi_extends/__manifest__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Part of Ktrine. See LICENSE file for full copyright and licensing details. + +{ + 'name': 'EDI Payment Extension', + 'version': '12.0.0.0', + 'depends': [ + 'l10n_mx_edi' + ], + 'external_dependencies': {}, + 'author': 'Eduwebgroup', + 'website': 'https://www.eduwebgroup.com', + 'summary': 'EDI Payment Extension', + 'description': """ + EDI Payment Extension + """, + 'category': 'Hidden', + 'data': [ + 'views/payment_acquirer_views.xml', + ], + 'qweb': [], + 'css': [], + 'images': [], + 'demo': [], + 'installable': True, + 'auto_install': False, + 'application': True, +} diff --git a/l10n_mx_edi_extends/models/__init__.py b/l10n_mx_edi_extends/models/__init__.py new file mode 100644 index 0000000..8bf266c --- /dev/null +++ b/l10n_mx_edi_extends/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import payment_acquirer +from . import payment_transaction \ No newline at end of file diff --git a/l10n_mx_edi_extends/models/payment_acquirer.py b/l10n_mx_edi_extends/models/payment_acquirer.py new file mode 100644 index 0000000..773226a --- /dev/null +++ b/l10n_mx_edi_extends/models/payment_acquirer.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ + + +class PaymentAcquirer(models.Model): + ###################### + # Private attributes # + ###################### + _inherit = "payment.acquirer" + ################### + # Default methods # + ################### + + ###################### + # Fields declaration # + ###################### + l10n_mx_edi_payment_method_id = fields.Many2one(string="Payment Way", + comodel_name="l10n_mx_edi.payment.method") + + ############################## + # Compute and search methods # + ############################## + + ############################ + # Constrains and onchanges # + ############################ + + ######################### + # CRUD method overrides # + ######################### + + ################## + # Action methods # + ################## + + #################### + # Business methods # + #################### + \ No newline at end of file diff --git a/l10n_mx_edi_extends/models/payment_transaction.py b/l10n_mx_edi_extends/models/payment_transaction.py new file mode 100644 index 0000000..1348793 --- /dev/null +++ b/l10n_mx_edi_extends/models/payment_transaction.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ + + +class PaymentTransaction(models.Model): + ###################### + # Private attributes # + ###################### + _inherit = "payment.transaction" + ################### + # Default methods # + ################### + + ###################### + # Fields declaration # + ###################### + + ############################## + # Compute and search methods # + ############################## + + ############################ + # Constrains and onchanges # + ############################ + + ######################### + # CRUD method overrides # + ######################### + + ################## + # Action methods # + ################## + + #################### + # Business methods # + #################### + @api.multi + def _prepare_account_payment_vals(self): + self.ensure_one() + res = super(PaymentTransaction, self)._prepare_account_payment_vals() + res["l10n_mx_edi_payment_method_id"] = self.acquirer_id.l10n_mx_edi_payment_method_id.id if self.acquirer_id.l10n_mx_edi_payment_method_id else False, + return res \ No newline at end of file diff --git a/l10n_mx_edi_extends/views/payment_acquirer_views.xml b/l10n_mx_edi_extends/views/payment_acquirer_views.xml new file mode 100644 index 0000000..5170093 --- /dev/null +++ b/l10n_mx_edi_extends/views/payment_acquirer_views.xml @@ -0,0 +1,15 @@ + + + + + payment.acquirer.view.form.inherit + payment.acquirer + + + + + + + + + diff --git a/payment_affipay/models/payment.py b/payment_affipay/models/payment.py index 8f9ee73..41860f2 100644 --- a/payment_affipay/models/payment.py +++ b/payment_affipay/models/payment.py @@ -211,11 +211,12 @@ def _affipay_ecommerce_request(self, url, eager_refresh=False, retries=2, **kwar "Affipay: Retrying request on %s. (%i retries left)" % (url, retries)) retries -= 1 return self._affipay_ecommerce_request(url, retries=retries, **kwargs) + raise e err = res_json.get("error", "Error") err_code = err.get("httpStatusCode", 400) err_description = err.get( "description", "Something is wrong with the request") - raise ValidationError("affipay Error: %s %s" % (err_code, err_description)) + raise AffipayError("affipay Error: %s %s" % (err_code, err_description)) def _affipay_refresh_access_token(self): self.ensure_one() @@ -226,7 +227,7 @@ def _affipay_refresh_access_token(self): }) if not data.get("access_token"): _logger.error(json.dumps(data)) - raise ValidationError("No access token given.") + raise AffipayError("No access token given.") self.affipay_access_token = data.get("access_token") return self.affipay_access_token diff --git a/payment_affipay/views/payment_affipay_templates.xml b/payment_affipay/views/payment_affipay_templates.xml index 4869766..f105aa6 100644 --- a/payment_affipay/views/payment_affipay_templates.xml +++ b/payment_affipay/views/payment_affipay_templates.xml @@ -20,7 +20,7 @@
- +