From 954497195d0dfa022d0075f8978f39025bb0d2cd Mon Sep 17 00:00:00 2001 From: jobl Date: Thu, 15 Feb 2024 19:00:08 +0000 Subject: [PATCH] [FIX] payment: stripe provider no longer copies website_id Description: In a multi-company environment, `payment.provider` records are specific to each company. After activating Stripe on Company 1, you can set a Website for the record if you wish. If you wish to activate Stripe for Company 2, Odoo will use `.copy()` to create a new `payment.provider` record for Company 2. However, this will lead to differing incorrect behavior depending on the version. On 16, a new `payment.provider` record will be created, but will be connected to the Website set on Company 1's provider. On 17, Odoo will throw an error after a `check_company` call reveals that the Website set on the new record is for the wrong company, preventing the record from being created. In both cases, the `.copy()` grabs the optional Website set on the existing `payment.provider` record to be used incorrectly for the new record. Desired behavior after PR is merged: The Website relation is always neutralized when Odoo creates a new Stripe `payment.provider` record using the `.copy()` method opw-3683338 closes odoo/odoo#154521 X-original-commit: 76cf4221b332c924c243e19f911131431c041bc6 Signed-off-by: Joel Bluemel (jobl) --- addons/payment/models/res_company.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/payment/models/res_company.py b/addons/payment/models/res_company.py index cd46266fd5f..e9aec4a68fc 100644 --- a/addons/payment/models/res_company.py +++ b/addons/payment/models/res_company.py @@ -40,7 +40,10 @@ class ResCompany(models.Model): if not stripe_provider: base_provider = self.env.ref('payment.payment_provider_stripe') # Use sudo to access payment provider record that can be in different company. - stripe_provider = base_provider.sudo().copy(default={'company_id': self.env.company.id}) + stripe_provider = base_provider.sudo().copy(default={ + 'company_id': self.env.company.id, + 'website_id': False, + }) return stripe_provider.action_stripe_connect_account(menu_id=menu_id)