Skip to content

Commit

Permalink
[MIG] payment
Browse files Browse the repository at this point in the history
Co-Authored-By: Miquel Raïch <[email protected]>
  • Loading branch information
Yasaie and MiquelRForgeFlow committed Aug 9, 2020
1 parent ace5606 commit 7bded46
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 9 deletions.
36 changes: 28 additions & 8 deletions addons/payment/migrations/13.0.1.0/noupdate_changes.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<record id="payment_acquirer_adyen" model="payment.acquirer">
<field name="image" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/>
<!-- <field name="image" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/>-->
<field name="display_as">Credit Card (powered by Adyen)</field>
<field name="image_128" type="base64" file="payment_adyen/static/src/img/adyen_icon.png"/>
</record>
Expand All @@ -19,37 +19,57 @@
<li class="list-inline-item"><i class="fa fa-check"/>Embedded Credit Card Form</li>
</ul>
</field>
<field name="image" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/>
<!-- <field name="image" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/>-->
<field name="display_as">Credit Card (powered by Authorize)</field>
<field name="image_128" type="base64" file="payment_authorize/static/src/img/authorize_icon.png"/>
</record>
<record id="payment_acquirer_buckaroo" model="payment.acquirer">
<field name="image" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/>
<!-- <field name="image" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/>-->
<field name="display_as">Credit Card (powered by Buckaroo)</field>
<field name="image_128" type="base64" file="payment_buckaroo/static/src/img/buckaroo_icon.png"/>
</record>
<record id="payment_acquirer_ingenico" model="payment.acquirer">
<field name="description" type="html">
<p>
Ingenico Payment Services (formerly Ogone) supports a wide range of payment methods: credit cards, debit cards, bank transfers, Bancontact, iDeal, Giropay.
</p>
<ul class="list-inline">
<li class="list-inline-item"><i class="fa fa-check"/>Online Payment</li>
<li class="list-inline-item"><i class="fa fa-check"/>Payment Status Tracking</li>
<li class="list-inline-item"><i class="fa fa-check"/>Subscriptions</li>
<li class="list-inline-item"><i class="fa fa-check"/>Save Cards</li>
<li class="list-inline-item"><i class="fa fa-check"/>Embedded Credit Card Form</li>
</ul>
</field>
<!-- <field name="image" type="base64" file="payment_ogone/static/src/img/ogone_icon.png"/>-->
<field name="module_id" ref="base.module_payment_ingenico"/>
<field name="payment_icon_ids"
eval="[(6, 0, [ref(&quot;payment.payment_icon_cc_ideal&quot;), ref(&quot;payment.payment_icon_cc_bancontact&quot;), ref(&quot;payment.payment_icon_cc_maestro&quot;), ref(&quot;payment.payment_icon_cc_mastercard&quot;), ref(&quot;payment.payment_icon_cc_visa&quot;)])]"/>
<field name="display_as">Credit Card (powered by Ingenico)</field>
<field name="image_128" type="base64" file="payment_ingenico/static/src/img/ingenico_icon.png"/>
</record>
<record id="payment_acquirer_paypal" model="payment.acquirer">
<field name="image" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/>
<!-- <field name="image" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/>-->
<field name="name">PayPal</field>
<field name="image_128" type="base64" file="payment_paypal/static/src/img/paypal_icon.png"/>
</record>
<record id="payment_acquirer_payu" model="payment.acquirer">
<field name="image" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/>
<!-- <field name="image" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/>-->
<field name="display_as">Credit Card (powered by PayUmoney)</field>
<field name="image_128" type="base64" file="payment_payumoney/static/src/img/payumoney_icon.png"/>
</record>
<record id="payment_acquirer_sips" model="payment.acquirer">
<field name="image" type="base64" file="payment_sips/static/src/img/sips_icon.png"/>
<!-- <field name="image" type="base64" file="payment_sips/static/src/img/sips_icon.png"/>-->
<field name="display_as">Credit Card (powered by Sips)</field>
<field name="image_128" type="base64" file="payment_sips/static/src/img/sips_icon.png"/>
</record>
<record id="payment_acquirer_stripe" model="payment.acquirer">
<field name="image" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/>
<!-- <field name="image" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/>-->
<field name="display_as">Credit Card (powered by Stripe)</field>
<field name="image_128" type="base64" file="payment_stripe/static/src/img/stripe_icon.png"/>
</record>
<record id="payment_acquirer_transfer" model="payment.acquirer">
<field name="image" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/>
<!-- <field name="image" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/>-->
<field name="image_128" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/>
</record>
</odoo>
54 changes: 54 additions & 0 deletions addons/payment/migrations/13.0.1.0/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---Models in module 'payment'---
new model payment.link.wizard [transient]
# NOTHING TO DO

---Fields in module 'payment'---
payment / account.invoice / transaction_ids (many2many) : DEL relation: payment.transaction
payment / account.move / transaction_ids (many2many) : NEW relation: payment.transaction
payment / payment.transaction / invoice_ids (many2many) : relation is now 'account.move' ('account.invoice') [nothing to do]
# DONE: post-migration updated new ids

payment / payment.acquirer / auth_msg (html) : NEW hasdefault
payment / payment.acquirer / check_validity (boolean) : NEW
payment / payment.acquirer / color (integer) : NEW isfunction: function, stored
payment / payment.acquirer / display_as (char) : NEW
# NOTHING TO DO

payment / payment.acquirer / environment (selection) : DEL required, selection_keys: ['prod', 'test'], req_default: function
payment / payment.acquirer / state (selection) : NEW required, selection_keys: ['disabled', 'enabled', 'test'], req_default: function, hasdefault
# DONE: Pre-migration renamed to state

payment / payment.acquirer / image (binary) : DEL attachment: True
payment / payment.acquirer / image_128 (binary) : NEW attachment: True
payment / payment.acquirer / image_medium (binary) : DEL attachment: True
payment / payment.acquirer / image_small (binary) : DEL attachment: True
# DONE: Pre-migration renamed to image_128

payment / payment.acquirer / module_state (selection) : is now stored
payment / payment.acquirer / post_msg (html) : DEL
payment / payment.acquirer / specific_countries (boolean) : DEL
payment / payment.acquirer / website_published (boolean) : DEL
payment / payment.acquirer / error_msg (html) : DEL
payment / payment.token / company_id (many2one) : NEW relation: res.company, isrelated: related, stored
# NOTHING TO DO: many2many table didn't changed

---XML records in module 'payment'---
NEW ir.actions.act_window: payment.action_invoice_order_generate_link
NEW ir.ui.view: payment.payment_link_wizard_view_form
NEW payment.acquirer: payment.payment_acquirer_alipay (noupdate)
NEW payment.acquirer: payment.payment_acquirer_payulatam (noupdate)
NEW payment.acquirer: payment.payment_acquirer_sepa_direct_debit (noupdate)
NEW payment.icon: payment.payment_icon_cc_codensa_easy_credit
NEW payment.icon: payment.payment_icon_cc_ideal
NEW payment.icon: payment.payment_icon_cc_webmoney
NEW payment.icon: payment.payment_icon_cc_western_union
DEL ir.ui.menu: payment.root_payment_menu [renamed to account module]
DEL ir.ui.view: payment.view_account_payment_invoice_form_inherit_payment
# NOTHING TO DO

DEL payment.acquirer: payment.payment_acquirer_custom (noupdate)
# DONE: Post-migration

NEW payment.acquirer: payment.payment_acquirer_ingenico (noupdate)
DEL payment.acquirer: payment.payment_acquirer_ogone (noupdate)
# DONE: Pre-migrations renamed
39 changes: 39 additions & 0 deletions addons/payment/migrations/13.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade

unlink_by_xmlid = [
'payment.payment_acquirer_custom'
]


def map_payment_acquirer_state(cr):
openupgrade.logged_query(
cr, """
UPDATE payment_acquirer
SET state = CASE WHEN {website_published} = TRUE THEN 'enabled'
ELSE 'disabled' END
WHERE state = 'prod'""".format(
website_published=openupgrade.get_legacy_name('website_published')
)
)


def update_account_invoice_transaction_rel_table(cr):
openupgrade.logged_query(
cr, """
UPDATE account_invoice_transaction_rel aitr
SET invoice_id = am.id
FROM account_move am
WHERE am.old_invoice_id = aitr.{}
""".format(openupgrade.get_legacy_name('invoice_id'))
)


@openupgrade.migrate(use_env=True)
def migrate(env, version):
map_payment_acquirer_state(env.cr)
update_account_invoice_transaction_rel_table(env.cr)
openupgrade.delete_records_safely_by_xml_id(env, unlink_by_xmlid)
openupgrade.load_data(env.cr, 'payment', 'migrations/13.0.1.0/noupdate_changes.xml')
44 changes: 44 additions & 0 deletions addons/payment/migrations/13.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade

_column_copies = {
'account_invoice_transaction_rel': [
('invoice_id', None, None),
],

}

_column_renames = {
'payment_acquirer': [
('website_published', None),
],

}

_field_renames = [
('payment.acquirer', 'payment_acquirer', 'image_medium', 'image_128'),
('payment.acquirer', 'payment_acquirer', 'environment', 'state'),
]

_xmlid_renames = [
('payment.payment_acquirer_ogone', 'payment.payment_acquirer_ingenico'),
]


@openupgrade.migrate(use_env=True)
def migrate(env, version):
openupgrade.rename_fields(env, _field_renames)
openupgrade.copy_columns(env.cr, _column_copies)
openupgrade.rename_columns(env.cr, _column_renames)
openupgrade.rename_xmlids(env.cr, _xmlid_renames)
# Fix image of payment.acquirer after renaming column to image_128
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_attachment
SET res_field = 'image_128'
WHERE res_field = 'image_medium' and res_model = 'payment.acquirer'
""",
)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules120-130.rst
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ missing in the new release are marked with |del|.
+----------------------------------------------+-------------------------------------------------+
|partner_autocomplete_address_extended | Nothing to do |
+----------------------------------------------+-------------------------------------------------+
|payment | |
|payment | Done |
+----------------------------------------------+-------------------------------------------------+
|payment_adyen | |
+----------------------------------------------+-------------------------------------------------+
Expand Down

0 comments on commit 7bded46

Please sign in to comment.