-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Add force company in create account payment from payment transa…
…ction
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import payment_provider | ||
from . import payment_transaction | ||
from . import account_payment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from odoo import models | ||
|
||
|
||
class AccountPayment(models.Model): | ||
_inherit = 'account.payment' | ||
|
||
def create(self, val_list): | ||
force_company = self.env.context._get('force_company') | ||
if force_company: | ||
for vals in val_list: | ||
vals['company_id'] = force_company | ||
return super().create(val_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from odoo import models | ||
|
||
|
||
class PaymentTransaction(models.Model): | ||
_inherit = 'payment.transaction' | ||
|
||
def _create_payment(self, **extra_create_values): | ||
# Add force_company to catch later in the account.payment creation. | ||
return super().with_context(force_company = self.provider_id.journal_id.company_id.id)._create_payment(**extra_create_values) |