Merge lp:~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-fill2-lga into lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical

Proposed by Laetitia Gangloff (Acsone)
Status: Merged
Approved by: Loïc Bellier - Numérigraphe
Approved revision: 44
Merged at revision: 41
Proposed branch: lp:~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-fill2-lga
Merge into: lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical
Diff against target: 493 lines (+363/-18)
12 files modified
stock_inventory_hierarchical_location/__init__.py (+1/-0)
stock_inventory_hierarchical_location/__openerp__.py (+1/-1)
stock_inventory_hierarchical_location/inventory_hierarchical_location.py (+0/-10)
stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml (+1/-1)
stock_inventory_hierarchical_location/tests/__init__.py (+39/-0)
stock_inventory_hierarchical_location/tests/fill_inventory_test.py (+118/-0)
stock_inventory_hierarchical_location/wizard/__init__.py (+21/-0)
stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py (+89/-0)
stock_inventory_location/__openerp__.py (+3/-3)
stock_inventory_location/stock_inventory_location.py (+4/-3)
stock_inventory_location/tests/__init__.py (+39/-0)
stock_inventory_location/tests/stock_inventory_location_test.py (+47/-0)
To merge this branch: bzr merge lp:~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-fill2-lga
Reviewer Review Type Date Requested Status
Loïc Bellier - Numérigraphe code review, testing Approve
Lionel Sausin - Initiatives/Numérigraphe has conflicts Pending
Review via email: mp+222984@code.launchpad.net

This proposal supersedes a proposal from 2014-06-12.

Description of the change

I make some change in the module stock_inventory_hierarchical_location.

The goal is to take account of sub-inventories in case of an exhaustive inventory in two case :

-fill inventory

I also correct a little mistake in demo data of this module.

To post a comment you must log in.
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : Posted in a previous version of this proposal

Thanks for your help.
I've just merged our own fixes of the day, will you please merge them to avoid conflicts ?

I think I understand what you're trying to do in fill_inventory and it's not exactly how we had it in v6 - which is broken right now in v7, and would require a patch on the code addons.
Your patch completely excludes the locations of sub-inventories, whereas we used to only exclude the generated inventory lines. That would allow us to "catch" the lines that could have been missing from sub-inventories, but since they're exhaustive anyway there should not be any.
So I guess your approach is correct.
I'll let Loïc decide, he's working on the problem too.

review: Needs Resubmitting (has conflicts)
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) : Posted in a previous version of this proposal
review: Needs Fixing (has conflicts)
Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

I redo a branch based on your last version (38).

So this one contains change for fill inventory. The fill inventory, is used when confirm inventory or when click on button.

In case of confirm inventory, the sub-inventory are already confirmed -> no missing lines.

In case of click on button, it is true that we can have some missing lines, but the confirmation, is not possible (sub-inventories are not confirmed). I think it is 'dangerous' if lines are added, because the confirmation on sub-inventory will also add these lines !

Maybe can we prevent this action when sub-inventories are not confirmed ? (like confirm)

40. By Laetitia Gangloff (Acsone)

stock_inventory_location : use SUPERUSER for check in stock.location and stock.move

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

I complete this mp, with the user of SUPERUSER for check on stock.location and stock.move.
It is in the module stock_inventory_location.

A user with no access to stock.inventory, have acl error with these check. And record rules can give wrong result.

41. By Laetitia Gangloff (Acsone)

stock_inventory_location : avoid recursive write on stock.location

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

I resolve another problem on the write of stock_location.
There is a "RuntimeError: maximum recursion depth exceeded" when change location_id. ids was just assigned in ids_to_check so, when ids_to_check change, ids change too and the write is not done with right parameter.

42. By Laetitia Gangloff (Acsone)

stock_inventory_hierarchical_location : in fill inventory, if exclude location is empty do not add it in domain

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

Following Loïc's test, in fill inventory I remove the exclude clause when location list to exclude is empty.

43. By Laetitia Gangloff (Acsone)

stock_inventory_hierarchical_location : remove unused method _fill_location_lines

44. By Laetitia Gangloff (Acsone)

stock_inventory_hierarchical_location: fill_inventory ignore no product exception in case of an exhaustive inventory

Revision history for this message
Loïc Bellier - Numérigraphe (lb-b) wrote :

After lot's of test, your module seems to work !

review: Approve (code review, testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'stock_inventory_hierarchical_location/__init__.py'
--- stock_inventory_hierarchical_location/__init__.py 2014-06-12 12:48:28 +0000
+++ stock_inventory_hierarchical_location/__init__.py 2014-06-13 13:19:05 +0000
@@ -19,3 +19,4 @@
19##############################################################################19##############################################################################
2020
21from . import inventory_hierarchical_location21from . import inventory_hierarchical_location
22from . import wizard
2223
=== modified file 'stock_inventory_hierarchical_location/__openerp__.py'
--- stock_inventory_hierarchical_location/__openerp__.py 2014-06-10 14:04:38 +0000
+++ stock_inventory_hierarchical_location/__openerp__.py 2014-06-13 13:19:05 +0000
@@ -43,6 +43,6 @@
43 "data": [43 "data": [
44 "inventory_hierarchical_location_view.xml",44 "inventory_hierarchical_location_view.xml",
45 ],45 ],
46 "test": ["test/inventory_hierarchical_location_test.yml"],46 "test": ["tests/inventory_hierarchical_location_test.yml"],
47 "demo": ["inventory_hierarchical_location_demo.xml"],47 "demo": ["inventory_hierarchical_location_demo.xml"],
48}48}
4949
=== modified file 'stock_inventory_hierarchical_location/inventory_hierarchical_location.py'
--- stock_inventory_hierarchical_location/inventory_hierarchical_location.py 2014-06-12 12:48:28 +0000
+++ stock_inventory_hierarchical_location/inventory_hierarchical_location.py 2014-06-13 13:19:05 +0000
@@ -86,13 +86,3 @@
86 "It cannot be added.")}86 "It cannot be added.")}
87 }87 }
88 return {}88 return {}
89
90 def _fill_location_lines(self, cr, uid, inventory_id, location_ids,
91 set_stock_zero, context=None):
92 """Add ids of children inventory into list """
93 children_inventory_ids = self.search(
94 cr, uid, [('parent_id', 'child_of', inventory_id)])
95 context['children_inventory_ids'] = children_inventory_ids
96 return super(HierarchicalExhInventory, self)._fill_location_lines(
97 cr, uid, inventory_id, location_ids, set_stock_zero,
98 context=context)
9989
=== modified file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml'
--- stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 2014-06-12 16:40:46 +0000
+++ stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 2014-06-13 13:19:05 +0000
@@ -22,7 +22,7 @@
22 <record id="child_2_id" model="stock.inventory">22 <record id="child_2_id" model="stock.inventory">
23 <field name="name">Team B</field>23 <field name="name">Team B</field>
24 <field name="parent_id" ref="parent_inventory"/>24 <field name="parent_id" ref="parent_inventory"/>
25 <field name="location_id" model="stock.location" search="stock.stock_location_components"/>25 <field name="location_id" model="stock.location" ref="stock.stock_location_components"/>
26 </record>26 </record>
27 </data>27 </data>
28</openerp>28</openerp>
2929
=== renamed directory 'stock_inventory_hierarchical_location/test' => 'stock_inventory_hierarchical_location/tests'
=== added file 'stock_inventory_hierarchical_location/tests/__init__.py'
--- stock_inventory_hierarchical_location/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_hierarchical_location/tests/__init__.py 2014-06-13 13:19:05 +0000
@@ -0,0 +1,39 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30import fill_inventory_test
31
32fast_suite = [
33]
34
35checks = [
36 fill_inventory_test,
37]
38
39# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
040
=== added file 'stock_inventory_hierarchical_location/tests/fill_inventory_test.py'
--- stock_inventory_hierarchical_location/tests/fill_inventory_test.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_hierarchical_location/tests/fill_inventory_test.py 2014-06-13 13:19:05 +0000
@@ -0,0 +1,118 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30import openerp.tests.common as common
31
32DB = common.DB
33ADMIN_USER_ID = common.ADMIN_USER_ID
34
35
36class fill_inventory_test(common.TransactionCase):
37
38 def setUp(self):
39 super(fill_inventory_test, self).setUp()
40
41 def test_missing_location(self):
42 """
43 Test that when confirm a parent inventory, the child location are not in the confirmation result
44 """
45 parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory')
46 self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id])
47 # confirm shelf 1 inventory
48 inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id')
49 self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id])
50 missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id])
51 self.assertEqual(len(missing_location), 1, "1 missing location should be find, because the inventory is empty")
52 wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]})
53 self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]})
54 missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id])
55 self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is confirmed")
56 # confirm shelf 2 inventory
57 inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id')
58 self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id])
59 missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id])
60 self.assertEqual(len(missing_location), 1, "1 missing location should be fine, because the inventory is empty")
61 self.registry('stock.inventory.line').create(self.cr, self.uid, {'product_id': self.ref('product.product_product_7'),
62 'product_uom': self.ref('product.product_uom_unit'),
63 'company_id': self.ref('base.main_company'),
64 'inventory_id': inventory_id,
65 'product_qty': 18.0,
66 'location_id': self.ref('stock.stock_location_14')})
67 missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id])
68 self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is filled")
69 wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]})
70 wizard = self.registry('stock.inventory.uninventoried.locations').browse(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]})
71 self.assertEqual(len(wizard.location_ids), 0, "The wizard should not contain any lines but contains %s." % wizard.location_ids)
72 self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]})
73 # confirm parent inventory
74 missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [parent_inventory_id])
75 self.assertEqual(len(missing_location), 1, "Only 1 missing location should be find, because there is some location in child inventory")
76
77 def test_fill_inventory(self):
78 """
79 Test that when fill a parent inventory, the child location are not in the result
80 """
81 parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory')
82 self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id])
83 # confirm shelf 1 inventory
84 inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id')
85 self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id])
86 wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_components'),
87 'recursive': True,
88 'exhaustive': True,
89 'set_stock_zero': True}, context={'active_ids': [inventory_id]})
90 self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]})
91 inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)])
92 self.assertEqual(len(inventory_line_ids), 12, "12 inventory line is fount after filling inventory")
93 # confirm shelf 2 inventory
94 inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id')
95 self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id])
96 wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_14'),
97 'recursive': True,
98 'exhaustive': True,
99 'set_stock_zero': True}, context={'active_ids': [inventory_id]})
100 self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]})
101 inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)])
102 self.assertEqual(len(inventory_line_ids), 4, "1 inventory line is fount after filling inventory")
103 # confirm parent inventory
104 wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_stock'),
105 'recursive': True,
106 'exhaustive': True,
107 'set_stock_zero': True}, context={'active_ids': [parent_inventory_id]})
108 try:
109 self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [parent_inventory_id]})
110 except Exception, e:
111 self.assertEqual(e.value, 'No product in this location. Please select a location in the product form.', "The message should be ''No product in this location. Please select a location in the product form.''")
112 exception_happened = True
113 pass
114 self.assertTrue(exception_happened)
115 inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', parent_inventory_id)])
116 self.assertEqual(len(inventory_line_ids), 0, "No inventory line is fount after filling inventory")
117
118# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0119
=== added directory 'stock_inventory_hierarchical_location/wizard'
=== added file 'stock_inventory_hierarchical_location/wizard/__init__.py'
--- stock_inventory_hierarchical_location/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_hierarchical_location/wizard/__init__.py 2014-06-13 13:19:05 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from . import stock_fill_location_inventory
022
=== added file 'stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py'
--- stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 2014-06-13 13:19:05 +0000
@@ -0,0 +1,89 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30from openerp.osv import orm
31from openerp.tools.translate import _
32
33
34class FillInventoryWizard(orm.TransientModel):
35 """If inventory as sub inventories, do not fill with sub inventories location"""
36 _inherit = 'stock.fill.inventory'
37
38 def fill_inventory(self, cr, uid, ids, context=None):
39 """ To Import stock inventory according to products available in the location and not already in a sub inventory
40
41 We split fill_inventory on many fill_inventory (one for each location)
42 @param self: The object pointer.
43 @param cr: A database cursor
44 @param uid: ID of the user currently logged in
45 @param ids: the ID or list of IDs if we want more than one
46 @param context: A standard dictionary
47 @return:
48 """
49 if context is None:
50 context = {}
51
52 if ids and len(ids):
53 ids = ids[0]
54 else:
55 return {'type': 'ir.actions.act_window_close'}
56 fill_inventory = self.browse(cr, uid, ids, context=context)
57 if fill_inventory.recursive and fill_inventory.exhaustive:
58 exclude_location_ids = []
59 for i in self.pool['stock.inventory'].browse(cr, uid, context['active_ids']):
60 for sub_inventory in i.inventory_ids:
61 # exclude these location
62 exclude_location_ids.append(sub_inventory.location_id.id)
63 domain = [('location_id', 'child_of', [fill_inventory.location_id.id])]
64 if exclude_location_ids:
65 domain.append('!')
66 domain.append(('location_id', 'child_of', exclude_location_ids))
67 location_ids = self.pool['stock.location'].search(cr, uid, domain,
68 order="id",
69 context=context)
70 all_in_exception = 0
71 for location_id in location_ids:
72 try:
73 super(FillInventoryWizard, self).fill_inventory(cr, uid,
74 [self.copy(cr, uid, ids, {'location_id': location_id,
75 'recursive': False, }, context=context)],
76 context=context)
77 except Exception, e:
78 if e.value == _('No product in this location. Please select a location in the product form.'):
79 all_in_exception = all_in_exception + 1
80 pass
81 else:
82 raise e
83 if all_in_exception == len(location_ids):
84 raise orm.except_orm(_('Warning!'), _('No product in this location. Please select a location in the product form.'))
85 return {'type': 'ir.actions.act_window_close'}
86 else:
87 return super(FillInventoryWizard, self).fill_inventory(cr, uid, [ids], context=context)
88
89# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
090
=== modified file 'stock_inventory_location/__openerp__.py'
--- stock_inventory_location/__openerp__.py 2014-06-10 16:02:09 +0000
+++ stock_inventory_location/__openerp__.py 2014-06-13 13:19:05 +0000
@@ -62,9 +62,9 @@
62 "wizard/stock_fill_location_inventory_view.xml",62 "wizard/stock_fill_location_inventory_view.xml",
63 ],63 ],
64 "test": [64 "test": [
65 "test/inventory_standard_test.yml",65 "tests/inventory_standard_test.yml",
66 "test/inventory_exhaustive_test.yml",66 "tests/inventory_exhaustive_test.yml",
67 "test/inventory_future_test.yml",67 "tests/inventory_future_test.yml",
68 ],68 ],
69 "images": [69 "images": [
70 "images/inventory_form.png",70 "images/inventory_form.png",
7171
=== modified file 'stock_inventory_location/stock_inventory_location.py'
--- stock_inventory_location/stock_inventory_location.py 2014-06-12 16:49:28 +0000
+++ stock_inventory_location/stock_inventory_location.py 2014-06-13 13:19:05 +0000
@@ -27,6 +27,7 @@
27# TODOv8! remove, feature is included upstream27# TODOv8! remove, feature is included upstream
28from openerp.osv import osv28from openerp.osv import osv
29from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT29from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
30from openerp import SUPERUSER_ID
3031
31from .exceptions import ExhaustiveInventoryException32from .exceptions import ExhaustiveInventoryException
3233
@@ -270,7 +271,7 @@
270 """Error if an exhaustive Inventory is being conducted here"""271 """Error if an exhaustive Inventory is being conducted here"""
271 inv_obj = self.pool['stock.inventory']272 inv_obj = self.pool['stock.inventory']
272 location_inventory_open_ids = inv_obj._get_locations_open_inventories(273 location_inventory_open_ids = inv_obj._get_locations_open_inventories(
273 cr, uid, context=context)274 cr, SUPERUSER_ID, context=context)
274 if not isinstance(ids, Iterable):275 if not isinstance(ids, Iterable):
275 ids = [ids]276 ids = [ids]
276 for inv_id in ids:277 for inv_id in ids:
@@ -286,7 +287,7 @@
286 self._check_inventory(cr, uid, ids, context=context)287 self._check_inventory(cr, uid, ids, context=context)
287 if not isinstance(ids, Iterable):288 if not isinstance(ids, Iterable):
288 ids = [ids]289 ids = [ids]
289 ids_to_check = ids290 ids_to_check = list(ids)
290 # If changing the parent, no inventory must conducted there either291 # If changing the parent, no inventory must conducted there either
291 if vals.get('location_id'):292 if vals.get('location_id'):
292 ids_to_check.append(vals['location_id'])293 ids_to_check.append(vals['location_id'])
@@ -326,7 +327,7 @@
326 message = ""327 message = ""
327 inv_obj = self.pool['stock.inventory']328 inv_obj = self.pool['stock.inventory']
328 locked_location_ids = inv_obj._get_locations_open_inventories(329 locked_location_ids = inv_obj._get_locations_open_inventories(
329 cr, uid, context=context)330 cr, SUPERUSER_ID, context=context)
330 if not locked_location_ids:331 if not locked_location_ids:
331 # Nothing to verify332 # Nothing to verify
332 return True333 return True
333334
=== renamed directory 'stock_inventory_location/test' => 'stock_inventory_location/tests'
=== added file 'stock_inventory_location/tests/__init__.py'
--- stock_inventory_location/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/__init__.py 2014-06-13 13:19:05 +0000
@@ -0,0 +1,39 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30import stock_inventory_location_test
31
32fast_suite = [
33]
34
35checks = [
36 stock_inventory_location_test,
37]
38
39# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
040
=== added file 'stock_inventory_location/tests/stock_inventory_location_test.py'
--- stock_inventory_location/tests/stock_inventory_location_test.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/stock_inventory_location_test.py 2014-06-13 13:19:05 +0000
@@ -0,0 +1,47 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30import openerp.tests.common as common
31
32DB = common.DB
33ADMIN_USER_ID = common.ADMIN_USER_ID
34
35
36class stock_inventory_location_test(common.TransactionCase):
37
38 def setUp(self):
39 super(stock_inventory_location_test, self).setUp()
40
41 def test_update_parent_location(self):
42 """
43 Test the update of the parent of a location (no inventory in progress
44 """
45 self.registry('stock.location').write(self.cr, self.uid, self.ref('stock.stock_location_5'), {'location_id': self.ref('stock.stock_location_4')})
46
47# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches