Restore instance context when getting account used
The account_used is set on property so it is executed under the transaction context but we expect to have the account from the company set in the instance context. issue10557 review355371002 (grafted from bfeac28a3c0b44c48b9ad6ce560ade9e24b06789) --HG-- branch : 6.0
This commit is contained in:
1 parent
6f315d994f
commit
ca3ca83176
1 file changed
+9
-2
+9
-2
@@ -4,6 +4,7 @@ from trytond.i18n import gettext
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
from .exceptions import GiftCardValidationError
|
||||
|
||||
@@ -44,7 +45,10 @@ class Template(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Config = pool.get('account.configuration')
|
||||
if self.gift_card:
|
||||
config = Config(1)
|
||||
transaction = Transaction()
|
||||
with transaction.reset_context(), \
|
||||
transaction.set_context(self._context):
|
||||
config = Config(1)
|
||||
return config.gift_card_account_expense
|
||||
return super().account_expense_used
|
||||
|
||||
@@ -53,7 +57,10 @@ class Template(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Config = pool.get('account.configuration')
|
||||
if self.gift_card:
|
||||
config = Config(1)
|
||||
transaction = Transaction()
|
||||
with transaction.reset_context(), \
|
||||
transaction.set_context(self._context):
|
||||
config = Config(1)
|
||||
return config.gift_card_account_revenue
|
||||
return super().account_revenue_used
|
||||
|
||||
|
||||
Reference in new issue
Block a user