changeset c0de02892891 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=c0de02892891
description:
        Manage explicitly stock_skip_warehouse context

        The windows that display product quantities should explicitly manage the
        stock_skip_warehouse context to ensure static result.

        issue9041
        review253051002
diffstat:

 move.py                                            |  7 -------
 product.py                                         |  7 +++++++
 product.xml                                        |  4 ++--
 view/product_quantities_warehouse_context_form.xml |  2 ++
 4 files changed, 11 insertions(+), 9 deletions(-)

diffs (78 lines):

diff -r bbc2443838bd -r c0de02892891 move.py
--- a/move.py   Wed Feb 12 00:23:36 2020 +0100
+++ b/move.py   Sat Feb 15 01:40:11 2020 +0100
@@ -111,10 +111,6 @@
         Compute the domain to filter records which validates the domain over
         quantity field.
 
-        The context with keys:
-            stock_skip_warehouse: if set, quantities on a warehouse are no more
-                quantities of all child locations but quantities of the storage
-                zone.
         location_ids is the list of IDs of locations to take account to compute
             the stock.
         grouping defines how stock moves are grouped.
@@ -956,9 +952,6 @@
             forecast: if set compute the forecast quantity.
             stock_destinations: A list of location ids. If set, restrict the
                 computation to moves from and to those locations.
-            stock_skip_warehouse: if set, quantities on a warehouse are no more
-                quantities of all child locations but quantities of the storage
-                zone.
         If with_childs, it computes also for child locations.
         grouping is a tuple of Move (or Product if prefixed by 'product.')
             field names and defines how stock moves are grouped.
diff -r bbc2443838bd -r c0de02892891 product.py
--- a/product.py        Wed Feb 12 00:23:36 2020 +0100
+++ b/product.py        Sat Feb 15 01:40:11 2020 +0100
@@ -564,12 +564,19 @@
             ('type', '=', 'warehouse'),
             ],
         help="The warehouse for which the quantities will be calculated.")
+    stock_skip_warehouse = fields.Boolean(
+        "Only storage zone",
+        help="Check to use only the quantity of the storage zone.")
 
     @classmethod
     def default_warehouse(cls):
         Location = Pool().get('stock.location')
         return Location.get_default_warehouse()
 
+    @classmethod
+    def default_stock_skip_warehouse(cls):
+        return Transaction().context.get('stock_skip_warehouse')
+
 
 class OpenProductQuantitiesByWarehouse(Wizard):
     "Open Product Quantities By Warehouse"
diff -r bbc2443838bd -r c0de02892891 product.xml
--- a/product.xml       Wed Feb 12 00:23:36 2020 +0100
+++ b/product.xml       Sat Feb 15 01:40:11 2020 +0100
@@ -152,7 +152,7 @@
             <field name="res_model">stock.location</field>
             <field name="domain" eval="[('parent', '=', None)]" pyson="1"/>
             <field name="context" pyson="1"
-                eval="If(Eval('active_model') == 'product.template', 
{'product_template': Eval('active_id')}, {'product': Eval('active_id')})"/>
+                eval="If(Eval('active_model') == 'product.template', 
{'product_template': Eval('active_id'), 'stock_skip_warehouse': False}, 
{'product': Eval('active_id'), 'stock_skip_warehouse': False})"/>
             <field name="context_model">product.by_location.context</field>
         </record>
         <record model="ir.action.act_window.view" 
id="act_location_quantity_tree_view1">
@@ -189,7 +189,7 @@
             <field name="res_model">stock.location</field>
             <field name="search_value" eval="['OR', ('quantity', '!=', 0), 
('forecast_quantity', '!=', 0)]" pyson="1"/>
             <field name="context" pyson="1"
-                eval="If(Eval('active_model') == 'product.template', 
{'product_template': Eval('active_id'), 'with_childs': False}, {'product': 
Eval('active_id'), 'with_childs': False})"/>
+                eval="If(Eval('active_model') == 'product.template', 
{'product_template': Eval('active_id'), 'with_childs': False, 
'stock_skip_warehouse': False}, {'product': Eval('active_id'), 'with_childs': 
False, 'stock_skip_warehouse': False})"/>
             <field name="context_model">product.by_location.context</field>
         </record>
         <record model="ir.action.act_window.view" 
id="act_location_quantity_list_view">
diff -r bbc2443838bd -r c0de02892891 
view/product_quantities_warehouse_context_form.xml
--- a/view/product_quantities_warehouse_context_form.xml        Wed Feb 12 
00:23:36 2020 +0100
+++ b/view/product_quantities_warehouse_context_form.xml        Sat Feb 15 
01:40:11 2020 +0100
@@ -4,4 +4,6 @@
 <form>
     <label name="warehouse"/>
     <field name="warehouse"/>
+    <label name="stock_skip_warehouse"/>
+    <field name="stock_skip_warehouse"/>
 </form>

Reply via email to