[FIX] stock: forbids possibility to make inventory of all products when a given product is chosen
opw-634388 Fixes #6512
This commit is contained in:
parent
0e5e8d2873
commit
561346db9e
|
@ -2744,6 +2744,18 @@ class stock_inventory(osv.osv):
|
||||||
vals.append(product_line)
|
vals.append(product_line)
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
def _check_filter_product(self, cr, uid, ids, context=None):
|
||||||
|
for inventory in self.browse(cr, uid, ids, context=context):
|
||||||
|
if inventory.filter not in ('product', 'product_owner') and inventory.product_id:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def onchange_filter(self, cr, uid, ids, filter):
|
||||||
|
return {'value': {'product_id': False} if filter not in ('product', 'product_owner') else {}}
|
||||||
|
|
||||||
|
_constraints = [
|
||||||
|
(_check_filter_product, 'A specific product is chosen while the filter "One product only" is not selected', ['product_id', 'filter']),
|
||||||
|
]
|
||||||
|
|
||||||
class stock_inventory_line(osv.osv):
|
class stock_inventory_line(osv.osv):
|
||||||
_name = "stock.inventory.line"
|
_name = "stock.inventory.line"
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="location_id" domain="[('usage','not in', ['supplier','production'])]"/>
|
<field name="location_id" domain="[('usage','not in', ['supplier','production'])]"/>
|
||||||
<field name="filter" string="Inventory of" widget='radio' attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="filter" string="Inventory of" widget='radio' attrs="{'readonly': [('state', '!=', 'draft')]}" on_change="onchange_filter(filter)"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
-
|
-
|
||||||
!record {model: stock.inventory, id: inventory_test0}:
|
!record {model: stock.inventory, id: inventory_test0}:
|
||||||
name: Test
|
name: Test
|
||||||
|
filter: product
|
||||||
product_id: inventory_product
|
product_id: inventory_product
|
||||||
-
|
-
|
||||||
I confirm the inventory and check that my inventory has no line, as the product is a new one.
|
I confirm the inventory and check that my inventory has no line, as the product is a new one.
|
||||||
|
@ -60,6 +61,7 @@
|
||||||
-
|
-
|
||||||
!record {model: stock.inventory, id: inventory_test1}:
|
!record {model: stock.inventory, id: inventory_test1}:
|
||||||
name: second test inventory
|
name: second test inventory
|
||||||
|
filter: product
|
||||||
product_id: inventory_product
|
product_id: inventory_product
|
||||||
-
|
-
|
||||||
I confirm the inventory and check that my inventory has one line, with a quantity of 10.
|
I confirm the inventory and check that my inventory has one line, with a quantity of 10.
|
||||||
|
|
Loading…
Reference in New Issue