[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) <jobl@odoo.com>
This commit is contained in:
jobl
2024-02-21 20:23:00 +00:00
parent c3891241d8
commit 954497195d
+4 -1
View File
@@ -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)