Merge lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical into lp:stock-logistic-warehouse
- 7.0-inventory-hierarchical
- Merge into 7.0
Status: | Superseded |
---|---|
Proposed branch: | lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical |
Merge into: | lp:stock-logistic-warehouse |
Prerequisite: | lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-location |
Diff against target: |
1547 lines (+1371/-6) 23 files modified
stock_inventory_hierarchical/__init__.py (+28/-0) stock_inventory_hierarchical/__openerp__.py (+46/-0) stock_inventory_hierarchical/exceptions.py (+26/-0) stock_inventory_hierarchical/hierarchical_inventory.py (+202/-0) stock_inventory_hierarchical/hierarchical_inventory_demo.xml (+17/-0) stock_inventory_hierarchical/hierarchical_inventory_view.xml (+78/-0) stock_inventory_hierarchical/i18n/fr.po (+112/-0) stock_inventory_hierarchical/test/hierarchical_inventory_test.yml (+96/-0) stock_inventory_hierarchical_location/__init__.py (+22/-0) stock_inventory_hierarchical_location/__openerp__.py (+48/-0) stock_inventory_hierarchical_location/i18n/fr.po (+127/-0) stock_inventory_hierarchical_location/inventory_hierarchical_location.py (+88/-0) stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml (+28/-0) stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml (+37/-0) stock_inventory_hierarchical_location/tests/__init__.py (+39/-0) stock_inventory_hierarchical_location/tests/fill_inventory_test.py (+118/-0) stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml (+56/-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:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lionel Sausin - Initiatives/Numérigraphe (community) | test pending | Needs Resubmitting | |
Stock and Logistic Core Editors | Pending | ||
Review via email: mp+210631@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-06-20.
Commit message
Description of the change
This proposal lets users compose inventories with sub-inventories in
a hierarchical tree.
This is useful in medium/large warehouses where
several teams must work in parallel to make inventories.
The module stock_inventory
stock_inventory
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
- 37. By Numérigraphe
-
[MERGE] code & views cleanup and fixes
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
Loïc and I are still working on this proposal. Good progress was made: we re-aligned the features with v8 in mind, and improved the code style and the views.
Acsone joined in and we're still making tests, and I hope Loïc can make a new proposal in the coming days.
- 38. By Loïc Bellier - Numérigraphe
-
[FIX]: Extract xpath inventory_ids from stock.inventory
_view_form - 39. By Loïc Bellier - Numérigraphe
-
[MERGE]: From dev branch
- 40. By Loïc Bellier - Numérigraphe
-
[MERGE]: merge from dev branch
- 41. By Loïc Bellier - Numérigraphe
-
[MERGE]: Fix some bugs. Add Merge Proposal of Laetitia Gangloff from ASCONE and thanks to her.
- 42. By Loïc Bellier - Numérigraphe
-
[MERGE]: Exception fault fixed by ACSONE.
- 43. By Numérigraphe
-
[MERGE] fixes from 7.0-inventory-
location - 44. By Numérigraphe
-
[MERGE] take subinventories into account when validating an exhaustive structured inventory
- 45. By Numérigraphe
-
[MERGE] no-change commit to close acsone's MP
- 46. By Laetitia Gangloff (Acsone)
-
[MERGE] raise the same exception as the standard so the other parts of the code can catch it properly
- 47. By Numérigraphe
-
[IMP] add button to open subinventories and progresbar on inventory header.
- 48. By Numérigraphe
-
[IMP] French translation
Unmerged revisions
- 48. By Numérigraphe
-
[IMP] French translation
- 47. By Numérigraphe
-
[IMP] add button to open subinventories and progresbar on inventory header.
- 46. By Laetitia Gangloff (Acsone)
-
[MERGE] raise the same exception as the standard so the other parts of the code can catch it properly
- 45. By Numérigraphe
-
[MERGE] no-change commit to close acsone's MP
- 44. By Numérigraphe
-
[MERGE] take subinventories into account when validating an exhaustive structured inventory
- 43. By Numérigraphe
-
[MERGE] fixes from 7.0-inventory-
location - 42. By Loïc Bellier - Numérigraphe
-
[MERGE]: Exception fault fixed by ACSONE.
- 41. By Loïc Bellier - Numérigraphe
-
[MERGE]: Fix some bugs. Add Merge Proposal of Laetitia Gangloff from ASCONE and thanks to her.
- 40. By Loïc Bellier - Numérigraphe
-
[MERGE]: merge from dev branch
- 39. By Loïc Bellier - Numérigraphe
-
[MERGE]: From dev branch
Preview Diff
1 | === added directory 'stock_inventory_hierarchical' | |||
2 | === added file 'stock_inventory_hierarchical/__init__.py' | |||
3 | --- stock_inventory_hierarchical/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ stock_inventory_hierarchical/__init__.py 2014-06-16 10:01:17 +0000 | |||
5 | @@ -0,0 +1,28 @@ | |||
6 | 1 | # -*- coding: utf-8 -*- | ||
7 | 2 | ############################################################################## | ||
8 | 3 | # | ||
9 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
10 | 5 | # | ||
11 | 6 | # This program is free software: you can redistribute it and/or modify | ||
12 | 7 | # it under the terms of the GNU General Public License as published by | ||
13 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
14 | 9 | # (at your option) any later version. | ||
15 | 10 | # | ||
16 | 11 | # This program is distributed in the hope that it will be useful, | ||
17 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | 14 | # GNU General Public License for more details. | ||
20 | 15 | # | ||
21 | 16 | # You should have received a copy of the GNU General Public License | ||
22 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
23 | 18 | # | ||
24 | 19 | ############################################################################## | ||
25 | 20 | |||
26 | 21 | # This package-wide list keeps the names of the field that must be | ||
27 | 22 | # propagated from root inventories to their children. | ||
28 | 23 | # Add field names in the Model's definition. | ||
29 | 24 | PARENT_VALUES = [] | ||
30 | 25 | |||
31 | 26 | import hierarchical_inventory | ||
32 | 27 | # Bring the main exception into the package's scope for easier reuse | ||
33 | 28 | from .exceptions import HierarchicalInventoryException | ||
34 | 0 | 29 | ||
35 | === added file 'stock_inventory_hierarchical/__openerp__.py' | |||
36 | --- stock_inventory_hierarchical/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
37 | +++ stock_inventory_hierarchical/__openerp__.py 2014-06-16 10:01:17 +0000 | |||
38 | @@ -0,0 +1,46 @@ | |||
39 | 1 | # -*- coding: utf-8 -*- | ||
40 | 2 | ############################################################################## | ||
41 | 3 | # | ||
42 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
43 | 5 | # | ||
44 | 6 | # This program is free software: you can redistribute it and/or modify | ||
45 | 7 | # it under the terms of the GNU General Public License as published by | ||
46 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
47 | 9 | # (at your option) any later version. | ||
48 | 10 | # | ||
49 | 11 | # This program is distributed in the hope that it will be useful, | ||
50 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
51 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
52 | 14 | # GNU General Public License for more details. | ||
53 | 15 | # | ||
54 | 16 | # You should have received a copy of the GNU General Public License | ||
55 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
56 | 18 | # | ||
57 | 19 | ############################################################################## | ||
58 | 20 | |||
59 | 21 | { | ||
60 | 22 | "name": "Hierarchical Physical Inventory", | ||
61 | 23 | "version": "1.1", | ||
62 | 24 | "depends": ["stock"], | ||
63 | 25 | "author": "Numérigraphe", | ||
64 | 26 | "category": "Warehouse Management", | ||
65 | 27 | "description": """ | ||
66 | 28 | Hierarchical structure for Physical Inventories and sub-Inventories | ||
67 | 29 | =================================================================== | ||
68 | 30 | |||
69 | 31 | This module adds a parent-child relationship between Physical Inventories, to | ||
70 | 32 | help users manage complex inventories. | ||
71 | 33 | Using several inventories, you can distribute the counting to several persons | ||
72 | 34 | and still keep a clear overview of global Inventory's status. | ||
73 | 35 | |||
74 | 36 | OpenERP will make sure the status of the Inventory and it's Sub-Inventories are | ||
75 | 37 | consistent. | ||
76 | 38 | """, | ||
77 | 39 | "data": ["hierarchical_inventory_view.xml"], | ||
78 | 40 | "test": ["test/hierarchical_inventory_test.yml"], | ||
79 | 41 | "demo": ["hierarchical_inventory_demo.xml"], | ||
80 | 42 | "images": [ | ||
81 | 43 | "inventory_form.png", | ||
82 | 44 | "inventory_form_actions.png", | ||
83 | 45 | ], | ||
84 | 46 | } | ||
85 | 0 | 47 | ||
86 | === added file 'stock_inventory_hierarchical/exceptions.py' | |||
87 | --- stock_inventory_hierarchical/exceptions.py 1970-01-01 00:00:00 +0000 | |||
88 | +++ stock_inventory_hierarchical/exceptions.py 2014-06-16 10:01:17 +0000 | |||
89 | @@ -0,0 +1,26 @@ | |||
90 | 1 | # -*- coding: utf-8 -*- | ||
91 | 2 | ############################################################################## | ||
92 | 3 | # | ||
93 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
94 | 5 | # | ||
95 | 6 | # This program is free software: you can redistribute it and/or modify | ||
96 | 7 | # it under the terms of the GNU General Public License as published by | ||
97 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
98 | 9 | # (at your option) any later version. | ||
99 | 10 | # | ||
100 | 11 | # This program is distributed in the hope that it will be useful, | ||
101 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
102 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
103 | 14 | # GNU General Public License for more details. | ||
104 | 15 | # | ||
105 | 16 | # You should have received a copy of the GNU General Public License | ||
106 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
107 | 18 | # | ||
108 | 19 | ############################################################################## | ||
109 | 20 | |||
110 | 21 | from openerp.osv import orm | ||
111 | 22 | |||
112 | 23 | |||
113 | 24 | class HierarchicalInventoryException(orm.except_orm): | ||
114 | 25 | """The operation is not possible for a hierarchical inventory""" | ||
115 | 26 | pass | ||
116 | 0 | 27 | ||
117 | === added file 'stock_inventory_hierarchical/hierarchical_inventory.py' | |||
118 | --- stock_inventory_hierarchical/hierarchical_inventory.py 1970-01-01 00:00:00 +0000 | |||
119 | +++ stock_inventory_hierarchical/hierarchical_inventory.py 2014-06-16 10:01:17 +0000 | |||
120 | @@ -0,0 +1,202 @@ | |||
121 | 1 | # -*- coding: utf-8 -*- | ||
122 | 2 | ############################################################################## | ||
123 | 3 | # | ||
124 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
125 | 5 | # | ||
126 | 6 | # This program is free software: you can redistribute it and/or modify | ||
127 | 7 | # it under the terms of the GNU General Public License as published by | ||
128 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
129 | 9 | # (at your option) any later version. | ||
130 | 10 | # | ||
131 | 11 | # This program is distributed in the hope that it will be useful, | ||
132 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
133 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
134 | 14 | # GNU General Public License for more details. | ||
135 | 15 | # | ||
136 | 16 | # You should have received a copy of the GNU General Public License | ||
137 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
138 | 18 | # | ||
139 | 19 | ############################################################################## | ||
140 | 20 | |||
141 | 21 | from openerp.osv import orm, fields | ||
142 | 22 | from openerp.tools.translate import _ | ||
143 | 23 | |||
144 | 24 | from .exceptions import HierarchicalInventoryException | ||
145 | 25 | |||
146 | 26 | # Add the date to the list of fields we must propagate to children inventories | ||
147 | 27 | from . import PARENT_VALUES | ||
148 | 28 | PARENT_VALUES.append('date') | ||
149 | 29 | |||
150 | 30 | |||
151 | 31 | class HierarchicalInventory(orm.Model): | ||
152 | 32 | _inherit = 'stock.inventory' | ||
153 | 33 | |||
154 | 34 | _parent_store = True | ||
155 | 35 | _parent_order = 'date, name' | ||
156 | 36 | _order = 'parent_left' | ||
157 | 37 | |||
158 | 38 | def name_get(self, cr, uid, ids, context=None): | ||
159 | 39 | """Show the parent inventory's name in the name of the children | ||
160 | 40 | |||
161 | 41 | :param dict context: the ``inventory_display`` key can be | ||
162 | 42 | used to select the short version of the | ||
163 | 43 | inventory name (without the direct parent), | ||
164 | 44 | when set to ``'short'``. The default is | ||
165 | 45 | the long version.""" | ||
166 | 46 | if context is None: | ||
167 | 47 | context = {} | ||
168 | 48 | if context.get('inventory_display') == 'short': | ||
169 | 49 | # Short name context: just do the usual stuff | ||
170 | 50 | return super(HierarchicalInventory, self).name_get( | ||
171 | 51 | cr, uid, ids, context=context) | ||
172 | 52 | if isinstance(ids, (list, tuple)) and not len(ids): | ||
173 | 53 | return [] | ||
174 | 54 | if isinstance(ids, (long, int)): | ||
175 | 55 | ids = [ids] | ||
176 | 56 | reads = self.read(cr, uid, ids, ['name', 'parent_id'], context=context) | ||
177 | 57 | res = [] | ||
178 | 58 | for record in reads: | ||
179 | 59 | name = record['name'] | ||
180 | 60 | if record['parent_id']: | ||
181 | 61 | name = record['parent_id'][1] + ' / ' + name | ||
182 | 62 | res.append((record['id'], name)) | ||
183 | 63 | return res | ||
184 | 64 | |||
185 | 65 | def name_search(self, cr, uid, name='', args=None, operator='ilike', | ||
186 | 66 | context=None, limit=100): | ||
187 | 67 | """Enable search on value returned by name_get ("parent / child")""" | ||
188 | 68 | if not args: | ||
189 | 69 | args = [] | ||
190 | 70 | if not context: | ||
191 | 71 | context = {} | ||
192 | 72 | if name: | ||
193 | 73 | # Make sure name_search is symmetric to name_get | ||
194 | 74 | name = name.split(' / ')[-1] | ||
195 | 75 | ids = self.search(cr, uid, [('name', operator, name)] + args, | ||
196 | 76 | limit=limit, context=context) | ||
197 | 77 | else: | ||
198 | 78 | ids = self.search(cr, uid, args, limit=limit, context=context) | ||
199 | 79 | return self.name_get(cr, uid, ids, context=context) | ||
200 | 80 | |||
201 | 81 | def _complete_name(self, cr, uid, ids, field_name, arg, context=None): | ||
202 | 82 | """Function-field wrapper to get the complete name from name_get""" | ||
203 | 83 | res = self.name_get(cr, uid, ids, context=context) | ||
204 | 84 | return dict(res) | ||
205 | 85 | |||
206 | 86 | def _progress_rate(self, cr, uid, ids, field_name, arg, context=None): | ||
207 | 87 | """Rate of (sub)inventories done/total""" | ||
208 | 88 | rates = {} | ||
209 | 89 | for current_id in ids: | ||
210 | 90 | nb = self.search( | ||
211 | 91 | cr, uid, [('parent_id', 'child_of', current_id)], | ||
212 | 92 | context=context, count=True) | ||
213 | 93 | if not nb: | ||
214 | 94 | # No inventory, consider it's 0% done | ||
215 | 95 | rates[current_id] = 0 | ||
216 | 96 | continue | ||
217 | 97 | nb_done = self.search( | ||
218 | 98 | cr, uid, [('parent_id', 'child_of', current_id), | ||
219 | 99 | ('state', '=', 'done')], | ||
220 | 100 | context=context, count=True) | ||
221 | 101 | rates[current_id] = 100 * nb_done / nb | ||
222 | 102 | return rates | ||
223 | 103 | |||
224 | 104 | _columns = { | ||
225 | 105 | # name_get() only changes the default name of the record, not the | ||
226 | 106 | # content of the field "name" so we add another field for that | ||
227 | 107 | 'complete_name': fields.function( | ||
228 | 108 | _complete_name, type="char", | ||
229 | 109 | string='Complete reference'), | ||
230 | 110 | 'parent_id': fields.many2one( | ||
231 | 111 | 'stock.inventory', 'Parent', ondelete='cascade', readonly=True, | ||
232 | 112 | states={'draft': [('readonly', False)]}), | ||
233 | 113 | 'inventory_ids': fields.one2many( | ||
234 | 114 | 'stock.inventory', 'parent_id', 'List of Sub-inventories', | ||
235 | 115 | readonly=True, states={'draft': [('readonly', False)]}), | ||
236 | 116 | 'parent_left': fields.integer('Parent Left', select=1), | ||
237 | 117 | 'parent_right': fields.integer('Parent Right', select=1), | ||
238 | 118 | 'progress_rate': fields.function( | ||
239 | 119 | _progress_rate, string='Progress', type='float'), | ||
240 | 120 | } | ||
241 | 121 | |||
242 | 122 | _constraints = [ | ||
243 | 123 | (orm.Model._check_recursion, | ||
244 | 124 | 'Error: You can not create recursive inventories.', | ||
245 | 125 | ['parent_id']), | ||
246 | 126 | ] | ||
247 | 127 | |||
248 | 128 | def create(self, cr, uid, vals, context=None): | ||
249 | 129 | """Copy selected values from parent to child""" | ||
250 | 130 | if vals and vals.get('parent_id'): | ||
251 | 131 | existing_fields = self.fields_get_keys(cr, uid, context=context) | ||
252 | 132 | parent_values = self.read(cr, uid, [vals['parent_id']], | ||
253 | 133 | PARENT_VALUES, context=context) | ||
254 | 134 | vals = vals.copy() | ||
255 | 135 | vals.update({field: parent_values[0][field] | ||
256 | 136 | for field in PARENT_VALUES | ||
257 | 137 | if field in existing_fields}) | ||
258 | 138 | return super(HierarchicalInventory, self).create( | ||
259 | 139 | cr, uid, vals, context=context) | ||
260 | 140 | |||
261 | 141 | def write(self, cr, uid, ids, vals, context=None): | ||
262 | 142 | """Copy selected values from parent to children""" | ||
263 | 143 | if context is None: | ||
264 | 144 | context = {} | ||
265 | 145 | |||
266 | 146 | values = super(HierarchicalInventory, self).write( | ||
267 | 147 | cr, uid, ids, vals, context=context) | ||
268 | 148 | if not vals or context.get('norecurse', False): | ||
269 | 149 | return values | ||
270 | 150 | |||
271 | 151 | # filter the fields we want to propagate | ||
272 | 152 | children_values = { | ||
273 | 153 | field: vals[field] for field in PARENT_VALUES if field in vals | ||
274 | 154 | } | ||
275 | 155 | if not children_values: | ||
276 | 156 | return values | ||
277 | 157 | |||
278 | 158 | if not isinstance(ids, list): | ||
279 | 159 | ids = [ids] | ||
280 | 160 | # The context disables recursion - children are already included | ||
281 | 161 | return self.write( | ||
282 | 162 | cr, uid, self.search(cr, uid, [('parent_id', 'child_of', ids)]), | ||
283 | 163 | children_values, context=dict(context, norecurse=True)) | ||
284 | 164 | |||
285 | 165 | def action_cancel_inventory(self, cr, uid, ids, context=None): | ||
286 | 166 | """Cancel inventory only if all the parents are canceled""" | ||
287 | 167 | inventories = self.browse(cr, uid, ids, context=context) | ||
288 | 168 | for inventory in inventories: | ||
289 | 169 | while inventory.parent_id: | ||
290 | 170 | inventory = inventory.parent_id | ||
291 | 171 | if inventory.state != 'cancel': | ||
292 | 172 | raise HierarchicalInventoryException( | ||
293 | 173 | _('Warning'), | ||
294 | 174 | _('One of the parent Inventories is not canceled.')) | ||
295 | 175 | return super(HierarchicalInventory, | ||
296 | 176 | self).action_cancel_inventory(cr, uid, ids, | ||
297 | 177 | context=context) | ||
298 | 178 | |||
299 | 179 | def action_confirm(self, cr, uid, ids, context=None): | ||
300 | 180 | """Confirm inventory only if all the children are confirmed""" | ||
301 | 181 | children_count = self.search( | ||
302 | 182 | cr, uid, [('parent_id', 'child_of', ids), | ||
303 | 183 | ('state', 'not in', ['confirm', 'done'])], | ||
304 | 184 | context=context, count=True) | ||
305 | 185 | if children_count > 1: | ||
306 | 186 | raise HierarchicalInventoryException( | ||
307 | 187 | _('Warning'), | ||
308 | 188 | _('Some Sub-inventories are not confirmed.')) | ||
309 | 189 | return super(HierarchicalInventory, self).action_confirm( | ||
310 | 190 | cr, uid, ids, context=context) | ||
311 | 191 | |||
312 | 192 | def action_done(self, cr, uid, ids, context=None): | ||
313 | 193 | """Perform validation only if all the children states are 'done'.""" | ||
314 | 194 | children_count = self.search(cr, uid, [('parent_id', 'child_of', ids), | ||
315 | 195 | ('state', '!=', 'done')], | ||
316 | 196 | context=context, count=True) | ||
317 | 197 | if children_count > 1: | ||
318 | 198 | raise HierarchicalInventoryException( | ||
319 | 199 | _('Warning'), | ||
320 | 200 | _('Some Sub-inventories are not validated.')) | ||
321 | 201 | return super(HierarchicalInventory, self).action_done( | ||
322 | 202 | cr, uid, ids, context=context) | ||
323 | 0 | 203 | ||
324 | === added file 'stock_inventory_hierarchical/hierarchical_inventory_demo.xml' | |||
325 | --- stock_inventory_hierarchical/hierarchical_inventory_demo.xml 1970-01-01 00:00:00 +0000 | |||
326 | +++ stock_inventory_hierarchical/hierarchical_inventory_demo.xml 2014-06-16 10:01:17 +0000 | |||
327 | @@ -0,0 +1,17 @@ | |||
328 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
329 | 2 | <openerp> | ||
330 | 3 | <data noupdate="0"> | ||
331 | 4 | <!-- Example Inventory with Sub-Inventories. --> | ||
332 | 5 | <record id="stock_inventory_parent0" model="stock.inventory"> | ||
333 | 6 | <field name="name">Main Inventory</field> | ||
334 | 7 | </record> | ||
335 | 8 | <record id="child_1_id" model="stock.inventory"> | ||
336 | 9 | <field name="name">Sub-Inventory 1</field> | ||
337 | 10 | <field name="parent_id" ref="stock_inventory_parent0" /> | ||
338 | 11 | </record> | ||
339 | 12 | <record id="child_2_id" model="stock.inventory"> | ||
340 | 13 | <field name="name">Sub-Inventory 2</field> | ||
341 | 14 | <field name="parent_id" ref="stock_inventory_parent0" /> | ||
342 | 15 | </record> | ||
343 | 16 | </data> | ||
344 | 17 | </openerp> | ||
345 | 0 | 18 | ||
346 | === added file 'stock_inventory_hierarchical/hierarchical_inventory_view.xml' | |||
347 | --- stock_inventory_hierarchical/hierarchical_inventory_view.xml 1970-01-01 00:00:00 +0000 | |||
348 | +++ stock_inventory_hierarchical/hierarchical_inventory_view.xml 2014-06-16 10:01:17 +0000 | |||
349 | @@ -0,0 +1,78 @@ | |||
350 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
351 | 2 | <openerp> | ||
352 | 3 | <data> | ||
353 | 4 | <!-- Add parent_id and number of Sub-inventories to form view --> | ||
354 | 5 | <record model="ir.ui.view" id="stock_inventory_hierarchical_tree_view"> | ||
355 | 6 | <field name="name">hierarchical.inventory.tree</field> | ||
356 | 7 | <field name="model">stock.inventory</field> | ||
357 | 8 | <field name="inherit_id" ref="stock.view_inventory_tree" /> | ||
358 | 9 | <field name="field_parent">inventory_ids</field> | ||
359 | 10 | <field name="arch" type="xml"> | ||
360 | 11 | <xpath expr="//field[@name='name']" position="replace"> | ||
361 | 12 | <field name="complete_name" string="Reference"/> | ||
362 | 13 | </xpath> | ||
363 | 14 | <xpath expr="//field[@name='state']" position="after"> | ||
364 | 15 | <field name="progress_rate" widget="progressbar" /> | ||
365 | 16 | </xpath> | ||
366 | 17 | </field> | ||
367 | 18 | </record> | ||
368 | 19 | |||
369 | 20 | <!-- Add the parent_id filter to search view --> | ||
370 | 21 | <record model="ir.ui.view" id="view_inventory_subinventories_filter"> | ||
371 | 22 | <field name="name">hierarchical.inventory.filter</field> | ||
372 | 23 | <field name="model">stock.inventory</field> | ||
373 | 24 | <field name="inherit_id" ref="stock.view_inventory_filter" /> | ||
374 | 25 | <field name="arch" type="xml"> | ||
375 | 26 | <xpath expr="//field[@name='name']" position="before"> | ||
376 | 27 | <filter icon="terp-check" name="main_inventories" string="Main inventories" domain="[('parent_id', '=', False)]" help="Only select inventories that have no parents." /> | ||
377 | 28 | <separator orientation="vertical"/> | ||
378 | 29 | </xpath> | ||
379 | 30 | <xpath expr="//field[@name='date']" position="after"> | ||
380 | 31 | <field name="parent_id" /> | ||
381 | 32 | </xpath> | ||
382 | 33 | </field> | ||
383 | 34 | </record> | ||
384 | 35 | <!-- Show main inventories by default --> | ||
385 | 36 | <record id="stock.action_inventory_form" model="ir.actions.act_window"> | ||
386 | 37 | <field name="context">{'full':'1', 'search_default_main_inventories':1}</field> | ||
387 | 38 | </record> | ||
388 | 39 | |||
389 | 40 | <record model="ir.ui.view" id="stock_inventory_hierarchical_form_view"> | ||
390 | 41 | <field name="name">hierarchical.inventory.form</field> | ||
391 | 42 | <field name="model">stock.inventory</field> | ||
392 | 43 | <field name="inherit_id" ref="stock.view_inventory_form" /> | ||
393 | 44 | <field name="arch" type="xml"> | ||
394 | 45 | <xpath expr="/form//field[@name='name']" position="after"> | ||
395 | 46 | <field name="parent_id"/> | ||
396 | 47 | </xpath> | ||
397 | 48 | <xpath expr="/form//field[@name='date']" position="attributes"> | ||
398 | 49 | <attribute name="attrs">{'readonly':[('parent_id', '!=', False)]}</attribute> | ||
399 | 50 | </xpath> | ||
400 | 51 | <xpath | ||
401 | 52 | expr="//page[@string='General Information']" | ||
402 | 53 | position="after"> | ||
403 | 54 | <page string="Sub-inventories"> | ||
404 | 55 | <field name="inventory_ids" nolabel="1" context="{'default_parent_id': active_id}"> | ||
405 | 56 | <tree> | ||
406 | 57 | <field name="name" /> | ||
407 | 58 | <field name="state" /> | ||
408 | 59 | <field name="progress_rate" widget="progressbar" /> | ||
409 | 60 | </tree> | ||
410 | 61 | </field> | ||
411 | 62 | </page> | ||
412 | 63 | </xpath> | ||
413 | 64 | </field> | ||
414 | 65 | </record> | ||
415 | 66 | |||
416 | 67 | <!-- Open the children of the current Inventory in a distinct list | ||
417 | 68 | to let users work in a normal window instead of a popup --> | ||
418 | 69 | <act_window id="action_view_sub_inventory" | ||
419 | 70 | name="View Sub-inventories" | ||
420 | 71 | res_model="stock.inventory" | ||
421 | 72 | src_model="stock.inventory" | ||
422 | 73 | view_mode="tree,form" | ||
423 | 74 | view_type="form" | ||
424 | 75 | domain="[('parent_id', 'child_of', active_id),('id', '!=', active_id)]" | ||
425 | 76 | context="{'full':1, 'search_default_main_inventories':0}"/> | ||
426 | 77 | </data> | ||
427 | 78 | </openerp> | ||
428 | 0 | 79 | ||
429 | === added directory 'stock_inventory_hierarchical/i18n' | |||
430 | === added file 'stock_inventory_hierarchical/i18n/fr.po' | |||
431 | --- stock_inventory_hierarchical/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
432 | +++ stock_inventory_hierarchical/i18n/fr.po 2014-06-16 10:01:17 +0000 | |||
433 | @@ -0,0 +1,112 @@ | |||
434 | 1 | # Translation of OpenERP Server. | ||
435 | 2 | # This file contains the translation of the following modules: | ||
436 | 3 | # * stock_inventory_hierarchical | ||
437 | 4 | # | ||
438 | 5 | msgid "" | ||
439 | 6 | msgstr "" | ||
440 | 7 | "Project-Id-Version: OpenERP Server 6.0.4\n" | ||
441 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
442 | 9 | "POT-Creation-Date: 2013-09-25 13:43+0000\n" | ||
443 | 10 | "PO-Revision-Date: 2013-09-25 13:43+0000\n" | ||
444 | 11 | "Last-Translator: <>\n" | ||
445 | 12 | "Language-Team: \n" | ||
446 | 13 | "MIME-Version: 1.0\n" | ||
447 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
448 | 15 | "Content-Transfer-Encoding: \n" | ||
449 | 16 | "Plural-Forms: \n" | ||
450 | 17 | |||
451 | 18 | #. module: stock_inventory_hierarchical | ||
452 | 19 | #: field:stock.inventory,complete_name:0 | ||
453 | 20 | msgid "Complete reference" | ||
454 | 21 | msgstr "Réference complète" | ||
455 | 22 | |||
456 | 23 | #. module: stock_inventory_hierarchical | ||
457 | 24 | #: field:stock.inventory,progress_rate:0 | ||
458 | 25 | msgid "Done" | ||
459 | 26 | msgstr "Terminé" | ||
460 | 27 | |||
461 | 28 | #. module: stock_inventory_hierarchical | ||
462 | 29 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:108 | ||
463 | 30 | #: constraint:stock.inventory:0 | ||
464 | 31 | #, python-format | ||
465 | 32 | msgid "Error: You can not create recursive inventories." | ||
466 | 33 | msgstr "Erreur : Vous ne pouvez pas créer d'inventaire récursifs." | ||
467 | 34 | |||
468 | 35 | #. module: stock_inventory_hierarchical | ||
469 | 36 | #: model:ir.model,name:stock_inventory_hierarchical.model_stock_inventory | ||
470 | 37 | msgid "Gestion des stocks" | ||
471 | 38 | msgstr "Gestion des stocks" | ||
472 | 39 | |||
473 | 40 | #. module: stock_inventory_hierarchical | ||
474 | 41 | #: field:stock.inventory,inventory_ids:0 | ||
475 | 42 | msgid "List of Sub-inventories" | ||
476 | 43 | msgstr "Liste des sous-inventaires" | ||
477 | 44 | |||
478 | 45 | #. module: stock_inventory_hierarchical | ||
479 | 46 | #: view:stock.inventory:0 | ||
480 | 47 | msgid "Main inventories" | ||
481 | 48 | msgstr "Inventaires principaux" | ||
482 | 49 | |||
483 | 50 | #. module: stock_inventory_hierarchical | ||
484 | 51 | #: view:stock.inventory:0 | ||
485 | 52 | msgid "Number of Sub-inventories" | ||
486 | 53 | msgstr "Nombre de sous-inventaires" | ||
487 | 54 | |||
488 | 55 | #. module: stock_inventory_hierarchical | ||
489 | 56 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:180 | ||
490 | 57 | #, python-format | ||
491 | 58 | msgid "One of the parent Inventories is not canceled." | ||
492 | 59 | msgstr "Un des inventaires pères n'est pas annulé." | ||
493 | 60 | |||
494 | 61 | #. module: stock_inventory_hierarchical | ||
495 | 62 | #: constraint:stock.inventory:0 | ||
496 | 63 | msgid "Other Physical inventories are being conducted using the same Locations." | ||
497 | 64 | msgstr "Certains emplacements sont déjà dans un autre inventaire." | ||
498 | 65 | |||
499 | 66 | #. module: stock_inventory_hierarchical | ||
500 | 67 | #: field:stock.inventory,parent_id:0 | ||
501 | 68 | msgid "Parent" | ||
502 | 69 | msgstr "Parent" | ||
503 | 70 | |||
504 | 71 | #. module: stock_inventory_hierarchical | ||
505 | 72 | #: field:stock.inventory,parent_left:0 | ||
506 | 73 | msgid "Parent Left" | ||
507 | 74 | msgstr "Parent gauche" | ||
508 | 75 | |||
509 | 76 | #. module: stock_inventory_hierarchical | ||
510 | 77 | #: field:stock.inventory,parent_right:0 | ||
511 | 78 | msgid "Parent Right" | ||
512 | 79 | msgstr "Parent droit" | ||
513 | 80 | |||
514 | 81 | #. module: stock_inventory_hierarchical | ||
515 | 82 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:188 | ||
516 | 83 | #, python-format | ||
517 | 84 | msgid "Some Sub-inventories are not confirmed." | ||
518 | 85 | msgstr "Certains sous-inventaires ne sont pas confirmés." | ||
519 | 86 | |||
520 | 87 | #. module: stock_inventory_hierarchical | ||
521 | 88 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:196 | ||
522 | 89 | #, python-format | ||
523 | 90 | msgid "Some Sub-inventories are not validated." | ||
524 | 91 | msgstr "Certains sous-inventaires ne sont pas terminés." | ||
525 | 92 | |||
526 | 93 | #. module: stock_inventory_hierarchical | ||
527 | 94 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical.action_view_sub_inventory | ||
528 | 95 | #: view:stock.inventory:0 | ||
529 | 96 | msgid "View Sub-inventories" | ||
530 | 97 | msgstr "Voir les sous-inventaires" | ||
531 | 98 | |||
532 | 99 | #. module: stock_inventory_hierarchical | ||
533 | 100 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:130 | ||
534 | 101 | #, python-format | ||
535 | 102 | msgid "Sub-inventory: %s" | ||
536 | 103 | msgstr "Sous-inventaire : %s" | ||
537 | 104 | |||
538 | 105 | #. module: stock_inventory_hierarchical | ||
539 | 106 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:180 | ||
540 | 107 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:188 | ||
541 | 108 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:196 | ||
542 | 109 | #, python-format | ||
543 | 110 | msgid "Warning" | ||
544 | 111 | msgstr "Attention" | ||
545 | 112 | |||
546 | 0 | 113 | ||
547 | === added directory 'stock_inventory_hierarchical/images' | |||
548 | === added file 'stock_inventory_hierarchical/images/inventory_form.png' | |||
549 | 1 | Binary files stock_inventory_hierarchical/images/inventory_form.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical/images/inventory_form.png 2014-06-16 10:01:17 +0000 differ | 114 | Binary files stock_inventory_hierarchical/images/inventory_form.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical/images/inventory_form.png 2014-06-16 10:01:17 +0000 differ |
550 | === added file 'stock_inventory_hierarchical/images/inventory_form_actions.png' | |||
551 | 2 | Binary files stock_inventory_hierarchical/images/inventory_form_actions.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical/images/inventory_form_actions.png 2014-06-16 10:01:17 +0000 differ | 115 | Binary files stock_inventory_hierarchical/images/inventory_form_actions.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical/images/inventory_form_actions.png 2014-06-16 10:01:17 +0000 differ |
552 | === added directory 'stock_inventory_hierarchical/static' | |||
553 | === added directory 'stock_inventory_hierarchical/static/src' | |||
554 | === added directory 'stock_inventory_hierarchical/static/src/img' | |||
555 | === added file 'stock_inventory_hierarchical/static/src/img/icon.png' | |||
556 | 3 | Binary files stock_inventory_hierarchical/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical/static/src/img/icon.png 2014-06-16 10:01:17 +0000 differ | 116 | Binary files stock_inventory_hierarchical/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical/static/src/img/icon.png 2014-06-16 10:01:17 +0000 differ |
557 | === added directory 'stock_inventory_hierarchical/test' | |||
558 | === added file 'stock_inventory_hierarchical/test/hierarchical_inventory_test.yml' | |||
559 | --- stock_inventory_hierarchical/test/hierarchical_inventory_test.yml 1970-01-01 00:00:00 +0000 | |||
560 | +++ stock_inventory_hierarchical/test/hierarchical_inventory_test.yml 2014-06-16 10:01:17 +0000 | |||
561 | @@ -0,0 +1,96 @@ | |||
562 | 1 | - | ||
563 | 2 | In this file, i check rules about hierarchical inventories. | ||
564 | 3 | Children date must be the same of parent date for each state, | ||
565 | 4 | the state of parent and children can change only if conditions are correct. | ||
566 | 5 | - | ||
567 | 6 | Check if date of children are the same as the parent's. | ||
568 | 7 | - | ||
569 | 8 | !python {model: stock.inventory}: | | ||
570 | 9 | parent_date = self.read( | ||
571 | 10 | cr, uid, [ref('stock_inventory_parent0')], ['date'])[0]['date'] | ||
572 | 11 | child_1_date = self.read( | ||
573 | 12 | cr, uid, [ref('child_1_id')], ['date'])[0]['date'] | ||
574 | 13 | assert child_1_date == parent_date, "Date are different: %s - %s" % (parent_date, child_1_date) | ||
575 | 14 | |||
576 | 15 | child_2_date = self.read( | ||
577 | 16 | cr, uid, [ref('child_2_id')], ['date'])[0]['date'] | ||
578 | 17 | assert child_2_date == parent_date, "Date are different: %s - %s" % (parent_date, child_2_date) | ||
579 | 18 | |||
580 | 19 | - | ||
581 | 20 | Check if children cannot be canceled if the parent was not canceled. | ||
582 | 21 | I'll try to cancel both children inventory while parent inventory having "draft" state. | ||
583 | 22 | After, i'll verify the state of each inventory. | ||
584 | 23 | - | ||
585 | 24 | !python {model: stock.inventory}: | | ||
586 | 25 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
587 | 26 | try: | ||
588 | 27 | self.action_cancel_inventory(cr, uid, [ref('child_1_id')]) | ||
589 | 28 | except HierarchicalInventoryException as e: | ||
590 | 29 | log("Good ! The Inventory could not be canceled: %s" % e) | ||
591 | 30 | try: | ||
592 | 31 | self.action_cancel_inventory(cr, uid, [ref('child_2_id')]) | ||
593 | 32 | except HierarchicalInventoryException as e: | ||
594 | 33 | log("Good ! The Inventory could not be canceled: %s" % e) | ||
595 | 34 | child_1_state = self.read(cr, uid, [ref('child_1_id')], ['state'])[0]['state'] | ||
596 | 35 | assert child_1_state == 'draft', "Child inventory 1 have '%s' state. It should be 'draft'" % child_1_state | ||
597 | 36 | child_2_state = self.read(cr, uid, [ref('child_2_id')], ['state'])[0]['state'] | ||
598 | 37 | assert child_2_state == 'draft', "Child inventory 2 have '%s' state. It should be 'draft'" % child_2_state | ||
599 | 38 | |||
600 | 39 | - | ||
601 | 40 | Check if children inventory have confirm state before confirm parent inventory. | ||
602 | 41 | To check this, i'll try to confirm parent inventory when children inventory having "draft" state, | ||
603 | 42 | and i'll check if state is still 'draft'. | ||
604 | 43 | - | ||
605 | 44 | !python {model: stock.inventory}: | | ||
606 | 45 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
607 | 46 | try: | ||
608 | 47 | self.action_confirm(cr, uid, [ref('stock_inventory_parent0')]) | ||
609 | 48 | except HierarchicalInventoryException as e: | ||
610 | 49 | log("Good, the inventory could not be confirmed: %s", e) | ||
611 | 50 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
612 | 51 | assert parent_state == 'draft', "Parent inventory have '%s' state. It should be 'draft'" % parent_state | ||
613 | 52 | |||
614 | 53 | - | ||
615 | 54 | In order, i'll confirm the children inventories, and the parent inventory after. | ||
616 | 55 | - | ||
617 | 56 | !python {model: stock.inventory}: | | ||
618 | 57 | self.action_confirm(cr, uid, [ref('child_1_id')]) | ||
619 | 58 | child_1_state = self.read(cr, uid, [ref('child_1_id')], ['state'])[0]['state'] | ||
620 | 59 | assert child_1_state == 'confirm', "Child inventory 1 have '%s' state. It should be 'confirm'" % child_1_state | ||
621 | 60 | |||
622 | 61 | self.action_confirm(cr, uid, [ref('child_2_id')]) | ||
623 | 62 | child_2_state = self.read(cr, uid, [ref('child_2_id')], ['state'])[0]['state'] | ||
624 | 63 | assert child_2_state == 'confirm', "Child inventory 2 have '%s' state. It should be 'confirm'" % child_2_state | ||
625 | 64 | |||
626 | 65 | self.action_confirm(cr, uid, [ref('stock_inventory_parent0')]) | ||
627 | 66 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
628 | 67 | assert parent_state == 'confirm', "Parent inventory have '%s' state. It should be 'confirm'" % parent_state | ||
629 | 68 | |||
630 | 69 | - | ||
631 | 70 | Check if children inventory have done state before validate parent inventory. | ||
632 | 71 | I'll try to validate parent inventory before children. | ||
633 | 72 | - | ||
634 | 73 | !python {model: stock.inventory}: | | ||
635 | 74 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
636 | 75 | try: | ||
637 | 76 | self.action_done(cr, uid, [ref('stock_inventory_parent0')]) | ||
638 | 77 | except HierarchicalInventoryException as e: | ||
639 | 78 | log("Good, the inventory could not be validated: %s", e) | ||
640 | 79 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
641 | 80 | assert parent_state == 'confirm', "Parent inventory have '%s' state. It should be 'confirm'" % parent_state | ||
642 | 81 | |||
643 | 82 | - | ||
644 | 83 | Now, i'll validate all children inventory before validate the parent. | ||
645 | 84 | - | ||
646 | 85 | !python {model: stock.inventory}: | | ||
647 | 86 | self.action_done(cr, uid, [ref('child_1_id')]) | ||
648 | 87 | child_1_state = self.read(cr, uid, [ref('child_1_id')], ['state'])[0]['state'] | ||
649 | 88 | assert child_1_state == 'done', "Child inventory 1 have '%s' state. It should be 'done'" % child_1_state | ||
650 | 89 | |||
651 | 90 | self.action_done(cr, uid, [ref('child_2_id')]) | ||
652 | 91 | child_2_state = self.read(cr, uid, [ref('child_2_id')], ['state'])[0]['state'] | ||
653 | 92 | assert child_2_state == 'done', "Child inventory 2 have '%s' state. It should be 'done'" % child_2_state | ||
654 | 93 | |||
655 | 94 | self.action_done(cr, uid, [ref('stock_inventory_parent0')]) | ||
656 | 95 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
657 | 96 | assert parent_state == 'done', "Parent inventory have '%s' state. It should be 'done'" % parent_state | ||
658 | 0 | 97 | ||
659 | === added directory 'stock_inventory_hierarchical_location' | |||
660 | === added file 'stock_inventory_hierarchical_location/__init__.py' | |||
661 | --- stock_inventory_hierarchical_location/__init__.py 1970-01-01 00:00:00 +0000 | |||
662 | +++ stock_inventory_hierarchical_location/__init__.py 2014-06-16 10:01:17 +0000 | |||
663 | @@ -0,0 +1,22 @@ | |||
664 | 1 | # -*- coding: utf-8 -*- | ||
665 | 2 | ############################################################################## | ||
666 | 3 | # | ||
667 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
668 | 5 | # | ||
669 | 6 | # This program is free software: you can redistribute it and/or modify | ||
670 | 7 | # it under the terms of the GNU General Public License as published by | ||
671 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
672 | 9 | # (at your option) any later version. | ||
673 | 10 | # | ||
674 | 11 | # This program is distributed in the hope that it will be useful, | ||
675 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
676 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
677 | 14 | # GNU General Public License for more details. | ||
678 | 15 | # | ||
679 | 16 | # You should have received a copy of the GNU General Public License | ||
680 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
681 | 18 | # | ||
682 | 19 | ############################################################################## | ||
683 | 20 | |||
684 | 21 | from . import inventory_hierarchical_location | ||
685 | 22 | from . import wizard | ||
686 | 0 | 23 | ||
687 | === added file 'stock_inventory_hierarchical_location/__openerp__.py' | |||
688 | --- stock_inventory_hierarchical_location/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
689 | +++ stock_inventory_hierarchical_location/__openerp__.py 2014-06-16 10:01:17 +0000 | |||
690 | @@ -0,0 +1,48 @@ | |||
691 | 1 | # -*- coding: utf-8 -*- | ||
692 | 2 | ############################################################################## | ||
693 | 3 | # | ||
694 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
695 | 5 | # | ||
696 | 6 | # This program is free software: you can redistribute it and/or modify | ||
697 | 7 | # it under the terms of the GNU General Public License as published by | ||
698 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
699 | 9 | # (at your option) any later version. | ||
700 | 10 | # | ||
701 | 11 | # This program is distributed in the hope that it will be useful, | ||
702 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
703 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
704 | 14 | # GNU General Public License for more details. | ||
705 | 15 | # | ||
706 | 16 | # You should have received a copy of the GNU General Public License | ||
707 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
708 | 18 | # | ||
709 | 19 | ############################################################################## | ||
710 | 20 | |||
711 | 21 | { | ||
712 | 22 | "name": "Exhaustive and hierarchical Stock Inventories", | ||
713 | 23 | "version": "1.1", | ||
714 | 24 | "depends": ["stock_inventory_hierarchical", "stock_inventory_location"], | ||
715 | 25 | "auto_install": True, | ||
716 | 26 | "author": u"Numérigraphe", | ||
717 | 27 | "category": "Hidden", | ||
718 | 28 | "description": """ | ||
719 | 29 | Make exhaustive Inventories aware of their Sub-Inventories. | ||
720 | 30 | =========================================================== | ||
721 | 31 | |||
722 | 32 | This module allows an inventory to contain a general Location, | ||
723 | 33 | and it's sub-inventories to contain some of it's sub-Locations. | ||
724 | 34 | It will prevent you from setting the Inventories and sub-Inventories | ||
725 | 35 | in inconsistent status. | ||
726 | 36 | |||
727 | 37 | This module will be installed automatically if the modules | ||
728 | 38 | "stock_inventory_location" and "stock_inventory_hierarchical" are both | ||
729 | 39 | installed. | ||
730 | 40 | You must keep this module installed to ensure proper functioning. | ||
731 | 41 | |||
732 | 42 | """, | ||
733 | 43 | "data": [ | ||
734 | 44 | "inventory_hierarchical_location_view.xml", | ||
735 | 45 | ], | ||
736 | 46 | "test": ["tests/inventory_hierarchical_location_test.yml"], | ||
737 | 47 | "demo": ["inventory_hierarchical_location_demo.xml"], | ||
738 | 48 | } | ||
739 | 0 | 49 | ||
740 | === added directory 'stock_inventory_hierarchical_location/i18n' | |||
741 | === added file 'stock_inventory_hierarchical_location/i18n/fr.po' | |||
742 | --- stock_inventory_hierarchical_location/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
743 | +++ stock_inventory_hierarchical_location/i18n/fr.po 2014-06-16 10:01:17 +0000 | |||
744 | @@ -0,0 +1,127 @@ | |||
745 | 1 | # Translation of OpenERP Server. | ||
746 | 2 | # This file contains the translation of the following modules: | ||
747 | 3 | # * stock_inventory_hierarchical_location | ||
748 | 4 | # | ||
749 | 5 | msgid "" | ||
750 | 6 | msgstr "" | ||
751 | 7 | "Project-Id-Version: OpenERP Server 6.0.4\n" | ||
752 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
753 | 9 | "POT-Creation-Date: 2013-09-25 13:55+0000\n" | ||
754 | 10 | "PO-Revision-Date: 2013-09-25 13:55+0000\n" | ||
755 | 11 | "Last-Translator: <>\n" | ||
756 | 12 | "Language-Team: \n" | ||
757 | 13 | "MIME-Version: 1.0\n" | ||
758 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
759 | 15 | "Content-Transfer-Encoding: \n" | ||
760 | 16 | "Plural-Forms: \n" | ||
761 | 17 | |||
762 | 18 | #. module: stock_inventory_hierarchical_location | ||
763 | 19 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical_location.action_view_stock_inventory_missing_location | ||
764 | 20 | msgid "Confirm missing location" | ||
765 | 21 | msgstr "Confirmer les emplacements manquants" | ||
766 | 22 | |||
767 | 23 | #. module: stock_inventory_hierarchical_location | ||
768 | 24 | #: view:stock.inventory.missing.location:0 | ||
769 | 25 | msgid "Confirm missing locations" | ||
770 | 26 | msgstr "Confirmer les emplacements manquants" | ||
771 | 27 | |||
772 | 28 | #. module: stock_inventory_hierarchical_location | ||
773 | 29 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory_uninventoried_locations | ||
774 | 30 | msgid "Confirm the uninventoried Locations." | ||
775 | 31 | msgstr "Confirmer les emplacements non inventoriés." | ||
776 | 32 | |||
777 | 33 | #. module: stock_inventory_hierarchical_location | ||
778 | 34 | #: view:stock.inventory.missing.location:0 | ||
779 | 35 | msgid "Do you want to continue ?" | ||
780 | 36 | msgstr "Voulez-vous continuer ?" | ||
781 | 37 | |||
782 | 38 | #. module: stock_inventory_hierarchical_location | ||
783 | 39 | #: constraint:stock.inventory:0 | ||
784 | 40 | msgid "Error! You can not create recursive inventories." | ||
785 | 41 | msgstr "Erreur! Vous ne pouvez pas créer un inventaire récursif." | ||
786 | 42 | |||
787 | 43 | #. module: stock_inventory_hierarchical_location | ||
788 | 44 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory | ||
789 | 45 | msgid "Gestion des stocks" | ||
790 | 46 | msgstr "Gestion des stocks" | ||
791 | 47 | |||
792 | 48 | #. module: stock_inventory_hierarchical_location | ||
793 | 49 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:70 | ||
794 | 50 | #, python-format | ||
795 | 51 | msgid "Location missing for inventory \"%s\"." | ||
796 | 52 | msgstr "Emplacement manquants dans l'inventaire \"%s\"." | ||
797 | 53 | |||
798 | 54 | #. module: stock_inventory_hierarchical_location | ||
799 | 55 | #: view:stock.inventory:0 | ||
800 | 56 | msgid "Locations" | ||
801 | 57 | msgstr "Emplacements" | ||
802 | 58 | |||
803 | 59 | #. module: stock_inventory_hierarchical_location | ||
804 | 60 | #: field:stock.inventory.missing.location,location_ids:0 | ||
805 | 61 | msgid "Missing location" | ||
806 | 62 | msgstr "Emplacements manquants" | ||
807 | 63 | |||
808 | 64 | #. module: stock_inventory_hierarchical_location | ||
809 | 65 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:41 | ||
810 | 66 | #, python-format | ||
811 | 67 | msgid "One of the parent inventories is not open." | ||
812 | 68 | msgstr "Un des inventaire parent n'est pas ouvert." | ||
813 | 69 | |||
814 | 70 | #. module: stock_inventory_hierarchical_location | ||
815 | 71 | #: view:stock.inventory:0 | ||
816 | 72 | msgid "Open Inventory" | ||
817 | 73 | msgstr "Ouvrir l'inventaire" | ||
818 | 74 | |||
819 | 75 | #. module: stock_inventory_hierarchical_location | ||
820 | 76 | #: constraint:stock.inventory:0 | ||
821 | 77 | msgid "Other Physical inventories are being conducted using the same Locations." | ||
822 | 78 | msgstr "Erreur: certains emplacements sont déjà dans un autre inventaire." | ||
823 | 79 | |||
824 | 80 | #. module: stock_inventory_hierarchical_location | ||
825 | 81 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory_missing_location | ||
826 | 82 | msgid "Search on inventory tree for missing declared locations." | ||
827 | 83 | msgstr "Recherche dans les inventaires les emplacements absents." | ||
828 | 84 | |||
829 | 85 | #. module: stock_inventory_hierarchical_location | ||
830 | 86 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:122 | ||
831 | 87 | #, python-format | ||
832 | 88 | msgid "Some Sub-inventories are not confirmed." | ||
833 | 89 | msgstr "Au moins un sous-inventaire n'est pas confirmé." | ||
834 | 90 | |||
835 | 91 | #. module: stock_inventory_hierarchical_location | ||
836 | 92 | #: view:stock.inventory.missing.location:0 | ||
837 | 93 | msgid "This is the list of missing locations." | ||
838 | 94 | msgstr "Voici la liste des emplacements manquants." | ||
839 | 95 | |||
840 | 96 | #. module: stock_inventory_hierarchical_location | ||
841 | 97 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:58 | ||
842 | 98 | #, python-format | ||
843 | 99 | msgid "This location is not declared on the parent inventory\n" | ||
844 | 100 | "It cannot be added." | ||
845 | 101 | msgstr "Cet emplacement n'est pas déclaré dans l'inventaire parent\n" | ||
846 | 102 | "Vous ne pouvez pas l'ajouter." | ||
847 | 103 | |||
848 | 104 | #. module: stock_inventory_hierarchical_location | ||
849 | 105 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:41 | ||
850 | 106 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:70 | ||
851 | 107 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:122 | ||
852 | 108 | #, python-format | ||
853 | 109 | msgid "Warning !" | ||
854 | 110 | msgstr "Attention !" | ||
855 | 111 | |||
856 | 112 | #. module: stock_inventory_hierarchical_location | ||
857 | 113 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:57 | ||
858 | 114 | #, python-format | ||
859 | 115 | msgid "Warning: Wrong location" | ||
860 | 116 | msgstr "Attention: mauvais emplacement" | ||
861 | 117 | |||
862 | 118 | #. module: stock_inventory_hierarchical_location | ||
863 | 119 | #: view:stock.inventory.missing.location:0 | ||
864 | 120 | msgid "_Cancel" | ||
865 | 121 | msgstr "_Annuler" | ||
866 | 122 | |||
867 | 123 | #. module: stock_inventory_hierarchical_location | ||
868 | 124 | #: view:stock.inventory.missing.location:0 | ||
869 | 125 | msgid "_Confirm missing locations" | ||
870 | 126 | msgstr "_Confirmer les emplacements manquants" | ||
871 | 127 | |||
872 | 0 | 128 | ||
873 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location.py' | |||
874 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location.py 1970-01-01 00:00:00 +0000 | |||
875 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location.py 2014-06-16 10:01:17 +0000 | |||
876 | @@ -0,0 +1,88 @@ | |||
877 | 1 | # -*- coding: utf-8 -*- | ||
878 | 2 | ############################################################################## | ||
879 | 3 | # | ||
880 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
881 | 5 | # | ||
882 | 6 | # This program is free software: you can redistribute it and/or modify | ||
883 | 7 | # it under the terms of the GNU General Public License as published by | ||
884 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
885 | 9 | # (at your option) any later version. | ||
886 | 10 | # | ||
887 | 11 | # This program is distributed in the hope that it will be useful, | ||
888 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
889 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
890 | 14 | # GNU General Public License for more details. | ||
891 | 15 | # | ||
892 | 16 | # You should have received a copy of the GNU General Public License | ||
893 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
894 | 18 | # | ||
895 | 19 | ############################################################################## | ||
896 | 20 | |||
897 | 21 | from openerp.osv import orm | ||
898 | 22 | from openerp.tools.translate import _ | ||
899 | 23 | |||
900 | 24 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
901 | 25 | |||
902 | 26 | # Add the date to the list of fields we must propagate to children inventories | ||
903 | 27 | from stock_inventory_hierarchical import PARENT_VALUES | ||
904 | 28 | PARENT_VALUES.append('exhaustive') | ||
905 | 29 | |||
906 | 30 | |||
907 | 31 | class HierarchicalExhInventory(orm.Model): | ||
908 | 32 | """Add hierarchical structure features to exhaustive Inventories""" | ||
909 | 33 | _inherit = 'stock.inventory' | ||
910 | 34 | |||
911 | 35 | def action_open(self, cr, uid, ids, context=None): | ||
912 | 36 | """Open only if all the parents are Open.""" | ||
913 | 37 | for inventory in self.browse(cr, uid, ids, context=context): | ||
914 | 38 | while inventory.parent_id: | ||
915 | 39 | inventory = inventory.parent_id | ||
916 | 40 | if inventory.state != 'open': | ||
917 | 41 | raise HierarchicalInventoryException( | ||
918 | 42 | _('Warning'), | ||
919 | 43 | _('One of the parent inventories is not open.')) | ||
920 | 44 | return super(HierarchicalExhInventory, self).action_open( | ||
921 | 45 | cr, uid, ids, context=context) | ||
922 | 46 | |||
923 | 47 | def get_missing_locations(self, cr, uid, ids, context=None): | ||
924 | 48 | """Extend the list of inventories with their children""" | ||
925 | 49 | ids = self.search( | ||
926 | 50 | cr, uid, [('parent_id', 'child_of', ids)], context=context) | ||
927 | 51 | return super(HierarchicalExhInventory, self).get_missing_locations( | ||
928 | 52 | cr, uid, ids, context=context) | ||
929 | 53 | |||
930 | 54 | # TODO v8: probably only keep the state "done" | ||
931 | 55 | def confirm_missing_locations(self, cr, uid, ids, context=None): | ||
932 | 56 | """Do something only if children state are confirm or done.""" | ||
933 | 57 | children_count = self.search( | ||
934 | 58 | cr, uid, [('parent_id', 'child_of', ids), | ||
935 | 59 | ('id', 'not in', ids), | ||
936 | 60 | ('state', 'not in', ['confirm', 'done'])], | ||
937 | 61 | context=context, count=True) | ||
938 | 62 | if children_count > 0: | ||
939 | 63 | raise HierarchicalInventoryException( | ||
940 | 64 | _('Warning'), | ||
941 | 65 | _('Some Sub-inventories are not confirmed.')) | ||
942 | 66 | return super(HierarchicalExhInventory, | ||
943 | 67 | self).confirm_missing_locations( | ||
944 | 68 | cr, uid, ids, context=context) | ||
945 | 69 | |||
946 | 70 | def onchange_location_id(self, cr, uid, ids, location_id, context=None): | ||
947 | 71 | """Check if location is a child of parent inventory location""" | ||
948 | 72 | loc_obj = self.pool['stock.location'] | ||
949 | 73 | for inventory in self.browse(cr, uid, ids, context=context): | ||
950 | 74 | if inventory.parent_id: | ||
951 | 75 | allowed_location_ids = loc_obj.search( | ||
952 | 76 | cr, uid, [('location_id', 'child_of', | ||
953 | 77 | inventory.parent_id.location_id.id)], | ||
954 | 78 | context=context) | ||
955 | 79 | if location_id not in allowed_location_ids: | ||
956 | 80 | return { | ||
957 | 81 | 'location_id': False, | ||
958 | 82 | 'warning': { | ||
959 | 83 | 'title': _('Warning: Wrong location'), | ||
960 | 84 | 'message': _("This location is not declared on " | ||
961 | 85 | "the parent inventory\n" | ||
962 | 86 | "It cannot be added.")} | ||
963 | 87 | } | ||
964 | 88 | return {} | ||
965 | 0 | 89 | ||
966 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml' | |||
967 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 1970-01-01 00:00:00 +0000 | |||
968 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 2014-06-16 10:01:17 +0000 | |||
969 | @@ -0,0 +1,28 @@ | |||
970 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
971 | 2 | <openerp> | ||
972 | 3 | <data noupdate="0"> | ||
973 | 4 | |||
974 | 5 | <!-- Record inventories we can use in the tests. --> | ||
975 | 6 | <!-- We need them in the demo data because test data is rolled back | ||
976 | 7 | whenever an exception is raised. --> | ||
977 | 8 | |||
978 | 9 | <!-- Record a hierarchical exhaustive inventory --> | ||
979 | 10 | <record id="parent_inventory" model="stock.inventory"> | ||
980 | 11 | <field name="name">Hierarchical exhaustive inventory</field> | ||
981 | 12 | <field name="state">draft</field> | ||
982 | 13 | <field name="date">2020-04-15 00:00:00</field> | ||
983 | 14 | <field name="exhaustive">True</field> | ||
984 | 15 | <field name="location_id" model="stock.location" ref="stock.stock_location_stock"/> | ||
985 | 16 | </record> | ||
986 | 17 | <record id="child_1_id" model="stock.inventory"> | ||
987 | 18 | <field name="name">Team A</field> | ||
988 | 19 | <field name="parent_id" ref="parent_inventory"/> | ||
989 | 20 | <field name="location_id" model="stock.location" ref="stock.stock_location_14"/> | ||
990 | 21 | </record> | ||
991 | 22 | <record id="child_2_id" model="stock.inventory"> | ||
992 | 23 | <field name="name">Team B</field> | ||
993 | 24 | <field name="parent_id" ref="parent_inventory"/> | ||
994 | 25 | <field name="location_id" model="stock.location" ref="stock.stock_location_components"/> | ||
995 | 26 | </record> | ||
996 | 27 | </data> | ||
997 | 28 | </openerp> | ||
998 | 0 | 29 | ||
999 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml' | |||
1000 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml 1970-01-01 00:00:00 +0000 | |||
1001 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml 2014-06-16 10:01:17 +0000 | |||
1002 | @@ -0,0 +1,37 @@ | |||
1003 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1004 | 2 | <openerp> | ||
1005 | 3 | <data> | ||
1006 | 4 | <record model="ir.ui.view" id="stock_inventory_hierarchical_location_form_view"> | ||
1007 | 5 | <field name="name">hierarchical.inventory.location.form</field> | ||
1008 | 6 | <field name="model">stock.inventory</field> | ||
1009 | 7 | <field name="inherit_id" ref="stock.view_inventory_form" /> | ||
1010 | 8 | <field name="arch" type="xml"> | ||
1011 | 9 | |||
1012 | 10 | <xpath expr="/form//field[@name='exhaustive']" position="attributes"> | ||
1013 | 11 | <attribute name="attrs">{'readonly':[('parent_id', '!=', False)]}</attribute> | ||
1014 | 12 | </xpath> | ||
1015 | 13 | |||
1016 | 14 | <xpath expr="/form//field[@name='location_id']" position="attributes"> | ||
1017 | 15 | <attribute name="on_change">onchange_location_id(location_id)</attribute> | ||
1018 | 16 | </xpath> | ||
1019 | 17 | |||
1020 | 18 | </field> | ||
1021 | 19 | </record> | ||
1022 | 20 | |||
1023 | 21 | <record model="ir.ui.view" id="stock_ihl_exhautive_form_view"> | ||
1024 | 22 | <field name="name">hierarchical.inventory.location.exhautive.form</field> | ||
1025 | 23 | <field name="model">stock.inventory</field> | ||
1026 | 24 | <field name="inherit_id" ref="stock_inventory_hierarchical.stock_inventory_hierarchical_form_view" /> | ||
1027 | 25 | <field name="arch" type="xml"> | ||
1028 | 26 | <xpath expr="//field[@name='inventory_ids']" position="attributes"> | ||
1029 | 27 | <attribute name="context">{'default_parent_id': active_id, 'default_exhaustive': exhaustive}</attribute> | ||
1030 | 28 | </xpath> | ||
1031 | 29 | </field> | ||
1032 | 30 | </record> | ||
1033 | 31 | |||
1034 | 32 | <!-- Show hierarchical exhaustive inventories by default --> | ||
1035 | 33 | <record id="stock.action_inventory_form" model="ir.actions.act_window"> | ||
1036 | 34 | <field name="context">{'full':'1', 'search_default_exhaustive':1, 'search_default_main_inventories':1}</field> | ||
1037 | 35 | </record> | ||
1038 | 36 | </data> | ||
1039 | 37 | </openerp> | ||
1040 | 0 | 38 | ||
1041 | === added directory 'stock_inventory_hierarchical_location/static' | |||
1042 | === added directory 'stock_inventory_hierarchical_location/static/src' | |||
1043 | === added directory 'stock_inventory_hierarchical_location/static/src/img' | |||
1044 | === added file 'stock_inventory_hierarchical_location/static/src/img/icon.png' | |||
1045 | 1 | Binary files stock_inventory_hierarchical_location/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical_location/static/src/img/icon.png 2014-06-16 10:01:17 +0000 differ | 39 | Binary files stock_inventory_hierarchical_location/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_hierarchical_location/static/src/img/icon.png 2014-06-16 10:01:17 +0000 differ |
1046 | === added directory 'stock_inventory_hierarchical_location/tests' | |||
1047 | === added file 'stock_inventory_hierarchical_location/tests/__init__.py' | |||
1048 | --- stock_inventory_hierarchical_location/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
1049 | +++ stock_inventory_hierarchical_location/tests/__init__.py 2014-06-16 10:01:17 +0000 | |||
1050 | @@ -0,0 +1,39 @@ | |||
1051 | 1 | # -*- coding: utf-8 -*- | ||
1052 | 2 | # | ||
1053 | 3 | # | ||
1054 | 4 | # Authors: Laetitia Gangloff | ||
1055 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1056 | 6 | # All Rights Reserved | ||
1057 | 7 | # | ||
1058 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1059 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1060 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1061 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1062 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1063 | 13 | # Service Company. | ||
1064 | 14 | # | ||
1065 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1066 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1067 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1068 | 18 | # License, or (at your option) any later version. | ||
1069 | 19 | # | ||
1070 | 20 | # This program is distributed in the hope that it will be useful, | ||
1071 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1072 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1073 | 23 | # GNU Affero General Public License for more details. | ||
1074 | 24 | # | ||
1075 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1076 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1077 | 27 | # | ||
1078 | 28 | # | ||
1079 | 29 | |||
1080 | 30 | import fill_inventory_test | ||
1081 | 31 | |||
1082 | 32 | fast_suite = [ | ||
1083 | 33 | ] | ||
1084 | 34 | |||
1085 | 35 | checks = [ | ||
1086 | 36 | fill_inventory_test, | ||
1087 | 37 | ] | ||
1088 | 38 | |||
1089 | 39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1090 | 0 | 40 | ||
1091 | === added file 'stock_inventory_hierarchical_location/tests/fill_inventory_test.py' | |||
1092 | --- stock_inventory_hierarchical_location/tests/fill_inventory_test.py 1970-01-01 00:00:00 +0000 | |||
1093 | +++ stock_inventory_hierarchical_location/tests/fill_inventory_test.py 2014-06-16 10:01:17 +0000 | |||
1094 | @@ -0,0 +1,118 @@ | |||
1095 | 1 | # -*- coding: utf-8 -*- | ||
1096 | 2 | # | ||
1097 | 3 | # | ||
1098 | 4 | # Authors: Laetitia Gangloff | ||
1099 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1100 | 6 | # All Rights Reserved | ||
1101 | 7 | # | ||
1102 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1103 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1104 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1105 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1106 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1107 | 13 | # Service Company. | ||
1108 | 14 | # | ||
1109 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1110 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1111 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1112 | 18 | # License, or (at your option) any later version. | ||
1113 | 19 | # | ||
1114 | 20 | # This program is distributed in the hope that it will be useful, | ||
1115 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1116 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1117 | 23 | # GNU Affero General Public License for more details. | ||
1118 | 24 | # | ||
1119 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1120 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1121 | 27 | # | ||
1122 | 28 | # | ||
1123 | 29 | |||
1124 | 30 | import openerp.tests.common as common | ||
1125 | 31 | |||
1126 | 32 | DB = common.DB | ||
1127 | 33 | ADMIN_USER_ID = common.ADMIN_USER_ID | ||
1128 | 34 | |||
1129 | 35 | |||
1130 | 36 | class fill_inventory_test(common.TransactionCase): | ||
1131 | 37 | |||
1132 | 38 | def setUp(self): | ||
1133 | 39 | super(fill_inventory_test, self).setUp() | ||
1134 | 40 | |||
1135 | 41 | def test_missing_location(self): | ||
1136 | 42 | """ | ||
1137 | 43 | Test that when confirm a parent inventory, the child location are not in the confirmation result | ||
1138 | 44 | """ | ||
1139 | 45 | parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory') | ||
1140 | 46 | self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id]) | ||
1141 | 47 | # confirm shelf 1 inventory | ||
1142 | 48 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id') | ||
1143 | 49 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1144 | 50 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1145 | 51 | self.assertEqual(len(missing_location), 1, "1 missing location should be find, because the inventory is empty") | ||
1146 | 52 | wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]}) | ||
1147 | 53 | self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1148 | 54 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1149 | 55 | self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is confirmed") | ||
1150 | 56 | # confirm shelf 2 inventory | ||
1151 | 57 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id') | ||
1152 | 58 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1153 | 59 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1154 | 60 | self.assertEqual(len(missing_location), 1, "1 missing location should be fine, because the inventory is empty") | ||
1155 | 61 | self.registry('stock.inventory.line').create(self.cr, self.uid, {'product_id': self.ref('product.product_product_7'), | ||
1156 | 62 | 'product_uom': self.ref('product.product_uom_unit'), | ||
1157 | 63 | 'company_id': self.ref('base.main_company'), | ||
1158 | 64 | 'inventory_id': inventory_id, | ||
1159 | 65 | 'product_qty': 18.0, | ||
1160 | 66 | 'location_id': self.ref('stock.stock_location_14')}) | ||
1161 | 67 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1162 | 68 | self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is filled") | ||
1163 | 69 | wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]}) | ||
1164 | 70 | wizard = self.registry('stock.inventory.uninventoried.locations').browse(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1165 | 71 | self.assertEqual(len(wizard.location_ids), 0, "The wizard should not contain any lines but contains %s." % wizard.location_ids) | ||
1166 | 72 | self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1167 | 73 | # confirm parent inventory | ||
1168 | 74 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [parent_inventory_id]) | ||
1169 | 75 | self.assertEqual(len(missing_location), 1, "Only 1 missing location should be find, because there is some location in child inventory") | ||
1170 | 76 | |||
1171 | 77 | def test_fill_inventory(self): | ||
1172 | 78 | """ | ||
1173 | 79 | Test that when fill a parent inventory, the child location are not in the result | ||
1174 | 80 | """ | ||
1175 | 81 | parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory') | ||
1176 | 82 | self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id]) | ||
1177 | 83 | # confirm shelf 1 inventory | ||
1178 | 84 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id') | ||
1179 | 85 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1180 | 86 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_components'), | ||
1181 | 87 | 'recursive': True, | ||
1182 | 88 | 'exhaustive': True, | ||
1183 | 89 | 'set_stock_zero': True}, context={'active_ids': [inventory_id]}) | ||
1184 | 90 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]}) | ||
1185 | 91 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)]) | ||
1186 | 92 | self.assertEqual(len(inventory_line_ids), 12, "12 inventory line is fount after filling inventory") | ||
1187 | 93 | # confirm shelf 2 inventory | ||
1188 | 94 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id') | ||
1189 | 95 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1190 | 96 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_14'), | ||
1191 | 97 | 'recursive': True, | ||
1192 | 98 | 'exhaustive': True, | ||
1193 | 99 | 'set_stock_zero': True}, context={'active_ids': [inventory_id]}) | ||
1194 | 100 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]}) | ||
1195 | 101 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)]) | ||
1196 | 102 | self.assertEqual(len(inventory_line_ids), 4, "1 inventory line is fount after filling inventory") | ||
1197 | 103 | # confirm parent inventory | ||
1198 | 104 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_stock'), | ||
1199 | 105 | 'recursive': True, | ||
1200 | 106 | 'exhaustive': True, | ||
1201 | 107 | 'set_stock_zero': True}, context={'active_ids': [parent_inventory_id]}) | ||
1202 | 108 | try: | ||
1203 | 109 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [parent_inventory_id]}) | ||
1204 | 110 | except Exception, e: | ||
1205 | 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.''") | ||
1206 | 112 | exception_happened = True | ||
1207 | 113 | pass | ||
1208 | 114 | self.assertTrue(exception_happened) | ||
1209 | 115 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', parent_inventory_id)]) | ||
1210 | 116 | self.assertEqual(len(inventory_line_ids), 0, "No inventory line is fount after filling inventory") | ||
1211 | 117 | |||
1212 | 118 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1213 | 0 | 119 | ||
1214 | === added file 'stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml' | |||
1215 | --- stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml 1970-01-01 00:00:00 +0000 | |||
1216 | +++ stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml 2014-06-16 10:01:17 +0000 | |||
1217 | @@ -0,0 +1,56 @@ | |||
1218 | 1 | - | ||
1219 | 2 | Check that the exhaustive field of parent inventory has been propagated to children. | ||
1220 | 3 | - | ||
1221 | 4 | !python {model: stock.inventory}: | | ||
1222 | 5 | exhaustive = self.read(cr, uid, [ref("child_1_id")], ['exhaustive'])[0]['exhaustive'] | ||
1223 | 6 | assert exhaustive, "Exhaustive field not propagated to child inventory" | ||
1224 | 7 | |||
1225 | 8 | - | ||
1226 | 9 | Check that I can't open child inventory while parent inventory is open. | ||
1227 | 10 | - | ||
1228 | 11 | !python {model: stock.inventory}: | | ||
1229 | 12 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
1230 | 13 | parent_state = self.read(cr, uid, [ref("parent_inventory")], ['state'])[0]['state'] | ||
1231 | 14 | assert parent_state == 'draft', "Parent inventory in state '%s'. It should be 'draft'" % parent_state | ||
1232 | 15 | try: | ||
1233 | 16 | self.action_open(cr, uid, [ref("child_1_id")]) | ||
1234 | 17 | except HierarchicalInventoryException as e: | ||
1235 | 18 | log("Good ! The Inventory could not be opened: %s" % e) | ||
1236 | 19 | child_1_state = self.read(cr, uid, [ref("child_1_id")], ['state'])[0]['state'] | ||
1237 | 20 | assert child_1_state == 'draft', "Child inventory 1 have '%s' state. It should be 'draft'" % child_1_state | ||
1238 | 21 | |||
1239 | 22 | - | ||
1240 | 23 | I will check that the function get_missing_locations return some locations. | ||
1241 | 24 | - | ||
1242 | 25 | !python {model: stock.inventory}: | | ||
1243 | 26 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('parent_inventory')], context=context) | ||
1244 | 27 | assert len(missing_loc_ids)==3, "get_missing_locations did not return any ID." | ||
1245 | 28 | |||
1246 | 29 | - | ||
1247 | 30 | I will fill the inventory and check that the function get_missing_locations return no locations. | ||
1248 | 31 | Adding 17” LCD Monitor. | ||
1249 | 32 | - | ||
1250 | 33 | !record {model: stock.inventory.line, id: lines_inventory_location_pc1}: | ||
1251 | 34 | product_id: product.product_product_7 | ||
1252 | 35 | product_uom: product.product_uom_unit | ||
1253 | 36 | company_id: base.main_company | ||
1254 | 37 | inventory_id: child_1_id | ||
1255 | 38 | product_qty: 18.0 | ||
1256 | 39 | location_id: stock.stock_location_14 | ||
1257 | 40 | |||
1258 | 41 | - | ||
1259 | 42 | Adding USB Keyboard, QWERTY. | ||
1260 | 43 | - | ||
1261 | 44 | !record {model: stock.inventory.line, id: lines_inventory_location_pc3}: | ||
1262 | 45 | product_id: product.product_product_8 | ||
1263 | 46 | product_uom: product.product_uom_unit | ||
1264 | 47 | company_id: base.main_company | ||
1265 | 48 | inventory_id: child_2_id | ||
1266 | 49 | product_qty: 5.0 | ||
1267 | 50 | location_id: stock.stock_location_components | ||
1268 | 51 | |||
1269 | 52 | - | ||
1270 | 53 | !python {model: stock.inventory}: | | ||
1271 | 54 | |||
1272 | 55 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('parent_inventory')], context=context) | ||
1273 | 56 | assert set(missing_loc_ids)==set([ref('stock.stock_location_stock')]), "get_missing_locations should return only %s but returned %s" % ([ref('stock.stock_location_stock')], missing_loc_ids) | ||
1274 | 0 | 57 | ||
1275 | === added directory 'stock_inventory_hierarchical_location/wizard' | |||
1276 | === added file 'stock_inventory_hierarchical_location/wizard/__init__.py' | |||
1277 | --- stock_inventory_hierarchical_location/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
1278 | +++ stock_inventory_hierarchical_location/wizard/__init__.py 2014-06-16 10:01:17 +0000 | |||
1279 | @@ -0,0 +1,21 @@ | |||
1280 | 1 | # -*- coding: utf-8 -*- | ||
1281 | 2 | ############################################################################## | ||
1282 | 3 | # | ||
1283 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1284 | 5 | # | ||
1285 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1286 | 7 | # it under the terms of the GNU General Public License as published by | ||
1287 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1288 | 9 | # (at your option) any later version. | ||
1289 | 10 | # | ||
1290 | 11 | # This program is distributed in the hope that it will be useful, | ||
1291 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1292 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1293 | 14 | # GNU General Public License for more details. | ||
1294 | 15 | # | ||
1295 | 16 | # You should have received a copy of the GNU General Public License | ||
1296 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1297 | 18 | # | ||
1298 | 19 | ############################################################################## | ||
1299 | 20 | |||
1300 | 21 | from . import stock_fill_location_inventory | ||
1301 | 0 | 22 | ||
1302 | === added file 'stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py' | |||
1303 | --- stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 1970-01-01 00:00:00 +0000 | |||
1304 | +++ stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 2014-06-16 10:01:17 +0000 | |||
1305 | @@ -0,0 +1,89 @@ | |||
1306 | 1 | # -*- coding: utf-8 -*- | ||
1307 | 2 | # | ||
1308 | 3 | # | ||
1309 | 4 | # Authors: Laetitia Gangloff | ||
1310 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1311 | 6 | # All Rights Reserved | ||
1312 | 7 | # | ||
1313 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1314 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1315 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1316 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1317 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1318 | 13 | # Service Company. | ||
1319 | 14 | # | ||
1320 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1321 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1322 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1323 | 18 | # License, or (at your option) any later version. | ||
1324 | 19 | # | ||
1325 | 20 | # This program is distributed in the hope that it will be useful, | ||
1326 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1327 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1328 | 23 | # GNU Affero General Public License for more details. | ||
1329 | 24 | # | ||
1330 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1331 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1332 | 27 | # | ||
1333 | 28 | # | ||
1334 | 29 | |||
1335 | 30 | from openerp.osv import orm | ||
1336 | 31 | from openerp.tools.translate import _ | ||
1337 | 32 | |||
1338 | 33 | |||
1339 | 34 | class FillInventoryWizard(orm.TransientModel): | ||
1340 | 35 | """If inventory as sub inventories, do not fill with sub inventories location""" | ||
1341 | 36 | _inherit = 'stock.fill.inventory' | ||
1342 | 37 | |||
1343 | 38 | def fill_inventory(self, cr, uid, ids, context=None): | ||
1344 | 39 | """ To Import stock inventory according to products available in the location and not already in a sub inventory | ||
1345 | 40 | |||
1346 | 41 | We split fill_inventory on many fill_inventory (one for each location) | ||
1347 | 42 | @param self: The object pointer. | ||
1348 | 43 | @param cr: A database cursor | ||
1349 | 44 | @param uid: ID of the user currently logged in | ||
1350 | 45 | @param ids: the ID or list of IDs if we want more than one | ||
1351 | 46 | @param context: A standard dictionary | ||
1352 | 47 | @return: | ||
1353 | 48 | """ | ||
1354 | 49 | if context is None: | ||
1355 | 50 | context = {} | ||
1356 | 51 | |||
1357 | 52 | if ids and len(ids): | ||
1358 | 53 | ids = ids[0] | ||
1359 | 54 | else: | ||
1360 | 55 | return {'type': 'ir.actions.act_window_close'} | ||
1361 | 56 | fill_inventory = self.browse(cr, uid, ids, context=context) | ||
1362 | 57 | if fill_inventory.recursive and fill_inventory.exhaustive: | ||
1363 | 58 | exclude_location_ids = [] | ||
1364 | 59 | for i in self.pool['stock.inventory'].browse(cr, uid, context['active_ids']): | ||
1365 | 60 | for sub_inventory in i.inventory_ids: | ||
1366 | 61 | # exclude these location | ||
1367 | 62 | exclude_location_ids.append(sub_inventory.location_id.id) | ||
1368 | 63 | domain = [('location_id', 'child_of', [fill_inventory.location_id.id])] | ||
1369 | 64 | if exclude_location_ids: | ||
1370 | 65 | domain.append('!') | ||
1371 | 66 | domain.append(('location_id', 'child_of', exclude_location_ids)) | ||
1372 | 67 | location_ids = self.pool['stock.location'].search(cr, uid, domain, | ||
1373 | 68 | order="id", | ||
1374 | 69 | context=context) | ||
1375 | 70 | all_in_exception = 0 | ||
1376 | 71 | for location_id in location_ids: | ||
1377 | 72 | try: | ||
1378 | 73 | super(FillInventoryWizard, self).fill_inventory(cr, uid, | ||
1379 | 74 | [self.copy(cr, uid, ids, {'location_id': location_id, | ||
1380 | 75 | 'recursive': False, }, context=context)], | ||
1381 | 76 | context=context) | ||
1382 | 77 | except Exception, e: | ||
1383 | 78 | if e.value == _('No product in this location. Please select a location in the product form.'): | ||
1384 | 79 | all_in_exception = all_in_exception + 1 | ||
1385 | 80 | pass | ||
1386 | 81 | else: | ||
1387 | 82 | raise e | ||
1388 | 83 | if all_in_exception == len(location_ids): | ||
1389 | 84 | raise orm.except_orm(_('Warning!'), _('No product in this location. Please select a location in the product form.')) | ||
1390 | 85 | return {'type': 'ir.actions.act_window_close'} | ||
1391 | 86 | else: | ||
1392 | 87 | return super(FillInventoryWizard, self).fill_inventory(cr, uid, [ids], context=context) | ||
1393 | 88 | |||
1394 | 89 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1395 | 0 | 90 | ||
1396 | === modified file 'stock_inventory_location/__openerp__.py' | |||
1397 | --- stock_inventory_location/__openerp__.py 2014-06-16 10:01:17 +0000 | |||
1398 | +++ stock_inventory_location/__openerp__.py 2014-06-16 10:01:17 +0000 | |||
1399 | @@ -62,9 +62,9 @@ | |||
1400 | 62 | "wizard/stock_fill_location_inventory_view.xml", | 62 | "wizard/stock_fill_location_inventory_view.xml", |
1401 | 63 | ], | 63 | ], |
1402 | 64 | "test": [ | 64 | "test": [ |
1406 | 65 | "test/inventory_standard_test.yml", | 65 | "tests/inventory_standard_test.yml", |
1407 | 66 | "test/inventory_exhaustive_test.yml", | 66 | "tests/inventory_exhaustive_test.yml", |
1408 | 67 | "test/inventory_future_test.yml", | 67 | "tests/inventory_future_test.yml", |
1409 | 68 | ], | 68 | ], |
1410 | 69 | "images": [ | 69 | "images": [ |
1411 | 70 | "images/inventory_form.png", | 70 | "images/inventory_form.png", |
1412 | 71 | 71 | ||
1413 | === modified file 'stock_inventory_location/stock_inventory_location.py' | |||
1414 | --- stock_inventory_location/stock_inventory_location.py 2014-06-16 10:01:17 +0000 | |||
1415 | +++ stock_inventory_location/stock_inventory_location.py 2014-06-16 10:01:17 +0000 | |||
1416 | @@ -27,6 +27,7 @@ | |||
1417 | 27 | # TODOv8! remove, feature is included upstream | 27 | # TODOv8! remove, feature is included upstream |
1418 | 28 | from openerp.osv import osv | 28 | from openerp.osv import osv |
1419 | 29 | from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT | 29 | from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT |
1420 | 30 | from openerp import SUPERUSER_ID | ||
1421 | 30 | 31 | ||
1422 | 31 | from .exceptions import ExhaustiveInventoryException | 32 | from .exceptions import ExhaustiveInventoryException |
1423 | 32 | 33 | ||
1424 | @@ -270,7 +271,7 @@ | |||
1425 | 270 | """Error if an exhaustive Inventory is being conducted here""" | 271 | """Error if an exhaustive Inventory is being conducted here""" |
1426 | 271 | inv_obj = self.pool['stock.inventory'] | 272 | inv_obj = self.pool['stock.inventory'] |
1427 | 272 | location_inventory_open_ids = inv_obj._get_locations_open_inventories( | 273 | location_inventory_open_ids = inv_obj._get_locations_open_inventories( |
1429 | 273 | cr, uid, context=context) | 274 | cr, SUPERUSER_ID, context=context) |
1430 | 274 | if not isinstance(ids, Iterable): | 275 | if not isinstance(ids, Iterable): |
1431 | 275 | ids = [ids] | 276 | ids = [ids] |
1432 | 276 | for inv_id in ids: | 277 | for inv_id in ids: |
1433 | @@ -286,7 +287,7 @@ | |||
1434 | 286 | self._check_inventory(cr, uid, ids, context=context) | 287 | self._check_inventory(cr, uid, ids, context=context) |
1435 | 287 | if not isinstance(ids, Iterable): | 288 | if not isinstance(ids, Iterable): |
1436 | 288 | ids = [ids] | 289 | ids = [ids] |
1438 | 289 | ids_to_check = ids | 290 | ids_to_check = list(ids) |
1439 | 290 | # If changing the parent, no inventory must conducted there either | 291 | # If changing the parent, no inventory must conducted there either |
1440 | 291 | if vals.get('location_id'): | 292 | if vals.get('location_id'): |
1441 | 292 | ids_to_check.append(vals['location_id']) | 293 | ids_to_check.append(vals['location_id']) |
1442 | @@ -326,7 +327,7 @@ | |||
1443 | 326 | message = "" | 327 | message = "" |
1444 | 327 | inv_obj = self.pool['stock.inventory'] | 328 | inv_obj = self.pool['stock.inventory'] |
1445 | 328 | locked_location_ids = inv_obj._get_locations_open_inventories( | 329 | locked_location_ids = inv_obj._get_locations_open_inventories( |
1447 | 329 | cr, uid, context=context) | 330 | cr, SUPERUSER_ID, context=context) |
1448 | 330 | if not locked_location_ids: | 331 | if not locked_location_ids: |
1449 | 331 | # Nothing to verify | 332 | # Nothing to verify |
1450 | 332 | return True | 333 | return True |
1451 | 333 | 334 | ||
1452 | === renamed directory 'stock_inventory_location/test' => 'stock_inventory_location/tests' | |||
1453 | === added file 'stock_inventory_location/tests/__init__.py' | |||
1454 | --- stock_inventory_location/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
1455 | +++ stock_inventory_location/tests/__init__.py 2014-06-16 10:01:17 +0000 | |||
1456 | @@ -0,0 +1,39 @@ | |||
1457 | 1 | # -*- coding: utf-8 -*- | ||
1458 | 2 | # | ||
1459 | 3 | # | ||
1460 | 4 | # Authors: Laetitia Gangloff | ||
1461 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1462 | 6 | # All Rights Reserved | ||
1463 | 7 | # | ||
1464 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1465 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1466 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1467 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1468 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1469 | 13 | # Service Company. | ||
1470 | 14 | # | ||
1471 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1472 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1473 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1474 | 18 | # License, or (at your option) any later version. | ||
1475 | 19 | # | ||
1476 | 20 | # This program is distributed in the hope that it will be useful, | ||
1477 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1478 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1479 | 23 | # GNU Affero General Public License for more details. | ||
1480 | 24 | # | ||
1481 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1482 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1483 | 27 | # | ||
1484 | 28 | # | ||
1485 | 29 | |||
1486 | 30 | import stock_inventory_location_test | ||
1487 | 31 | |||
1488 | 32 | fast_suite = [ | ||
1489 | 33 | ] | ||
1490 | 34 | |||
1491 | 35 | checks = [ | ||
1492 | 36 | stock_inventory_location_test, | ||
1493 | 37 | ] | ||
1494 | 38 | |||
1495 | 39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1496 | 0 | 40 | ||
1497 | === added file 'stock_inventory_location/tests/stock_inventory_location_test.py' | |||
1498 | --- stock_inventory_location/tests/stock_inventory_location_test.py 1970-01-01 00:00:00 +0000 | |||
1499 | +++ stock_inventory_location/tests/stock_inventory_location_test.py 2014-06-16 10:01:17 +0000 | |||
1500 | @@ -0,0 +1,47 @@ | |||
1501 | 1 | # -*- coding: utf-8 -*- | ||
1502 | 2 | # | ||
1503 | 3 | # | ||
1504 | 4 | # Authors: Laetitia Gangloff | ||
1505 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1506 | 6 | # All Rights Reserved | ||
1507 | 7 | # | ||
1508 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1509 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1510 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1511 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1512 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1513 | 13 | # Service Company. | ||
1514 | 14 | # | ||
1515 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1516 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1517 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1518 | 18 | # License, or (at your option) any later version. | ||
1519 | 19 | # | ||
1520 | 20 | # This program is distributed in the hope that it will be useful, | ||
1521 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1522 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1523 | 23 | # GNU Affero General Public License for more details. | ||
1524 | 24 | # | ||
1525 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1526 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1527 | 27 | # | ||
1528 | 28 | # | ||
1529 | 29 | |||
1530 | 30 | import openerp.tests.common as common | ||
1531 | 31 | |||
1532 | 32 | DB = common.DB | ||
1533 | 33 | ADMIN_USER_ID = common.ADMIN_USER_ID | ||
1534 | 34 | |||
1535 | 35 | |||
1536 | 36 | class stock_inventory_location_test(common.TransactionCase): | ||
1537 | 37 | |||
1538 | 38 | def setUp(self): | ||
1539 | 39 | super(stock_inventory_location_test, self).setUp() | ||
1540 | 40 | |||
1541 | 41 | def test_update_parent_location(self): | ||
1542 | 42 | """ | ||
1543 | 43 | Test the update of the parent of a location (no inventory in progress | ||
1544 | 44 | """ | ||
1545 | 45 | self.registry('stock.location').write(self.cr, self.uid, self.ref('stock.stock_location_5'), {'location_id': self.ref('stock.stock_location_4')}) | ||
1546 | 46 | |||
1547 | 47 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
Loic and I are improving this proposal WRT the 7.0 coding style and latest v8 updates.