changeset 399364eeb545 in modules/account_product:default
details: 
https://hg.tryton.org/modules/account_product?cmd=changeset&node=399364eeb545
description:
        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
diffstat:

 product.py |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (15 lines):

diff -r eccf0af50277 -r 399364eeb545 product.py
--- a/product.py        Sun Jul 04 17:54:46 2021 +0200
+++ b/product.py        Wed Jul 21 23:54:13 2021 +0200
@@ -191,7 +191,10 @@
         if self.account_parent:
             return self.parent.get_account(name, **pattern)
         else:
-            return self.get_multivalue(name[:-5], **pattern)
+            transaction = Transaction()
+            with transaction.reset_context(), \
+                    transaction.set_context(self._context):
+                return self.get_multivalue(name[:-5], **pattern)
 
     def get_taxes(self, name):
         company = Transaction().context.get('company')

Reply via email to