changeset 472cf1d757b9 in modules/account_product:default
details: 
https://hg.tryton.org/modules/account_product?cmd=changeset;node=472cf1d757b9
description:
        Add test on context of company multivalue target fields

        issue10067
        review333851026
diffstat:

 analytic_account.py           |  14 ++++++++++++--
 product.py                    |   6 +++++-
 tests/test_account_product.py |   5 +++--
 3 files changed, 20 insertions(+), 5 deletions(-)

diffs (64 lines):

diff -r 3860aed8d26e -r 472cf1d757b9 analytic_account.py
--- a/analytic_account.py       Tue Jan 05 16:44:34 2021 +0000
+++ b/analytic_account.py       Fri Mar 05 15:49:19 2021 +0100
@@ -2,14 +2,24 @@
 # this repository contains the full copyright notices and license terms.
 from trytond.model import fields
 from trytond.pool import PoolMeta
+from trytond.pyson import Eval
 
 
 class Rule(metaclass=PoolMeta):
     __name__ = 'analytic_account.rule'
 
-    product = fields.Many2One('product.product', "Product", ondelete='CASCADE')
+    product = fields.Many2One(
+        'product.product', "Product", ondelete='CASCADE',
+        context={
+            'company': Eval('company', -1),
+            },
+        depends=['company'])
     product_category = fields.Many2One(
-        'product.category', "Product Category", ondelete='CASCADE')
+        'product.category', "Product Category", ondelete='CASCADE',
+        context={
+            'company': Eval('company', -1),
+            },
+        depends=['company'])
 
     def match(self, pattern):
         if 'product_categories' in pattern:
diff -r 3860aed8d26e -r 472cf1d757b9 product.py
--- a/product.py        Tue Jan 05 16:44:34 2021 +0000
+++ b/product.py        Fri Mar 05 15:49:19 2021 +0100
@@ -227,7 +227,11 @@
     "Category Account"
     __name__ = 'product.category.account'
     category = fields.Many2One(
-        'product.category', "Category", ondelete='CASCADE', select=True)
+        'product.category', "Category", ondelete='CASCADE', select=True,
+        context={
+            'company': Eval('company', -1),
+            },
+        depends=['company'])
     account_expense = fields.Many2One(
         'account.account', "Account Expense",
         domain=[
diff -r 3860aed8d26e -r 472cf1d757b9 tests/test_account_product.py
--- a/tests/test_account_product.py     Tue Jan 05 16:44:34 2021 +0000
+++ b/tests/test_account_product.py     Fri Mar 05 15:49:19 2021 +0100
@@ -8,11 +8,12 @@
 from trytond.pool import Pool
 from trytond.exceptions import UserError
 
-from trytond.modules.company.tests import create_company, set_company
+from trytond.modules.company.tests import (
+    create_company, set_company, CompanyMultiValueTestMixin)
 from trytond.modules.account.tests import create_chart
 
 
-class AccountProductTestCase(ModuleTestCase):
+class AccountProductTestCase(CompanyMultiValueTestMixin, ModuleTestCase):
     'Test AccountProduct module'
     module = 'account_product'
     extras = ['analytic_account']

Reply via email to