[FIX] payment_*: reset payment acquirers to default on uninstall
The `payment` module introduces a certain amount of payment acquirers, each one corresponding to a `payment_` module. When a `payment_` module is installed, this data is updated so that payments done with the corresponding acquirer change in behaviour using the provider installed by the `payment_` module. When a `payment_` module is uninstalled, this data should be reset to default, more especifically the `view_template_id` and the `provider` fields of `payment.acquirer`. This was not possible before this commit, and more importantly it would make the uninstallation of such `payment_` module impossible as the `view_template_id` is a required m2o ondelete='set null', which will make the registry crash. Even if the former wasn't a problem, the provider field would remain set to a non-existing selection option, which would make the registry crash (eventually, when checking a record with such a selection option). With this commit, we reset these fields to their default value upon module uninstall. In 13, the issue with `view_template_id` should be fixed, as required m2o that are ondelete='set null' are no longer possible. As for the provider Selection field, a fix should arrive in master soon. opw-2225333 closes odoo/odoo#48916 X-original-commit: 4f0c1c1bfd71dd1ff6793d0a91b49984c54d1351 Signed-off-by: Raphael Collet (rco) <rco@openerp.com> Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
from . import models
|
||||
from . import controllers
|
||||
from . import wizards
|
||||
|
||||
|
||||
def reset_payment_provider(cr, registry, provider):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
acquirers = env['payment.acquirer'].search([('provider', '=', provider)])
|
||||
acquirers.write({
|
||||
'view_template_id': acquirers._get_default_view_template_id().id,
|
||||
'provider': 'manual',
|
||||
})
|
||||
|
||||
@@ -4,3 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'adyen')
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,8 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'authorize')
|
||||
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'buckaroo')
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'ogone')
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'paypal')
|
||||
|
||||
@@ -16,4 +16,5 @@
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'payumoney')
|
||||
|
||||
@@ -18,4 +18,5 @@
|
||||
],
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'sips')
|
||||
|
||||
@@ -22,4 +22,5 @@ payments acquirer using Worldline SIPS.""",
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'stripe')
|
||||
|
||||
@@ -16,4 +16,5 @@
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
from . import models
|
||||
from . import controllers
|
||||
from odoo.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
from odoo.addons.payment import reset_payment_provider
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
reset_payment_provider(cr, registry, 'transfer')
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user