Skip to content

Conversation

@hbrunn
Copy link
Member

@hbrunn hbrunn commented Dec 9, 2024

continuation of #4584

@hbrunn
Copy link
Member Author

hbrunn commented Dec 9, 2024

/ocabot migration payment

@MiquelRForgeFlow
Copy link
Contributor

Could you rebase?

haumenphai and others added 3 commits February 4, 2025 14:21
Remove payment.payment_method_acss_debit as does not exist anymore
Move payment.icon to payment.method
Reload payment methods and links to providers
@hbrunn
Copy link
Member Author

hbrunn commented Feb 4, 2025

done

@MiquelRForgeFlow
Copy link
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 17.0-ocabot-merge-pr-4692-by-MiquelRForgeFlow-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 526961d into OCA:17.0 Feb 4, 2025
4 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 526961d. Thanks a lot for contributing to OCA. ❤️

@remi-filament
Copy link
Contributor

Hi @hbrunn @MiquelRForgeFlow @pedrobaeza
I have a problem with this migration script when trying to migrate a DB from v16 where I have multiple companies and in my case Stripe on a secondary company.

In this scenario, payment_provider stripe has been duplicated for the second company, and therefore does not hold XML-id. Therefore the new payment methods (and in particular "card" one were not applied on this provider) and when running end-migration script I get the following UserError from payment_method write() method (https://github.com/odoo/odoo/blob/a73211ad089c238d193d928a70d2586cb92e4707/addons/payment/models/payment_method.py#L184) :
This payment method needs a partner in crime; you should enable a payment provider supporting this method first

I am not sure how to proceed from there, and would appreciate your insights !
Should we look at all payment_providers without XML id based on their code and load method_ids for them ?
That makes sense to me but I am not sure how to do that, maybe copying these from the one with XML id after no_update_changes have been loaded on them ?

@pedrobaeza
Copy link
Member

Shouldn't you adjust your DB to have the primary provider enabled in the second company?

@remi-filament
Copy link
Contributor

You mean using the payment_provider stripe with XML id on my secondary company ?
I cannot do that since I need it also on my primary company (with different configuration) so I need two, but only one carries the XML id.

@pedrobaeza
Copy link
Member

Then I read bad the code... The other part of the condition is about payment methods. Maybe you need to set them properly?

@remi-filament
Copy link
Contributor

Exactly and this is my point, payment methods changed a lot between 16.0 and 17.0 and were reloaded on payment_provider with this file :

<field name="payment_method_ids" eval="[Command.set([ ref('payment.payment_method_ach_direct_debit'), ref('payment.payment_method_affirm'), ref('payment.payment_method_afterpay'), ref('payment.payment_method_alipay'), ref('payment.payment_method_bacs_direct_debit'), ref('payment.payment_method_bancontact'), ref('payment.payment_method_becs_direct_debit'), ref('payment.payment_method_boleto'), ref('payment.payment_method_card'), ref('payment.payment_method_cash_app_pay'), ref('payment.payment_method_clearpay'), ref('payment.payment_method_eps'), ref('payment.payment_method_fpx'), ref('payment.payment_method_giropay'), ref('payment.payment_method_grabpay'), ref('payment.payment_method_ideal'), ref('payment.payment_method_klarna'), ref('payment.payment_method_mobile_pay'), ref('payment.payment_method_multibanco'), ref('payment.payment_method_p24'), ref('payment.payment_method_paynow'), ref('payment.payment_method_paypal'), ref('payment.payment_method_pix'), ref('payment.payment_method_promptpay'), ref('payment.payment_method_revolut_pay'), ref('payment.payment_method_sepa_direct_debit'), ref('payment.payment_method_sofort'), ref('payment.payment_method_upi'), ref('payment.payment_method_wechat_pay'), ref('payment.payment_method_zip'), ])]"/>

The problem is that during migration we are only updating those payment methods on records with XML id (which were noupdate here), but we are not on the paymment provider created manually from those (which should have the same code as original ones but no XML id).

I need to figure out the best way to reload these updated methods on the payment providers without XML id...

@remi-filament
Copy link
Contributor

I could solve the issue by only looking at existing payment methods on payment provider and adding the primary_method from those if missing.
That should solve the UserError, but if feels like it would be an incomplete solution since payment provider would not have been updated with all new payment methods / removing the ones not supported anymore.

@pedrobaeza
Copy link
Member

OK, let's do that assignment for all the copies of each payment provider. Can you do the PR?

@remi-filament
Copy link
Contributor

Yes I will, I would need confirmation on a couple of things to ease the process :

  1. Do you know a way to get all objects without an external id ? (I was thinking making a SQL request for all IDs not in ir_model_data, but maybe there is a more elegant way to do ?)
  2. Should I rely on the code of the payment provider to determine which one was the source ?

Thanks !

@pedrobaeza
Copy link
Member

Isn't there the provider code? And I would use the noupdate changes file as the template, and even write the same data for all of them at once and don't load that noupdate data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants