changeset 1abb4c534c70 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=1abb4c534c70
description:
Add test on context of company multivalue target fields
issue10067
review333851026
diffstat:
move.py | 5 ++++-
product.py | 10 ++++++++--
shipment.py | 20 ++++++++++++++++----
stock_reporting_margin.py | 7 ++++++-
tests/test_stock.py | 7 +++++--
5 files changed, 39 insertions(+), 10 deletions(-)
diffs (129 lines):
diff -r 76116f3d95d2 -r 1abb4c534c70 move.py
--- a/move.py Sat Feb 27 18:16:29 2021 +0100
+++ b/move.py Fri Mar 05 15:49:20 2021 +0100
@@ -179,7 +179,10 @@
('default_uom_category', '=', Eval('product_uom_category')),
())
],
- depends=DEPENDS + ['product_uom_category'],
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=DEPENDS + ['product_uom_category', 'company'],
help="The product that the move is associated with.")
product_uom_category = fields.Function(
fields.Many2One('product.uom.category', 'Product Uom Category'),
diff -r 76116f3d95d2 -r 1abb4c534c70 product.py
--- a/product.py Sat Feb 27 18:16:29 2021 +0100
+++ b/product.py Fri Mar 05 15:49:20 2021 +0100
@@ -1061,7 +1061,10 @@
('products', '=', Eval('product')),
()),
],
- depends=['product'])
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['product', 'company'])
product = fields.Many2One(
'product.product', "Variant",
ondelete='CASCADE', select=True,
@@ -1070,7 +1073,10 @@
('template', '=', Eval('template')),
()),
],
- depends=['template'])
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['template', 'company'])
company = fields.Many2One(
'company.company', "Company", ondelete='CASCADE', required=True)
diff -r 76116f3d95d2 -r 1abb4c534c70 shipment.py
--- a/shipment.py Sat Feb 27 18:16:29 2021 +0100
+++ b/shipment.py Fri Mar 05 15:49:20 2021 +0100
@@ -101,7 +101,10 @@
| Eval('incoming_moves', [0]))
& Eval('supplier')),
}, required=True,
- depends=['state', 'supplier'],
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['state', 'supplier', 'company'],
help="The party that supplied the stock.")
supplier_location = fields.Function(fields.Many2One('stock.location',
'Supplier Location'),
@@ -544,7 +547,10 @@
| Eval('moves', [0]))
& Eval('supplier', 0)),
}, required=True,
- depends=['state', 'supplier'],
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['state', 'supplier', 'company'],
help="The party that supplied the stock.")
delivery_address = fields.Many2One('party.address', 'Delivery Address',
states={
@@ -897,7 +903,10 @@
'readonly': ((Eval('state') != 'draft')
| Eval('outgoing_moves', [0])),
},
- depends=['state'],
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['state', 'company'],
help="The party that purchased the stock.")
customer_location = fields.Function(fields.Many2One('stock.location',
'Customer Location'), 'on_change_with_customer_location')
@@ -1518,7 +1527,10 @@
'readonly': ((Eval('state') != 'draft')
| Eval('incoming_moves', [0])),
},
- depends=['state'],
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['state', 'company'],
help="The party that purchased the stock.")
customer_location = fields.Function(fields.Many2One('stock.location',
'Customer Location'), 'on_change_with_customer_location')
diff -r 76116f3d95d2 -r 1abb4c534c70 stock_reporting_margin.py
--- a/stock_reporting_margin.py Sat Feb 27 18:16:29 2021 +0100
+++ b/stock_reporting_margin.py Fri Mar 05 15:49:20 2021 +0100
@@ -337,7 +337,12 @@
class ProductMixin:
__slots__ = ()
- product = fields.Many2One('product.product', "Product")
+ product = fields.Many2One(
+ 'product.product', "Product",
+ context={
+ 'company': Eval('company', -1),
+ },
+ depends=['company'])
internal_quantity = fields.Float("Internal Quantity")
quantity = fields.Function(fields.Float(
"Quantity", digits=(16, Eval('unit_digits', 2)),
diff -r 76116f3d95d2 -r 1abb4c534c70 tests/test_stock.py
--- a/tests/test_stock.py Sat Feb 27 18:16:29 2021 +0100
+++ b/tests/test_stock.py Fri Mar 05 15:49:20 2021 +0100
@@ -17,10 +17,13 @@
from trytond.pool import Pool
from trytond.modules.company.tests import (
- create_company, set_company, PartyCompanyCheckEraseMixin)
+ create_company, set_company, PartyCompanyCheckEraseMixin,
+ CompanyMultiValueTestMixin)
-class StockTestCase(PartyCompanyCheckEraseMixin, ModuleTestCase):
+class StockTestCase(
+ PartyCompanyCheckEraseMixin, CompanyMultiValueTestMixin,
+ ModuleTestCase):
'Test Stock module'
module = 'stock'
longMessage = True