Merge lp:~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-location-fix-subinventory-locations into lp:stock-logistic-warehouse
Proposed by
Laetitia Gangloff (Acsone)
Status: | Merged |
---|---|
Merge reported by: | Laetitia Gangloff (Acsone) |
Merged at revision: | not available |
Proposed branch: | lp:~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-location-fix-subinventory-locations |
Merge into: | lp:stock-logistic-warehouse |
Diff against target: |
3044 lines (+2811/-0) 38 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 (+49/-0) stock_inventory_hierarchical_location/i18n/fr.po (+127/-0) stock_inventory_hierarchical_location/inventory_hierarchical_location.py (+100/-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 (+22/-0) stock_inventory_hierarchical_location/wizard/generate_inventory.py (+134/-0) stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml (+42/-0) stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py (+89/-0) stock_inventory_location/__init__.py (+24/-0) stock_inventory_location/__openerp__.py (+77/-0) stock_inventory_location/exceptions.py (+26/-0) stock_inventory_location/i18n/fr.po (+241/-0) stock_inventory_location/stock_inventory_location.py (+353/-0) stock_inventory_location/stock_inventory_location_demo.xml (+26/-0) stock_inventory_location/stock_inventory_location_view.xml (+81/-0) stock_inventory_location/tests/__init__.py (+39/-0) stock_inventory_location/tests/inventory_exhaustive_test.yml (+128/-0) stock_inventory_location/tests/inventory_future_test.yml (+13/-0) stock_inventory_location/tests/inventory_standard_test.yml (+100/-0) stock_inventory_location/tests/stock_inventory_location_test.py (+47/-0) stock_inventory_location/wizard/__init__.py (+22/-0) stock_inventory_location/wizard/stock_confirm_uninventoried_location.py (+68/-0) stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml (+33/-0) stock_inventory_location/wizard/stock_fill_location_inventory.py (+47/-0) stock_inventory_location/wizard/stock_fill_location_inventory_view.xml (+18/-0) |
To merge this branch: | bzr merge lp:~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-location-fix-subinventory-locations |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stock and Logistic Core Editors | Pending | ||
Review via email: mp+224774@code.launchpad.net |
Commit message
Description of the change
Add exhaustive parameter for fill inventory.
And encapsulate in try catch to confirm even if there is no product to add
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +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-27 09:18:58 +0000 | |||
690 | @@ -0,0 +1,49 @@ | |||
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 | "wizard/generate_inventory_view.xml", | ||
736 | 46 | ], | ||
737 | 47 | "test": ["tests/inventory_hierarchical_location_test.yml"], | ||
738 | 48 | "demo": ["inventory_hierarchical_location_demo.xml"], | ||
739 | 49 | } | ||
740 | 0 | 50 | ||
741 | === added directory 'stock_inventory_hierarchical_location/i18n' | |||
742 | === added file 'stock_inventory_hierarchical_location/i18n/fr.po' | |||
743 | --- stock_inventory_hierarchical_location/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
744 | +++ stock_inventory_hierarchical_location/i18n/fr.po 2014-06-27 09:18:58 +0000 | |||
745 | @@ -0,0 +1,127 @@ | |||
746 | 1 | # Translation of OpenERP Server. | ||
747 | 2 | # This file contains the translation of the following modules: | ||
748 | 3 | # * stock_inventory_hierarchical_location | ||
749 | 4 | # | ||
750 | 5 | msgid "" | ||
751 | 6 | msgstr "" | ||
752 | 7 | "Project-Id-Version: OpenERP Server 6.0.4\n" | ||
753 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
754 | 9 | "POT-Creation-Date: 2013-09-25 13:55+0000\n" | ||
755 | 10 | "PO-Revision-Date: 2013-09-25 13:55+0000\n" | ||
756 | 11 | "Last-Translator: <>\n" | ||
757 | 12 | "Language-Team: \n" | ||
758 | 13 | "MIME-Version: 1.0\n" | ||
759 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
760 | 15 | "Content-Transfer-Encoding: \n" | ||
761 | 16 | "Plural-Forms: \n" | ||
762 | 17 | |||
763 | 18 | #. module: stock_inventory_hierarchical_location | ||
764 | 19 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical_location.action_view_stock_inventory_missing_location | ||
765 | 20 | msgid "Confirm missing location" | ||
766 | 21 | msgstr "Confirmer les emplacements manquants" | ||
767 | 22 | |||
768 | 23 | #. module: stock_inventory_hierarchical_location | ||
769 | 24 | #: view:stock.inventory.missing.location:0 | ||
770 | 25 | msgid "Confirm missing locations" | ||
771 | 26 | msgstr "Confirmer les emplacements manquants" | ||
772 | 27 | |||
773 | 28 | #. module: stock_inventory_hierarchical_location | ||
774 | 29 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory_uninventoried_locations | ||
775 | 30 | msgid "Confirm the uninventoried Locations." | ||
776 | 31 | msgstr "Confirmer les emplacements non inventoriés." | ||
777 | 32 | |||
778 | 33 | #. module: stock_inventory_hierarchical_location | ||
779 | 34 | #: view:stock.inventory.missing.location:0 | ||
780 | 35 | msgid "Do you want to continue ?" | ||
781 | 36 | msgstr "Voulez-vous continuer ?" | ||
782 | 37 | |||
783 | 38 | #. module: stock_inventory_hierarchical_location | ||
784 | 39 | #: constraint:stock.inventory:0 | ||
785 | 40 | msgid "Error! You can not create recursive inventories." | ||
786 | 41 | msgstr "Erreur! Vous ne pouvez pas créer un inventaire récursif." | ||
787 | 42 | |||
788 | 43 | #. module: stock_inventory_hierarchical_location | ||
789 | 44 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory | ||
790 | 45 | msgid "Gestion des stocks" | ||
791 | 46 | msgstr "Gestion des stocks" | ||
792 | 47 | |||
793 | 48 | #. module: stock_inventory_hierarchical_location | ||
794 | 49 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:70 | ||
795 | 50 | #, python-format | ||
796 | 51 | msgid "Location missing for inventory \"%s\"." | ||
797 | 52 | msgstr "Emplacement manquants dans l'inventaire \"%s\"." | ||
798 | 53 | |||
799 | 54 | #. module: stock_inventory_hierarchical_location | ||
800 | 55 | #: view:stock.inventory:0 | ||
801 | 56 | msgid "Locations" | ||
802 | 57 | msgstr "Emplacements" | ||
803 | 58 | |||
804 | 59 | #. module: stock_inventory_hierarchical_location | ||
805 | 60 | #: field:stock.inventory.missing.location,location_ids:0 | ||
806 | 61 | msgid "Missing location" | ||
807 | 62 | msgstr "Emplacements manquants" | ||
808 | 63 | |||
809 | 64 | #. module: stock_inventory_hierarchical_location | ||
810 | 65 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:41 | ||
811 | 66 | #, python-format | ||
812 | 67 | msgid "One of the parent inventories is not open." | ||
813 | 68 | msgstr "Un des inventaire parent n'est pas ouvert." | ||
814 | 69 | |||
815 | 70 | #. module: stock_inventory_hierarchical_location | ||
816 | 71 | #: view:stock.inventory:0 | ||
817 | 72 | msgid "Open Inventory" | ||
818 | 73 | msgstr "Ouvrir l'inventaire" | ||
819 | 74 | |||
820 | 75 | #. module: stock_inventory_hierarchical_location | ||
821 | 76 | #: constraint:stock.inventory:0 | ||
822 | 77 | msgid "Other Physical inventories are being conducted using the same Locations." | ||
823 | 78 | msgstr "Erreur: certains emplacements sont déjà dans un autre inventaire." | ||
824 | 79 | |||
825 | 80 | #. module: stock_inventory_hierarchical_location | ||
826 | 81 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory_missing_location | ||
827 | 82 | msgid "Search on inventory tree for missing declared locations." | ||
828 | 83 | msgstr "Recherche dans les inventaires les emplacements absents." | ||
829 | 84 | |||
830 | 85 | #. module: stock_inventory_hierarchical_location | ||
831 | 86 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:122 | ||
832 | 87 | #, python-format | ||
833 | 88 | msgid "Some Sub-inventories are not confirmed." | ||
834 | 89 | msgstr "Au moins un sous-inventaire n'est pas confirmé." | ||
835 | 90 | |||
836 | 91 | #. module: stock_inventory_hierarchical_location | ||
837 | 92 | #: view:stock.inventory.missing.location:0 | ||
838 | 93 | msgid "This is the list of missing locations." | ||
839 | 94 | msgstr "Voici la liste des emplacements manquants." | ||
840 | 95 | |||
841 | 96 | #. module: stock_inventory_hierarchical_location | ||
842 | 97 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:58 | ||
843 | 98 | #, python-format | ||
844 | 99 | msgid "This location is not declared on the parent inventory\n" | ||
845 | 100 | "It cannot be added." | ||
846 | 101 | msgstr "Cet emplacement n'est pas déclaré dans l'inventaire parent\n" | ||
847 | 102 | "Vous ne pouvez pas l'ajouter." | ||
848 | 103 | |||
849 | 104 | #. module: stock_inventory_hierarchical_location | ||
850 | 105 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:41 | ||
851 | 106 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:70 | ||
852 | 107 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:122 | ||
853 | 108 | #, python-format | ||
854 | 109 | msgid "Warning !" | ||
855 | 110 | msgstr "Attention !" | ||
856 | 111 | |||
857 | 112 | #. module: stock_inventory_hierarchical_location | ||
858 | 113 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:57 | ||
859 | 114 | #, python-format | ||
860 | 115 | msgid "Warning: Wrong location" | ||
861 | 116 | msgstr "Attention: mauvais emplacement" | ||
862 | 117 | |||
863 | 118 | #. module: stock_inventory_hierarchical_location | ||
864 | 119 | #: view:stock.inventory.missing.location:0 | ||
865 | 120 | msgid "_Cancel" | ||
866 | 121 | msgstr "_Annuler" | ||
867 | 122 | |||
868 | 123 | #. module: stock_inventory_hierarchical_location | ||
869 | 124 | #: view:stock.inventory.missing.location:0 | ||
870 | 125 | msgid "_Confirm missing locations" | ||
871 | 126 | msgstr "_Confirmer les emplacements manquants" | ||
872 | 127 | |||
873 | 0 | 128 | ||
874 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location.py' | |||
875 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location.py 1970-01-01 00:00:00 +0000 | |||
876 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location.py 2014-06-27 09:18:58 +0000 | |||
877 | @@ -0,0 +1,100 @@ | |||
878 | 1 | # -*- coding: utf-8 -*- | ||
879 | 2 | ############################################################################## | ||
880 | 3 | # | ||
881 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
882 | 5 | # | ||
883 | 6 | # This program is free software: you can redistribute it and/or modify | ||
884 | 7 | # it under the terms of the GNU General Public License as published by | ||
885 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
886 | 9 | # (at your option) any later version. | ||
887 | 10 | # | ||
888 | 11 | # This program is distributed in the hope that it will be useful, | ||
889 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
890 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
891 | 14 | # GNU General Public License for more details. | ||
892 | 15 | # | ||
893 | 16 | # You should have received a copy of the GNU General Public License | ||
894 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
895 | 18 | # | ||
896 | 19 | ############################################################################## | ||
897 | 20 | |||
898 | 21 | from openerp.osv import orm | ||
899 | 22 | from openerp.tools.translate import _ | ||
900 | 23 | |||
901 | 24 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
902 | 25 | |||
903 | 26 | # Add the date to the list of fields we must propagate to children inventories | ||
904 | 27 | from stock_inventory_hierarchical import PARENT_VALUES | ||
905 | 28 | PARENT_VALUES.append('exhaustive') | ||
906 | 29 | |||
907 | 30 | |||
908 | 31 | class HierarchicalExhInventory(orm.Model): | ||
909 | 32 | """Add hierarchical structure features to exhaustive Inventories""" | ||
910 | 33 | _inherit = 'stock.inventory' | ||
911 | 34 | |||
912 | 35 | def action_open(self, cr, uid, ids, context=None): | ||
913 | 36 | """Open only if all the parents are Open.""" | ||
914 | 37 | for inventory in self.browse(cr, uid, ids, context=context): | ||
915 | 38 | while inventory.parent_id: | ||
916 | 39 | inventory = inventory.parent_id | ||
917 | 40 | if inventory.state != 'open': | ||
918 | 41 | raise HierarchicalInventoryException( | ||
919 | 42 | _('Warning'), | ||
920 | 43 | _('One of the parent inventories is not open.')) | ||
921 | 44 | return super(HierarchicalExhInventory, self).action_open( | ||
922 | 45 | cr, uid, ids, context=context) | ||
923 | 46 | |||
924 | 47 | def get_missing_locations(self, cr, uid, ids, context=None): | ||
925 | 48 | """Extend the list of inventories with their children""" | ||
926 | 49 | ids = self.search( | ||
927 | 50 | cr, uid, [('parent_id', 'child_of', ids)], context=context) | ||
928 | 51 | missing_ids = set( | ||
929 | 52 | super(HierarchicalExhInventory, self).get_missing_locations( | ||
930 | 53 | cr, uid, ids, context=context)) | ||
931 | 54 | # Find the locations already included in sub-inventories | ||
932 | 55 | inventories = self.browse(cr, uid, ids, context=context) | ||
933 | 56 | subinv_location_ids = [sub.location_id.id | ||
934 | 57 | for i in inventories | ||
935 | 58 | for sub in i.inventory_ids] | ||
936 | 59 | # Extend to the children locations | ||
937 | 60 | subinv_location_ids = set(self.pool['stock.location'].search( | ||
938 | 61 | cr, uid, [ | ||
939 | 62 | ('location_id', 'child_of', subinv_location_ids), | ||
940 | 63 | ('usage', '=', 'internal')], context=context)) | ||
941 | 64 | return list(missing_ids - subinv_location_ids) | ||
942 | 65 | |||
943 | 66 | # TODO v8: probably only keep the state "done" | ||
944 | 67 | def confirm_missing_locations(self, cr, uid, ids, context=None): | ||
945 | 68 | """Do something only if children state are confirm or done.""" | ||
946 | 69 | children_count = self.search( | ||
947 | 70 | cr, uid, [('parent_id', 'child_of', ids), | ||
948 | 71 | ('id', 'not in', ids), | ||
949 | 72 | ('state', 'not in', ['confirm', 'done'])], | ||
950 | 73 | context=context, count=True) | ||
951 | 74 | if children_count > 0: | ||
952 | 75 | raise HierarchicalInventoryException( | ||
953 | 76 | _('Warning'), | ||
954 | 77 | _('Some Sub-inventories are not confirmed.')) | ||
955 | 78 | return super(HierarchicalExhInventory, | ||
956 | 79 | self).confirm_missing_locations( | ||
957 | 80 | cr, uid, ids, context=context) | ||
958 | 81 | |||
959 | 82 | def onchange_location_id(self, cr, uid, ids, location_id, context=None): | ||
960 | 83 | """Check if location is a child of parent inventory location""" | ||
961 | 84 | loc_obj = self.pool['stock.location'] | ||
962 | 85 | for inventory in self.browse(cr, uid, ids, context=context): | ||
963 | 86 | if inventory.parent_id: | ||
964 | 87 | allowed_location_ids = loc_obj.search( | ||
965 | 88 | cr, uid, [('location_id', 'child_of', | ||
966 | 89 | inventory.parent_id.location_id.id)], | ||
967 | 90 | context=context) | ||
968 | 91 | if location_id not in allowed_location_ids: | ||
969 | 92 | return { | ||
970 | 93 | 'location_id': False, | ||
971 | 94 | 'warning': { | ||
972 | 95 | 'title': _('Warning: Wrong location'), | ||
973 | 96 | 'message': _("This location is not declared on " | ||
974 | 97 | "the parent inventory\n" | ||
975 | 98 | "It cannot be added.")} | ||
976 | 99 | } | ||
977 | 100 | return {} | ||
978 | 0 | 101 | ||
979 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml' | |||
980 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 1970-01-01 00:00:00 +0000 | |||
981 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 2014-06-27 09:18:58 +0000 | |||
982 | @@ -0,0 +1,28 @@ | |||
983 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
984 | 2 | <openerp> | ||
985 | 3 | <data noupdate="0"> | ||
986 | 4 | |||
987 | 5 | <!-- Record inventories we can use in the tests. --> | ||
988 | 6 | <!-- We need them in the demo data because test data is rolled back | ||
989 | 7 | whenever an exception is raised. --> | ||
990 | 8 | |||
991 | 9 | <!-- Record a hierarchical exhaustive inventory --> | ||
992 | 10 | <record id="parent_inventory" model="stock.inventory"> | ||
993 | 11 | <field name="name">Hierarchical exhaustive inventory</field> | ||
994 | 12 | <field name="state">draft</field> | ||
995 | 13 | <field name="date">2020-04-15 00:00:00</field> | ||
996 | 14 | <field name="exhaustive">True</field> | ||
997 | 15 | <field name="location_id" model="stock.location" ref="stock.stock_location_stock"/> | ||
998 | 16 | </record> | ||
999 | 17 | <record id="child_1_id" model="stock.inventory"> | ||
1000 | 18 | <field name="name">Team A</field> | ||
1001 | 19 | <field name="parent_id" ref="parent_inventory"/> | ||
1002 | 20 | <field name="location_id" model="stock.location" ref="stock.stock_location_14"/> | ||
1003 | 21 | </record> | ||
1004 | 22 | <record id="child_2_id" model="stock.inventory"> | ||
1005 | 23 | <field name="name">Team B</field> | ||
1006 | 24 | <field name="parent_id" ref="parent_inventory"/> | ||
1007 | 25 | <field name="location_id" model="stock.location" ref="stock.stock_location_components"/> | ||
1008 | 26 | </record> | ||
1009 | 27 | </data> | ||
1010 | 28 | </openerp> | ||
1011 | 0 | 29 | ||
1012 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml' | |||
1013 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml 1970-01-01 00:00:00 +0000 | |||
1014 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml 2014-06-27 09:18:58 +0000 | |||
1015 | @@ -0,0 +1,37 @@ | |||
1016 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1017 | 2 | <openerp> | ||
1018 | 3 | <data> | ||
1019 | 4 | <record model="ir.ui.view" id="stock_inventory_hierarchical_location_form_view"> | ||
1020 | 5 | <field name="name">hierarchical.inventory.location.form</field> | ||
1021 | 6 | <field name="model">stock.inventory</field> | ||
1022 | 7 | <field name="inherit_id" ref="stock.view_inventory_form" /> | ||
1023 | 8 | <field name="arch" type="xml"> | ||
1024 | 9 | |||
1025 | 10 | <xpath expr="/form//field[@name='exhaustive']" position="attributes"> | ||
1026 | 11 | <attribute name="attrs">{'readonly':[('parent_id', '!=', False)]}</attribute> | ||
1027 | 12 | </xpath> | ||
1028 | 13 | |||
1029 | 14 | <xpath expr="/form//field[@name='location_id']" position="attributes"> | ||
1030 | 15 | <attribute name="on_change">onchange_location_id(location_id)</attribute> | ||
1031 | 16 | </xpath> | ||
1032 | 17 | |||
1033 | 18 | </field> | ||
1034 | 19 | </record> | ||
1035 | 20 | |||
1036 | 21 | <record model="ir.ui.view" id="stock_ihl_exhautive_form_view"> | ||
1037 | 22 | <field name="name">hierarchical.inventory.location.exhautive.form</field> | ||
1038 | 23 | <field name="model">stock.inventory</field> | ||
1039 | 24 | <field name="inherit_id" ref="stock_inventory_hierarchical.stock_inventory_hierarchical_form_view" /> | ||
1040 | 25 | <field name="arch" type="xml"> | ||
1041 | 26 | <xpath expr="//field[@name='inventory_ids']" position="attributes"> | ||
1042 | 27 | <attribute name="context">{'default_parent_id': active_id, 'default_exhaustive': exhaustive}</attribute> | ||
1043 | 28 | </xpath> | ||
1044 | 29 | </field> | ||
1045 | 30 | </record> | ||
1046 | 31 | |||
1047 | 32 | <!-- Show hierarchical exhaustive inventories by default --> | ||
1048 | 33 | <record id="stock.action_inventory_form" model="ir.actions.act_window"> | ||
1049 | 34 | <field name="context">{'full':'1', 'search_default_exhaustive':1, 'search_default_main_inventories':1}</field> | ||
1050 | 35 | </record> | ||
1051 | 36 | </data> | ||
1052 | 37 | </openerp> | ||
1053 | 0 | 38 | ||
1054 | === added directory 'stock_inventory_hierarchical_location/static' | |||
1055 | === added directory 'stock_inventory_hierarchical_location/static/src' | |||
1056 | === added directory 'stock_inventory_hierarchical_location/static/src/img' | |||
1057 | === added file 'stock_inventory_hierarchical_location/static/src/img/icon.png' | |||
1058 | 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-27 09:18:58 +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-27 09:18:58 +0000 differ |
1059 | === added directory 'stock_inventory_hierarchical_location/tests' | |||
1060 | === added file 'stock_inventory_hierarchical_location/tests/__init__.py' | |||
1061 | --- stock_inventory_hierarchical_location/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
1062 | +++ stock_inventory_hierarchical_location/tests/__init__.py 2014-06-27 09:18:58 +0000 | |||
1063 | @@ -0,0 +1,39 @@ | |||
1064 | 1 | # -*- coding: utf-8 -*- | ||
1065 | 2 | # | ||
1066 | 3 | # | ||
1067 | 4 | # Authors: Laetitia Gangloff | ||
1068 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1069 | 6 | # All Rights Reserved | ||
1070 | 7 | # | ||
1071 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1072 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1073 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1074 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1075 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1076 | 13 | # Service Company. | ||
1077 | 14 | # | ||
1078 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1079 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1080 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1081 | 18 | # License, or (at your option) any later version. | ||
1082 | 19 | # | ||
1083 | 20 | # This program is distributed in the hope that it will be useful, | ||
1084 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1085 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1086 | 23 | # GNU Affero General Public License for more details. | ||
1087 | 24 | # | ||
1088 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1089 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1090 | 27 | # | ||
1091 | 28 | # | ||
1092 | 29 | |||
1093 | 30 | import fill_inventory_test | ||
1094 | 31 | |||
1095 | 32 | fast_suite = [ | ||
1096 | 33 | ] | ||
1097 | 34 | |||
1098 | 35 | checks = [ | ||
1099 | 36 | fill_inventory_test, | ||
1100 | 37 | ] | ||
1101 | 38 | |||
1102 | 39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1103 | 0 | 40 | ||
1104 | === added file 'stock_inventory_hierarchical_location/tests/fill_inventory_test.py' | |||
1105 | --- stock_inventory_hierarchical_location/tests/fill_inventory_test.py 1970-01-01 00:00:00 +0000 | |||
1106 | +++ stock_inventory_hierarchical_location/tests/fill_inventory_test.py 2014-06-27 09:18:58 +0000 | |||
1107 | @@ -0,0 +1,118 @@ | |||
1108 | 1 | # -*- coding: utf-8 -*- | ||
1109 | 2 | # | ||
1110 | 3 | # | ||
1111 | 4 | # Authors: Laetitia Gangloff | ||
1112 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1113 | 6 | # All Rights Reserved | ||
1114 | 7 | # | ||
1115 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1116 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1117 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1118 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1119 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1120 | 13 | # Service Company. | ||
1121 | 14 | # | ||
1122 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1123 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1124 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1125 | 18 | # License, or (at your option) any later version. | ||
1126 | 19 | # | ||
1127 | 20 | # This program is distributed in the hope that it will be useful, | ||
1128 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1129 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1130 | 23 | # GNU Affero General Public License for more details. | ||
1131 | 24 | # | ||
1132 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1133 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1134 | 27 | # | ||
1135 | 28 | # | ||
1136 | 29 | |||
1137 | 30 | import openerp.tests.common as common | ||
1138 | 31 | |||
1139 | 32 | DB = common.DB | ||
1140 | 33 | ADMIN_USER_ID = common.ADMIN_USER_ID | ||
1141 | 34 | |||
1142 | 35 | |||
1143 | 36 | class fill_inventory_test(common.TransactionCase): | ||
1144 | 37 | |||
1145 | 38 | def setUp(self): | ||
1146 | 39 | super(fill_inventory_test, self).setUp() | ||
1147 | 40 | |||
1148 | 41 | def test_missing_location(self): | ||
1149 | 42 | """ | ||
1150 | 43 | Test that when confirm a parent inventory, the child location are not in the confirmation result | ||
1151 | 44 | """ | ||
1152 | 45 | parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory') | ||
1153 | 46 | self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id]) | ||
1154 | 47 | # confirm shelf 1 inventory | ||
1155 | 48 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id') | ||
1156 | 49 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1157 | 50 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1158 | 51 | self.assertEqual(len(missing_location), 1, "1 missing location should be find, because the inventory is empty") | ||
1159 | 52 | wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]}) | ||
1160 | 53 | self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1161 | 54 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1162 | 55 | self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is confirmed") | ||
1163 | 56 | # confirm shelf 2 inventory | ||
1164 | 57 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id') | ||
1165 | 58 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1166 | 59 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1167 | 60 | self.assertEqual(len(missing_location), 1, "1 missing location should be fine, because the inventory is empty") | ||
1168 | 61 | self.registry('stock.inventory.line').create(self.cr, self.uid, {'product_id': self.ref('product.product_product_7'), | ||
1169 | 62 | 'product_uom': self.ref('product.product_uom_unit'), | ||
1170 | 63 | 'company_id': self.ref('base.main_company'), | ||
1171 | 64 | 'inventory_id': inventory_id, | ||
1172 | 65 | 'product_qty': 18.0, | ||
1173 | 66 | 'location_id': self.ref('stock.stock_location_14')}) | ||
1174 | 67 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1175 | 68 | self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is filled") | ||
1176 | 69 | wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]}) | ||
1177 | 70 | wizard = self.registry('stock.inventory.uninventoried.locations').browse(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1178 | 71 | self.assertEqual(len(wizard.location_ids), 0, "The wizard should not contain any lines but contains %s." % wizard.location_ids) | ||
1179 | 72 | self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1180 | 73 | # confirm parent inventory | ||
1181 | 74 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [parent_inventory_id]) | ||
1182 | 75 | self.assertEqual(len(missing_location), 1, "Only 1 missing location should be find, because there is some location in child inventory") | ||
1183 | 76 | |||
1184 | 77 | def test_fill_inventory(self): | ||
1185 | 78 | """ | ||
1186 | 79 | Test that when fill a parent inventory, the child location are not in the result | ||
1187 | 80 | """ | ||
1188 | 81 | parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory') | ||
1189 | 82 | self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id]) | ||
1190 | 83 | # confirm shelf 1 inventory | ||
1191 | 84 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id') | ||
1192 | 85 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1193 | 86 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_components'), | ||
1194 | 87 | 'recursive': True, | ||
1195 | 88 | 'exhaustive': True, | ||
1196 | 89 | 'set_stock_zero': True}, context={'active_ids': [inventory_id]}) | ||
1197 | 90 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]}) | ||
1198 | 91 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)]) | ||
1199 | 92 | self.assertEqual(len(inventory_line_ids), 12, "12 inventory line is fount after filling inventory") | ||
1200 | 93 | # confirm shelf 2 inventory | ||
1201 | 94 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id') | ||
1202 | 95 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1203 | 96 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_14'), | ||
1204 | 97 | 'recursive': True, | ||
1205 | 98 | 'exhaustive': True, | ||
1206 | 99 | 'set_stock_zero': True}, context={'active_ids': [inventory_id]}) | ||
1207 | 100 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]}) | ||
1208 | 101 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)]) | ||
1209 | 102 | self.assertEqual(len(inventory_line_ids), 4, "1 inventory line is fount after filling inventory") | ||
1210 | 103 | # confirm parent inventory | ||
1211 | 104 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_stock'), | ||
1212 | 105 | 'recursive': True, | ||
1213 | 106 | 'exhaustive': True, | ||
1214 | 107 | 'set_stock_zero': True}, context={'active_ids': [parent_inventory_id]}) | ||
1215 | 108 | try: | ||
1216 | 109 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [parent_inventory_id]}) | ||
1217 | 110 | except Exception, e: | ||
1218 | 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.''") | ||
1219 | 112 | exception_happened = True | ||
1220 | 113 | pass | ||
1221 | 114 | self.assertTrue(exception_happened) | ||
1222 | 115 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', parent_inventory_id)]) | ||
1223 | 116 | self.assertEqual(len(inventory_line_ids), 0, "No inventory line is fount after filling inventory") | ||
1224 | 117 | |||
1225 | 118 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1226 | 0 | 119 | ||
1227 | === added file 'stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml' | |||
1228 | --- stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml 1970-01-01 00:00:00 +0000 | |||
1229 | +++ stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml 2014-06-27 09:18:58 +0000 | |||
1230 | @@ -0,0 +1,56 @@ | |||
1231 | 1 | - | ||
1232 | 2 | Check that the exhaustive field of parent inventory has been propagated to children. | ||
1233 | 3 | - | ||
1234 | 4 | !python {model: stock.inventory}: | | ||
1235 | 5 | exhaustive = self.read(cr, uid, [ref("child_1_id")], ['exhaustive'])[0]['exhaustive'] | ||
1236 | 6 | assert exhaustive, "Exhaustive field not propagated to child inventory" | ||
1237 | 7 | |||
1238 | 8 | - | ||
1239 | 9 | Check that I can't open child inventory while parent inventory is open. | ||
1240 | 10 | - | ||
1241 | 11 | !python {model: stock.inventory}: | | ||
1242 | 12 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
1243 | 13 | parent_state = self.read(cr, uid, [ref("parent_inventory")], ['state'])[0]['state'] | ||
1244 | 14 | assert parent_state == 'draft', "Parent inventory in state '%s'. It should be 'draft'" % parent_state | ||
1245 | 15 | try: | ||
1246 | 16 | self.action_open(cr, uid, [ref("child_1_id")]) | ||
1247 | 17 | except HierarchicalInventoryException as e: | ||
1248 | 18 | log("Good ! The Inventory could not be opened: %s" % e) | ||
1249 | 19 | child_1_state = self.read(cr, uid, [ref("child_1_id")], ['state'])[0]['state'] | ||
1250 | 20 | assert child_1_state == 'draft', "Child inventory 1 have '%s' state. It should be 'draft'" % child_1_state | ||
1251 | 21 | |||
1252 | 22 | - | ||
1253 | 23 | I will check that the function get_missing_locations return some locations. | ||
1254 | 24 | - | ||
1255 | 25 | !python {model: stock.inventory}: | | ||
1256 | 26 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('parent_inventory')], context=context) | ||
1257 | 27 | assert len(missing_loc_ids)==3, "get_missing_locations did not return any ID." | ||
1258 | 28 | |||
1259 | 29 | - | ||
1260 | 30 | I will fill the inventory and check that the function get_missing_locations return no locations. | ||
1261 | 31 | Adding 17” LCD Monitor. | ||
1262 | 32 | - | ||
1263 | 33 | !record {model: stock.inventory.line, id: lines_inventory_location_pc1}: | ||
1264 | 34 | product_id: product.product_product_7 | ||
1265 | 35 | product_uom: product.product_uom_unit | ||
1266 | 36 | company_id: base.main_company | ||
1267 | 37 | inventory_id: child_1_id | ||
1268 | 38 | product_qty: 18.0 | ||
1269 | 39 | location_id: stock.stock_location_14 | ||
1270 | 40 | |||
1271 | 41 | - | ||
1272 | 42 | Adding USB Keyboard, QWERTY. | ||
1273 | 43 | - | ||
1274 | 44 | !record {model: stock.inventory.line, id: lines_inventory_location_pc3}: | ||
1275 | 45 | product_id: product.product_product_8 | ||
1276 | 46 | product_uom: product.product_uom_unit | ||
1277 | 47 | company_id: base.main_company | ||
1278 | 48 | inventory_id: child_2_id | ||
1279 | 49 | product_qty: 5.0 | ||
1280 | 50 | location_id: stock.stock_location_components | ||
1281 | 51 | |||
1282 | 52 | - | ||
1283 | 53 | !python {model: stock.inventory}: | | ||
1284 | 54 | |||
1285 | 55 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('parent_inventory')], context=context) | ||
1286 | 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) | ||
1287 | 0 | 57 | ||
1288 | === added directory 'stock_inventory_hierarchical_location/wizard' | |||
1289 | === added file 'stock_inventory_hierarchical_location/wizard/__init__.py' | |||
1290 | --- stock_inventory_hierarchical_location/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
1291 | +++ stock_inventory_hierarchical_location/wizard/__init__.py 2014-06-27 09:18:58 +0000 | |||
1292 | @@ -0,0 +1,22 @@ | |||
1293 | 1 | # -*- coding: utf-8 -*- | ||
1294 | 2 | ############################################################################## | ||
1295 | 3 | # | ||
1296 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1297 | 5 | # | ||
1298 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1299 | 7 | # it under the terms of the GNU General Public License as published by | ||
1300 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1301 | 9 | # (at your option) any later version. | ||
1302 | 10 | # | ||
1303 | 11 | # This program is distributed in the hope that it will be useful, | ||
1304 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1305 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1306 | 14 | # GNU General Public License for more details. | ||
1307 | 15 | # | ||
1308 | 16 | # You should have received a copy of the GNU General Public License | ||
1309 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1310 | 18 | # | ||
1311 | 19 | ############################################################################## | ||
1312 | 20 | |||
1313 | 21 | from . import stock_fill_location_inventory | ||
1314 | 22 | from . import generate_inventory | ||
1315 | 0 | 23 | ||
1316 | === added file 'stock_inventory_hierarchical_location/wizard/generate_inventory.py' | |||
1317 | --- stock_inventory_hierarchical_location/wizard/generate_inventory.py 1970-01-01 00:00:00 +0000 | |||
1318 | +++ stock_inventory_hierarchical_location/wizard/generate_inventory.py 2014-06-27 09:18:58 +0000 | |||
1319 | @@ -0,0 +1,134 @@ | |||
1320 | 1 | # -*- coding: utf-8 -*- | ||
1321 | 2 | # | ||
1322 | 3 | # | ||
1323 | 4 | # Authors: Laetitia Gangloff | ||
1324 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1325 | 6 | # All Rights Reserved | ||
1326 | 7 | # | ||
1327 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1328 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1329 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1330 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1331 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1332 | 13 | # Service Company. | ||
1333 | 14 | # | ||
1334 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1335 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1336 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1337 | 18 | # License, or (at your option) any later version. | ||
1338 | 19 | # | ||
1339 | 20 | # This program is distributed in the hope that it will be useful, | ||
1340 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1341 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1342 | 23 | # GNU Affero General Public License for more details. | ||
1343 | 24 | # | ||
1344 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1345 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1346 | 27 | # | ||
1347 | 28 | # | ||
1348 | 29 | |||
1349 | 30 | from openerp.osv import fields, orm | ||
1350 | 31 | from openerp.tools.translate import _ | ||
1351 | 32 | |||
1352 | 33 | |||
1353 | 34 | class GenerateInventoryWizard(orm.TransientModel): | ||
1354 | 35 | """ This wizard generate an inventory and all related sub-inventories for the specified location and level | ||
1355 | 36 | Example: location = Stock / level = 1 => 1 inventory on Stock (similar to create) | ||
1356 | 37 | location = Stock / level = 2 => 1 inventory on Stock, 1 sub-inventory on Shelf1, 1 sub-inventory on Shelf2 | ||
1357 | 38 | """ | ||
1358 | 39 | |||
1359 | 40 | _name = "stock.generate.inventory" | ||
1360 | 41 | _description = "Generate Inventory" | ||
1361 | 42 | |||
1362 | 43 | _columns = { | ||
1363 | 44 | 'prefix_inv_name': fields.char('Inventory prefix', help="Optional prefix for all created inventory"), | ||
1364 | 45 | 'location_id': fields.many2one('stock.location', 'Location', required=True), | ||
1365 | 46 | 'level': fields.integer("Level", help="number of level between inventory on location_id and sub-inventory"), | ||
1366 | 47 | 'only_view': fields.boolean('Only view', help="If set, only inventory on view location can be created"), | ||
1367 | 48 | } | ||
1368 | 49 | |||
1369 | 50 | def _default_location(self, cr, uid, ids, context=None): | ||
1370 | 51 | """Default stock location | ||
1371 | 52 | |||
1372 | 53 | @return: id of the stock location of the first warehouse of the | ||
1373 | 54 | default company""" | ||
1374 | 55 | location_id = False | ||
1375 | 56 | company_id = self.pool['res.company']._company_default_get( | ||
1376 | 57 | cr, uid, 'stock.warehouse', context=context) | ||
1377 | 58 | warehouse_id = self.pool['stock.warehouse'].search( | ||
1378 | 59 | cr, uid, [('company_id', '=', company_id)], limit=1) | ||
1379 | 60 | if warehouse_id: | ||
1380 | 61 | location_id = self.pool['stock.warehouse'].read( | ||
1381 | 62 | cr, uid, warehouse_id[0], ['lot_stock_id'])['lot_stock_id'][0] | ||
1382 | 63 | return location_id | ||
1383 | 64 | |||
1384 | 65 | _defaults = { | ||
1385 | 66 | 'location_id': _default_location, | ||
1386 | 67 | 'level': 1, | ||
1387 | 68 | 'only_view': True, | ||
1388 | 69 | } | ||
1389 | 70 | |||
1390 | 71 | _sql_constraints = [ | ||
1391 | 72 | ('level', 'CHECK (level>0)', 'Level must be positive!'), | ||
1392 | 73 | ] | ||
1393 | 74 | |||
1394 | 75 | def _create_subinventory(self, cr, uid, inventory_ids, prefix_inv_name, only_view, context): | ||
1395 | 76 | new_inventory_ids = [] | ||
1396 | 77 | for inventory_id in inventory_ids: | ||
1397 | 78 | location_id = self.pool['stock.inventory'].read(cr, uid, inventory_id, ['location_id'], context=context)['location_id'][0] | ||
1398 | 79 | domain = [('location_id', '=', location_id)] | ||
1399 | 80 | if only_view: | ||
1400 | 81 | domain.append(('usage', '=', 'view')) | ||
1401 | 82 | location_ids = self.pool['stock.location'].search(cr, uid, domain, context=context) | ||
1402 | 83 | for location_id in location_ids: | ||
1403 | 84 | location_name = self.pool['stock.location'].read(cr, uid, location_id, ['name'], context=context)['name'] | ||
1404 | 85 | new_inventory_ids.append(self.pool['stock.inventory'].create(cr, uid, {'name': prefix_inv_name + location_name, | ||
1405 | 86 | 'exhaustive': True, | ||
1406 | 87 | 'location_id': location_id, | ||
1407 | 88 | 'parent_id': inventory_id}, context=context)) | ||
1408 | 89 | return new_inventory_ids | ||
1409 | 90 | |||
1410 | 91 | def generate_inventory(self, cr, uid, ids, context=None): | ||
1411 | 92 | """ Generate inventory and sub-inventories for specified location and level | ||
1412 | 93 | |||
1413 | 94 | @param self: The object pointer. | ||
1414 | 95 | @param cr: A database cursor | ||
1415 | 96 | @param uid: ID of the user currently logged in | ||
1416 | 97 | @param ids: the ID or list of IDs if we want more than one | ||
1417 | 98 | @param context: A standard dictionary | ||
1418 | 99 | @return: | ||
1419 | 100 | """ | ||
1420 | 101 | if context is None: | ||
1421 | 102 | context = {} | ||
1422 | 103 | |||
1423 | 104 | if ids and len(ids): | ||
1424 | 105 | ids = ids[0] | ||
1425 | 106 | else: | ||
1426 | 107 | return {'type': 'ir.actions.act_window_close'} | ||
1427 | 108 | generate_inventory = self.browse(cr, uid, ids, context=context) | ||
1428 | 109 | # create first level inventory | ||
1429 | 110 | prefix_inv_name = generate_inventory.prefix_inv_name or '' | ||
1430 | 111 | location_id = generate_inventory.location_id.id | ||
1431 | 112 | only_view = generate_inventory.only_view | ||
1432 | 113 | parent_inventory_id = self.pool['stock.inventory'].create(cr, uid, {'name': prefix_inv_name + generate_inventory.location_id.name, | ||
1433 | 114 | 'exhaustive': True, | ||
1434 | 115 | 'location_id': location_id}, context=context) | ||
1435 | 116 | |||
1436 | 117 | inventory_ids = [parent_inventory_id] | ||
1437 | 118 | for i in range(1, generate_inventory.level): | ||
1438 | 119 | inventory_ids = self._create_subinventory(cr, uid, inventory_ids, prefix_inv_name, only_view, context) | ||
1439 | 120 | |||
1440 | 121 | mod_obj = self.pool['ir.model.data'] | ||
1441 | 122 | result = mod_obj.get_object_reference(cr, uid, 'stock', 'view_inventory_form') | ||
1442 | 123 | view_id = result and result[1] or False | ||
1443 | 124 | return {'name': _('Inventory generated'), | ||
1444 | 125 | 'view_mode': 'form', | ||
1445 | 126 | 'view_type': 'form', | ||
1446 | 127 | 'res_model': 'stock.inventory', | ||
1447 | 128 | 'type': 'ir.actions.act_window', | ||
1448 | 129 | 'view_id': view_id, | ||
1449 | 130 | 'res_id': int(parent_inventory_id), | ||
1450 | 131 | } | ||
1451 | 132 | |||
1452 | 133 | |||
1453 | 134 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1454 | 0 | 135 | ||
1455 | === added file 'stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml' | |||
1456 | --- stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml 1970-01-01 00:00:00 +0000 | |||
1457 | +++ stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml 2014-06-27 09:18:58 +0000 | |||
1458 | @@ -0,0 +1,42 @@ | |||
1459 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1460 | 2 | <openerp> | ||
1461 | 3 | <data> | ||
1462 | 4 | <record id="view_stock_generate_inventory" model="ir.ui.view"> | ||
1463 | 5 | <field name="name">Generate Inventory</field> | ||
1464 | 6 | <field name="model">stock.generate.inventory</field> | ||
1465 | 7 | <field name="arch" type="xml"> | ||
1466 | 8 | <form string="Generate Inventory" version="7.0"> | ||
1467 | 9 | <separator string="Generate inventory"/> | ||
1468 | 10 | <group> | ||
1469 | 11 | <field name="prefix_inv_name"/> | ||
1470 | 12 | <field name="location_id"/> | ||
1471 | 13 | <field name="only_view"/> | ||
1472 | 14 | <field name="level"/> | ||
1473 | 15 | </group> | ||
1474 | 16 | <footer> | ||
1475 | 17 | <button name="generate_inventory" string="Generate Inventory" type="object" class="oe_highlight"/> | ||
1476 | 18 | or | ||
1477 | 19 | <button string="Cancel" class="oe_link" special="cancel" /> | ||
1478 | 20 | </footer> | ||
1479 | 21 | </form> | ||
1480 | 22 | </field> | ||
1481 | 23 | </record> | ||
1482 | 24 | |||
1483 | 25 | <record id="action_view_stock_generate_inventory" model="ir.actions.act_window"> | ||
1484 | 26 | <field name="name">Generate Inventory</field> | ||
1485 | 27 | <field name="type">ir.actions.act_window</field> | ||
1486 | 28 | <field name="res_model">stock.generate.inventory</field> | ||
1487 | 29 | <field name="view_type">form</field> | ||
1488 | 30 | <field name="view_mode">form</field> | ||
1489 | 31 | <field name="view_id" ref="view_stock_generate_inventory"/> | ||
1490 | 32 | <field name="target">new</field> | ||
1491 | 33 | </record> | ||
1492 | 34 | |||
1493 | 35 | <menuitem action="action_view_stock_generate_inventory" | ||
1494 | 36 | id="menu_action_stock_generate_inventory_form" | ||
1495 | 37 | parent="stock.menu_stock_inventory_control" | ||
1496 | 38 | sequence="20" | ||
1497 | 39 | groups="stock.group_locations"/> | ||
1498 | 40 | |||
1499 | 41 | </data> | ||
1500 | 42 | </openerp> | ||
1501 | 0 | 43 | ||
1502 | === added file 'stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py' | |||
1503 | --- stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 1970-01-01 00:00:00 +0000 | |||
1504 | +++ stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 2014-06-27 09:18:58 +0000 | |||
1505 | @@ -0,0 +1,89 @@ | |||
1506 | 1 | # -*- coding: utf-8 -*- | ||
1507 | 2 | # | ||
1508 | 3 | # | ||
1509 | 4 | # Authors: Laetitia Gangloff | ||
1510 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1511 | 6 | # All Rights Reserved | ||
1512 | 7 | # | ||
1513 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1514 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1515 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1516 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1517 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1518 | 13 | # Service Company. | ||
1519 | 14 | # | ||
1520 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1521 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1522 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1523 | 18 | # License, or (at your option) any later version. | ||
1524 | 19 | # | ||
1525 | 20 | # This program is distributed in the hope that it will be useful, | ||
1526 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1527 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1528 | 23 | # GNU Affero General Public License for more details. | ||
1529 | 24 | # | ||
1530 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1531 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1532 | 27 | # | ||
1533 | 28 | # | ||
1534 | 29 | |||
1535 | 30 | from openerp.osv import orm, osv | ||
1536 | 31 | from openerp.tools.translate import _ | ||
1537 | 32 | |||
1538 | 33 | |||
1539 | 34 | class FillInventoryWizard(orm.TransientModel): | ||
1540 | 35 | """If inventory as sub inventories, do not fill with sub inventories location""" | ||
1541 | 36 | _inherit = 'stock.fill.inventory' | ||
1542 | 37 | |||
1543 | 38 | def fill_inventory(self, cr, uid, ids, context=None): | ||
1544 | 39 | """ To Import stock inventory according to products available in the location and not already in a sub inventory | ||
1545 | 40 | |||
1546 | 41 | We split fill_inventory on many fill_inventory (one for each location) | ||
1547 | 42 | @param self: The object pointer. | ||
1548 | 43 | @param cr: A database cursor | ||
1549 | 44 | @param uid: ID of the user currently logged in | ||
1550 | 45 | @param ids: the ID or list of IDs if we want more than one | ||
1551 | 46 | @param context: A standard dictionary | ||
1552 | 47 | @return: | ||
1553 | 48 | """ | ||
1554 | 49 | if context is None: | ||
1555 | 50 | context = {} | ||
1556 | 51 | |||
1557 | 52 | if ids and len(ids): | ||
1558 | 53 | ids = ids[0] | ||
1559 | 54 | else: | ||
1560 | 55 | return {'type': 'ir.actions.act_window_close'} | ||
1561 | 56 | fill_inventory = self.browse(cr, uid, ids, context=context) | ||
1562 | 57 | if fill_inventory.recursive and fill_inventory.exhaustive: | ||
1563 | 58 | exclude_location_ids = [] | ||
1564 | 59 | for i in self.pool['stock.inventory'].browse(cr, uid, context['active_ids']): | ||
1565 | 60 | for sub_inventory in i.inventory_ids: | ||
1566 | 61 | # exclude these location | ||
1567 | 62 | exclude_location_ids.append(sub_inventory.location_id.id) | ||
1568 | 63 | domain = [('location_id', 'child_of', [fill_inventory.location_id.id])] | ||
1569 | 64 | if exclude_location_ids: | ||
1570 | 65 | domain.append('!') | ||
1571 | 66 | domain.append(('location_id', 'child_of', exclude_location_ids)) | ||
1572 | 67 | location_ids = self.pool['stock.location'].search(cr, uid, domain, | ||
1573 | 68 | order="id", | ||
1574 | 69 | context=context) | ||
1575 | 70 | all_in_exception = 0 | ||
1576 | 71 | for location_id in location_ids: | ||
1577 | 72 | try: | ||
1578 | 73 | super(FillInventoryWizard, self).fill_inventory(cr, uid, | ||
1579 | 74 | [self.copy(cr, uid, ids, {'location_id': location_id, | ||
1580 | 75 | 'recursive': False, }, context=context)], | ||
1581 | 76 | context=context) | ||
1582 | 77 | except osv.except_osv, e: | ||
1583 | 78 | if e.value == _('No product in this location. Please select a location in the product form.'): | ||
1584 | 79 | all_in_exception = all_in_exception + 1 | ||
1585 | 80 | pass | ||
1586 | 81 | else: | ||
1587 | 82 | raise e | ||
1588 | 83 | if all_in_exception == len(location_ids): | ||
1589 | 84 | raise orm.except_orm(_('Warning!'), _('No product in this location. Please select a location in the product form.')) | ||
1590 | 85 | return {'type': 'ir.actions.act_window_close'} | ||
1591 | 86 | else: | ||
1592 | 87 | return super(FillInventoryWizard, self).fill_inventory(cr, uid, [ids], context=context) | ||
1593 | 88 | |||
1594 | 89 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1595 | 0 | 90 | ||
1596 | === added directory 'stock_inventory_location' | |||
1597 | === added file 'stock_inventory_location/__init__.py' | |||
1598 | --- stock_inventory_location/__init__.py 1970-01-01 00:00:00 +0000 | |||
1599 | +++ stock_inventory_location/__init__.py 2014-06-27 09:18:58 +0000 | |||
1600 | @@ -0,0 +1,24 @@ | |||
1601 | 1 | # -*- coding: utf-8 -*- | ||
1602 | 2 | ############################################################################## | ||
1603 | 3 | # | ||
1604 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1605 | 5 | # | ||
1606 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1607 | 7 | # it under the terms of the GNU General Public License as published by | ||
1608 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1609 | 9 | # (at your option) any later version. | ||
1610 | 10 | # | ||
1611 | 11 | # This program is distributed in the hope that it will be useful, | ||
1612 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1613 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1614 | 14 | # GNU General Public License for more details. | ||
1615 | 15 | # | ||
1616 | 16 | # You should have received a copy of the GNU General Public License | ||
1617 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1618 | 18 | # | ||
1619 | 19 | ############################################################################## | ||
1620 | 20 | |||
1621 | 21 | import stock_inventory_location | ||
1622 | 22 | import wizard | ||
1623 | 23 | # Bring the main exception into the package's scope for easier reuse | ||
1624 | 24 | from .exceptions import ExhaustiveInventoryException | ||
1625 | 0 | 25 | ||
1626 | === added file 'stock_inventory_location/__openerp__.py' | |||
1627 | --- stock_inventory_location/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
1628 | +++ stock_inventory_location/__openerp__.py 2014-06-27 09:18:58 +0000 | |||
1629 | @@ -0,0 +1,77 @@ | |||
1630 | 1 | # -*- coding: utf-8 -*- | ||
1631 | 2 | ############################################################################## | ||
1632 | 3 | # | ||
1633 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1634 | 5 | # | ||
1635 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1636 | 7 | # it under the terms of the GNU General Public License as published by | ||
1637 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1638 | 9 | # (at your option) any later version. | ||
1639 | 10 | # | ||
1640 | 11 | # This program is distributed in the hope that it will be useful, | ||
1641 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1642 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1643 | 14 | # GNU General Public License for more details. | ||
1644 | 15 | # | ||
1645 | 16 | # You should have received a copy of the GNU General Public License | ||
1646 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1647 | 18 | # | ||
1648 | 19 | ############################################################################## | ||
1649 | 20 | |||
1650 | 21 | { | ||
1651 | 22 | "name": "Exhaustive Stock Inventories", | ||
1652 | 23 | "version": "1.1", | ||
1653 | 24 | "depends": ["stock"], | ||
1654 | 25 | "author": u"Numérigraphe", | ||
1655 | 26 | "category": "Warehouse Management", | ||
1656 | 27 | "description": """ | ||
1657 | 28 | Let users make exhaustive Inventories | ||
1658 | 29 | ===================================== | ||
1659 | 30 | |||
1660 | 31 | Standard Physical Inventories in OpenERP only contain a generic list of | ||
1661 | 32 | products by locations, which is well suited to partial Inventories and simple | ||
1662 | 33 | warehouses. When the a standard Inventory is confirmed, only the products in | ||
1663 | 34 | the inventory are checked. If a Product is present in the computed stock and | ||
1664 | 35 | not in the recorded Inventory, OpenERP will consider that it remains unchanged. | ||
1665 | 36 | |||
1666 | 37 | But for exhaustive inventories in complex warehouses, it is not practical: | ||
1667 | 38 | - you want to avoid Stock Moves to/from these Locations while counting goods | ||
1668 | 39 | - you must make sure all the locations you want have been counted | ||
1669 | 40 | - you must make sure no other location has been counted by mistake | ||
1670 | 41 | - you want the computed stock to perfectly match the inventory when you | ||
1671 | 42 | confirm it. | ||
1672 | 43 | |||
1673 | 44 | This module lets choose whether an Physical Inventory is exhaustive or | ||
1674 | 45 | standard. | ||
1675 | 46 | For an exhaustive Inventory: | ||
1676 | 47 | - in the state "Draft" you define the Location where goods must be counted. | ||
1677 | 48 | - the new Inventory status "Open" lets you indicate that the list of Locations | ||
1678 | 49 | is final and you are now counting the goods. | ||
1679 | 50 | In that status, no Stock Moves can be recorded in/out of the Inventory's | ||
1680 | 51 | Locations. | ||
1681 | 52 | - if the Location or some of it's children have not been entered in the | ||
1682 | 53 | Inventory Lines, OpenERP warns you when you confirm the Inventory. | ||
1683 | 54 | - only the Inventory's Location or its children can be entered in the | ||
1684 | 55 | Inventory Lines. | ||
1685 | 56 | - every good that is not in the Inventory Lines is considered lost, and gets | ||
1686 | 57 | moved out of the stock when you confirm the Inventory. | ||
1687 | 58 | """, | ||
1688 | 59 | "data": [ | ||
1689 | 60 | "wizard/stock_confirm_uninventoried_location.xml", | ||
1690 | 61 | "stock_inventory_location_view.xml", | ||
1691 | 62 | "wizard/stock_fill_location_inventory_view.xml", | ||
1692 | 63 | ], | ||
1693 | 64 | "test": [ | ||
1694 | 65 | "tests/inventory_standard_test.yml", | ||
1695 | 66 | "tests/inventory_exhaustive_test.yml", | ||
1696 | 67 | "tests/inventory_future_test.yml", | ||
1697 | 68 | ], | ||
1698 | 69 | "images": [ | ||
1699 | 70 | "images/inventory_form.png", | ||
1700 | 71 | "inventory_empty_locations.png", | ||
1701 | 72 | "images/move_error.png", | ||
1702 | 73 | "images/location_locked.png", | ||
1703 | 74 | "images/future_inventory.png", | ||
1704 | 75 | ], | ||
1705 | 76 | "demo": ["stock_inventory_location_demo.xml"] | ||
1706 | 77 | } | ||
1707 | 0 | 78 | ||
1708 | === added file 'stock_inventory_location/exceptions.py' | |||
1709 | --- stock_inventory_location/exceptions.py 1970-01-01 00:00:00 +0000 | |||
1710 | +++ stock_inventory_location/exceptions.py 2014-06-27 09:18:58 +0000 | |||
1711 | @@ -0,0 +1,26 @@ | |||
1712 | 1 | # -*- coding: utf-8 -*- | ||
1713 | 2 | ############################################################################## | ||
1714 | 3 | # | ||
1715 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1716 | 5 | # | ||
1717 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1718 | 7 | # it under the terms of the GNU General Public License as published by | ||
1719 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1720 | 9 | # (at your option) any later version. | ||
1721 | 10 | # | ||
1722 | 11 | # This program is distributed in the hope that it will be useful, | ||
1723 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1724 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1725 | 14 | # GNU General Public License for more details. | ||
1726 | 15 | # | ||
1727 | 16 | # You should have received a copy of the GNU General Public License | ||
1728 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1729 | 18 | # | ||
1730 | 19 | ############################################################################## | ||
1731 | 20 | |||
1732 | 21 | from openerp.osv import orm | ||
1733 | 22 | |||
1734 | 23 | |||
1735 | 24 | class ExhaustiveInventoryException(orm.except_orm): | ||
1736 | 25 | """The operation is not possible for an exhaustive inventory""" | ||
1737 | 26 | pass | ||
1738 | 0 | 27 | ||
1739 | === added directory 'stock_inventory_location/i18n' | |||
1740 | === added file 'stock_inventory_location/i18n/fr.po' | |||
1741 | --- stock_inventory_location/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
1742 | +++ stock_inventory_location/i18n/fr.po 2014-06-27 09:18:58 +0000 | |||
1743 | @@ -0,0 +1,241 @@ | |||
1744 | 1 | # Translation of OpenERP Server. | ||
1745 | 2 | # This file contains the translation of the following modules: | ||
1746 | 3 | # * stock_inventory_location | ||
1747 | 4 | # | ||
1748 | 5 | msgid "" | ||
1749 | 6 | msgstr "" | ||
1750 | 7 | "Project-Id-Version: OpenERP Server 6.0.4\n" | ||
1751 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
1752 | 9 | "POT-Creation-Date: 2013-09-25 13:58+0000\n" | ||
1753 | 10 | "PO-Revision-Date: 2013-09-25 13:58+0000\n" | ||
1754 | 11 | "Last-Translator: <>\n" | ||
1755 | 12 | "Language-Team: \n" | ||
1756 | 13 | "MIME-Version: 1.0\n" | ||
1757 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
1758 | 15 | "Content-Transfer-Encoding: \n" | ||
1759 | 16 | "Plural-Forms: \n" | ||
1760 | 17 | |||
1761 | 18 | #. module: stock_inventory_location | ||
1762 | 19 | #: code:addons/stock_inventory_location/stock_inventory_location.py:232 | ||
1763 | 20 | #: constraint:stock.move:0 | ||
1764 | 21 | #, python-format | ||
1765 | 22 | msgid "A Physical Inventory is being conducted at this location" | ||
1766 | 23 | msgstr "Un inventaire est en cours à cet emplacement" | ||
1767 | 24 | |||
1768 | 25 | #. module: stock_inventory_location | ||
1769 | 26 | #: view:stock.inventory.uninventoried.locations:0 | ||
1770 | 27 | msgid "Cancel" | ||
1771 | 28 | msgstr "Annuler" | ||
1772 | 29 | |||
1773 | 30 | #. module: stock_inventory_location | ||
1774 | 31 | #: view:stock.inventory:0 | ||
1775 | 32 | msgid "Cancel Inventory" | ||
1776 | 33 | msgstr "Annuler l'inventaire" | ||
1777 | 34 | |||
1778 | 35 | #. module: stock_inventory_location | ||
1779 | 36 | #: help:stock.inventory,exhaustive:0 | ||
1780 | 37 | msgid "Check the box if you are conducting an exhaustive Inventory.\n" | ||
1781 | 38 | "Leave the box unchecked if you are conducting a standard Inventory (partial inventory for example).\n" | ||
1782 | 39 | "For an exhaustive Inventory:\n" | ||
1783 | 40 | " - the status \"Draft\" lets you define the list of Locations where goods must be counted\n" | ||
1784 | 41 | " - the status \"Open\" indicates that the list of Locations is definitive and you are now counting the goods. In that status, no Stock Moves can be recorded in/out of the Inventory's Locations\n" | ||
1785 | 42 | " - only the Inventory's Locations can be entered in the Inventory Lines\n" | ||
1786 | 43 | " - if some of the Inventory's Locations have not been entered in the Inventory Lines, OpenERP warns you when you confirm the Inventory\n" | ||
1787 | 44 | " - every good that is not in the Inventory Lines is considered lost, and gets moved out of the stock when you confirm the Inventory" | ||
1788 | 45 | msgstr "Cochez la case si vous effectuez un inventaire exhaustif.\n" | ||
1789 | 46 | "Laissez la case non-dochée si vous effectuez un inventaire standard (par exmple un inventaire partiel).\n" | ||
1790 | 47 | "Pour les inventaires exhaustifs :\n" | ||
1791 | 48 | " - le statut \"Brouillon\" permet d'indiquer la liste des emplacements dont la marchandise doit être comptée\n" | ||
1792 | 49 | " - le statut \"Ouvert\" indiqueque la liste des emplacements est définitive, et que le comptage est en cours. Dans ce statut, aucun mouvement de stock ne peut être enregistré depuis/vers les emplacements de l'inventaire\n" | ||
1793 | 50 | " - seuls les emplacements de l'inventaire peuvent être saisis dans les lignes d'inventaire\n" | ||
1794 | 51 | " - si certains emplacements sont absent des lignes d'inventaire, OpenERP vous en avertit lors de la confirmation de l'inventaire\n" | ||
1795 | 52 | " - toutes les marchandises qui ne sont pas dans les lignes d'inventaire sont considérées comme perdues, et sont supprimées lors de la confirmation de l'inventaire" | ||
1796 | 53 | |||
1797 | 54 | #. module: stock_inventory_location | ||
1798 | 55 | #: view:stock.inventory:0 | ||
1799 | 56 | msgid "Confirm Inventory" | ||
1800 | 57 | msgstr "Confirmer l'inventaire" | ||
1801 | 58 | |||
1802 | 59 | #. module: stock_inventory_location | ||
1803 | 60 | #: model:ir.model,name:stock_inventory_location.model_stock_inventory_uninventoried_locations | ||
1804 | 61 | msgid "Confirm the uninventoried Locations." | ||
1805 | 62 | msgstr "Confirmer les emplacements non inventoriés." | ||
1806 | 63 | |||
1807 | 64 | #. module: stock_inventory_location | ||
1808 | 65 | #: view:stock.inventory.uninventoried.locations:0 | ||
1809 | 66 | msgid "Confirm empty locations" | ||
1810 | 67 | msgstr "Confirmez les emplacements vides" | ||
1811 | 68 | |||
1812 | 69 | #. module: stock_inventory_location | ||
1813 | 70 | #: model:ir.model,name:stock_inventory_location.model_stock_location | ||
1814 | 71 | msgid "Emplacement" | ||
1815 | 72 | msgstr "Emplacement" | ||
1816 | 73 | |||
1817 | 74 | #. module: stock_inventory_location | ||
1818 | 75 | #: code:addons/stock_inventory_location/wizard/stock_fill_location_inventory.py:54 | ||
1819 | 76 | #, python-format | ||
1820 | 77 | msgid "Error" | ||
1821 | 78 | msgstr "Erreur" | ||
1822 | 79 | |||
1823 | 80 | #. module: stock_inventory_location | ||
1824 | 81 | #: code:addons/stock_inventory_location/wizard/stock_fill_location_inventory.py:75 | ||
1825 | 82 | #, python-format | ||
1826 | 83 | msgid "Error: Empty location" | ||
1827 | 84 | msgstr "Erreur : Emplacement vide" | ||
1828 | 85 | |||
1829 | 86 | #. module: stock_inventory_location | ||
1830 | 87 | #: code:addons/stock_inventory_location/stock_inventory_location.py:231 | ||
1831 | 88 | #: code:addons/stock_inventory_location/stock_inventory_location.py:282 | ||
1832 | 89 | #, python-format | ||
1833 | 90 | msgid "Error: Location locked down" | ||
1834 | 91 | msgstr "Erreur: emplacement en inventaire" | ||
1835 | 92 | |||
1836 | 93 | #. module: stock_inventory_location | ||
1837 | 94 | #: constraint:stock.inventory:0 | ||
1838 | 95 | msgid "Error: You can not create recursive inventories." | ||
1839 | 96 | msgstr "Erreur: Vous ne pouvez pas créer un inventaire récursif." | ||
1840 | 97 | |||
1841 | 98 | #. module: stock_inventory_location | ||
1842 | 99 | #: constraint:stock.inventory.line:0 | ||
1843 | 100 | msgid "Error: duplicates lines" | ||
1844 | 101 | msgstr "Erreur: lignes en double" | ||
1845 | 102 | |||
1846 | 103 | #. module: stock_inventory_location | ||
1847 | 104 | #: view:stock.inventory:0 | ||
1848 | 105 | #: field:stock.inventory,exhaustive:0 | ||
1849 | 106 | msgid "Exhaustive" | ||
1850 | 107 | msgstr "Exhaustif" | ||
1851 | 108 | |||
1852 | 109 | #. module: stock_inventory_location | ||
1853 | 110 | #: model:ir.model,name:stock_inventory_location.model_stock_inventory | ||
1854 | 111 | msgid "Gestion des stocks" | ||
1855 | 112 | msgstr "Gestion des stocks" | ||
1856 | 113 | |||
1857 | 114 | #. module: stock_inventory_location | ||
1858 | 115 | #: view:stock.inventory.uninventoried.locations:0 | ||
1859 | 116 | msgid "If you confirm the Inventory, these Locations will be considered empty and their content will be purged." | ||
1860 | 117 | msgstr "Si vous confirmez l'inventaire, ces emplacements seront considérés comme vides et leur contenu sera supprimé." | ||
1861 | 118 | |||
1862 | 119 | #. module: stock_inventory_location | ||
1863 | 120 | #: model:ir.model,name:stock_inventory_location.model_stock_fill_inventory | ||
1864 | 121 | msgid "Importer un inventaire" | ||
1865 | 122 | msgstr "Importer un inventaire" | ||
1866 | 123 | |||
1867 | 124 | #. module: stock_inventory_location | ||
1868 | 125 | #: view:stock.inventory.uninventoried.locations:0 | ||
1869 | 126 | msgid "It could either mean that the Locations are empty, or that the Inventory is not yet complete." | ||
1870 | 127 | msgstr "Cela peut vouloir dire soit que l'inventaire n'est pas terminé, soit que ces emplacements sont effectivement vides." | ||
1871 | 128 | |||
1872 | 129 | #. module: stock_inventory_location | ||
1873 | 130 | #: model:ir.model,name:stock_inventory_location.model_stock_inventory_line | ||
1874 | 131 | msgid "Ligne d'inventaire" | ||
1875 | 132 | msgstr "Ligne d'inventaire" | ||
1876 | 133 | |||
1877 | 134 | #. module: stock_inventory_location | ||
1878 | 135 | #: code:addons/stock_inventory_location/stock_inventory_location.py:59 | ||
1879 | 136 | #, python-format | ||
1880 | 137 | msgid "Location missing for this inventory." | ||
1881 | 138 | msgstr "Emplacement manquant pour cet inventaire." | ||
1882 | 139 | |||
1883 | 140 | #. module: stock_inventory_location | ||
1884 | 141 | #: model:ir.model,name:stock_inventory_location.model_stock_move | ||
1885 | 142 | msgid "Mouvement de stock" | ||
1886 | 143 | msgstr "Mouvement de stock" | ||
1887 | 144 | |||
1888 | 145 | #. module: stock_inventory_location | ||
1889 | 146 | #: code:addons/stock_inventory_location/wizard/stock_fill_location_inventory.py:75 | ||
1890 | 147 | #, python-format | ||
1891 | 148 | msgid "No location to import.\n" | ||
1892 | 149 | "You must add a location on the locations list." | ||
1893 | 150 | msgstr "Pas d'emplacement à importer.\n" | ||
1894 | 151 | "Vous devez ajouter un emplacement dans la liste des emplacements." | ||
1895 | 152 | |||
1896 | 153 | #. module: stock_inventory_location | ||
1897 | 154 | #: code:addons/stock_inventory_location/wizard/stock_fill_location_inventory.py:58 | ||
1898 | 155 | #, python-format | ||
1899 | 156 | msgid "No locations found for the inventory." | ||
1900 | 157 | msgstr "Pas d'emplacement trouvé pour cet inventaire." | ||
1901 | 158 | |||
1902 | 159 | #. module: stock_inventory_location | ||
1903 | 160 | #: code:addons/stock_inventory_location/stock_inventory_location.py:163 | ||
1904 | 161 | #, python-format | ||
1905 | 162 | msgid "No product in this location." | ||
1906 | 163 | msgstr "Pas de produit à cet emplacement." | ||
1907 | 164 | |||
1908 | 165 | #. module: stock_inventory_location | ||
1909 | 166 | #: code:addons/stock_inventory_location/stock_inventory_location.py:283 | ||
1910 | 167 | #, python-format | ||
1911 | 168 | msgid "A Physical Inventory is being conducted at the following location(s):\n" | ||
1912 | 169 | "%s" | ||
1913 | 170 | msgstr "Les emplacements suivants sont en inventaire :\n" | ||
1914 | 171 | "%s" | ||
1915 | 172 | |||
1916 | 173 | #. module: stock_inventory_location | ||
1917 | 174 | #: view:stock.inventory:0 | ||
1918 | 175 | msgid "Open Inventory" | ||
1919 | 176 | msgstr "Ouvrir l'inventaire" | ||
1920 | 177 | |||
1921 | 178 | #. module: stock_inventory_location | ||
1922 | 179 | #: constraint:stock.inventory:0 | ||
1923 | 180 | msgid "Other Physical inventories are being conducted using the same Locations." | ||
1924 | 181 | msgstr "Erreur: certains emplacements sont déjà dans un autre inventaire." | ||
1925 | 182 | |||
1926 | 183 | #. module: stock_inventory_location | ||
1927 | 184 | #: view:stock.inventory.uninventoried.locations:0 | ||
1928 | 185 | msgid "Purge contents and confirm Inventory" | ||
1929 | 186 | msgstr "Supprimer le contenu et confirmer l'inventaire" | ||
1930 | 187 | |||
1931 | 188 | #. module: stock_inventory_location | ||
1932 | 189 | #: view:stock.inventory.uninventoried.locations:0 | ||
1933 | 190 | msgid "The following Stock Locations are part of the current Physical Inventory, but no Inventory Line has been recorded for them." | ||
1934 | 191 | msgstr "Les emplacements suivants font partie de l'inventaire en cours, mais aucune ligne d'inventaire les concernant n'a été enregistrée." | ||
1935 | 192 | |||
1936 | 193 | #. module: stock_inventory_location | ||
1937 | 194 | #: field:stock.inventory.uninventoried.locations,location_ids:0 | ||
1938 | 195 | msgid "Uninventoried location" | ||
1939 | 196 | msgstr "Emplacements non inventoriés" | ||
1940 | 197 | |||
1941 | 198 | #. module: stock_inventory_location | ||
1942 | 199 | #: code:addons/stock_inventory_location/stock_inventory_location.py:59 | ||
1943 | 200 | #: code:addons/stock_inventory_location/stock_inventory_location.py:163 | ||
1944 | 201 | #: code:addons/stock_inventory_location/wizard/stock_fill_location_inventory.py:58 | ||
1945 | 202 | #, python-format | ||
1946 | 203 | msgid "Warning" | ||
1947 | 204 | msgstr "Attention" | ||
1948 | 205 | |||
1949 | 206 | #. module: stock_inventory_location | ||
1950 | 207 | #: code:addons/stock_inventory_location/stock_inventory_location.py:209 | ||
1951 | 208 | #, python-format | ||
1952 | 209 | msgid "Warning: Wrong location" | ||
1953 | 210 | msgstr "Attention: emplacement incorrect" | ||
1954 | 211 | |||
1955 | 212 | #. module: stock_inventory_location | ||
1956 | 213 | #: code:addons/stock_inventory_location/stock_inventory_location.py:210 | ||
1957 | 214 | #, python-format | ||
1958 | 215 | msgid "You cannot record an Inventory Line for this Location.\n" | ||
1959 | 216 | "You must first add this Location to the list of affected Locations on the Inventory form." | ||
1960 | 217 | msgstr "Vous ne pouvez pas ajouter cet emplacement.\n" | ||
1961 | 218 | "Il ne fait pas partie de la liste des emplacements à inventorier" | ||
1962 | 219 | |||
1963 | 220 | #. module: stock_inventory_location | ||
1964 | 221 | #: constraint:stock.move:0 | ||
1965 | 222 | msgid "You must assign a production lot for this product" | ||
1966 | 223 | msgstr "Vous devez affecter un lot de fabrication à ce produit." | ||
1967 | 224 | |||
1968 | 225 | #. module: stock_inventory_location | ||
1969 | 226 | #: constraint:stock.inventory.line:0 | ||
1970 | 227 | msgid "You must not create same inventory line Product, Location, Lot on the same date" | ||
1971 | 228 | msgstr "Vous ne pouvez pas créer plusieurs lignes d'inventaires pour le même produit, lot, emplacement à la même date" | ||
1972 | 229 | |||
1973 | 230 | #. module: stock_inventory_location | ||
1974 | 231 | #: constraint:stock.move:0 | ||
1975 | 232 | msgid "You try to assign a lot which is not from the same product" | ||
1976 | 233 | msgstr "Vous essayez d'affecter un lot qui n'est pas pour ce produit." | ||
1977 | 234 | |||
1978 | 235 | |||
1979 | 236 | #. module: stock_inventory_location | ||
1980 | 237 | #: code:addons/stock_inventory_location/wizard/stock_fill_location_inventory.py:54 | ||
1981 | 238 | #, python-format | ||
1982 | 239 | msgid "the inventory must be in \"Open\" state." | ||
1983 | 240 | msgstr "l'inventaire doit etre \"Ouvert\"." | ||
1984 | 241 | |||
1985 | 0 | 242 | ||
1986 | === added directory 'stock_inventory_location/images' | |||
1987 | === added file 'stock_inventory_location/images/future_inventory.png' | |||
1988 | 1 | Binary files stock_inventory_location/images/future_inventory.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/future_inventory.png 2014-06-27 09:18:58 +0000 differ | 243 | Binary files stock_inventory_location/images/future_inventory.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/future_inventory.png 2014-06-27 09:18:58 +0000 differ |
1989 | === added file 'stock_inventory_location/images/inventory_empty_locations.png' | |||
1990 | 2 | Binary files stock_inventory_location/images/inventory_empty_locations.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_empty_locations.png 2014-06-27 09:18:58 +0000 differ | 244 | Binary files stock_inventory_location/images/inventory_empty_locations.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_empty_locations.png 2014-06-27 09:18:58 +0000 differ |
1991 | === added file 'stock_inventory_location/images/inventory_form.png' | |||
1992 | 3 | Binary files stock_inventory_location/images/inventory_form.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_form.png 2014-06-27 09:18:58 +0000 differ | 245 | Binary files stock_inventory_location/images/inventory_form.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_form.png 2014-06-27 09:18:58 +0000 differ |
1993 | === added file 'stock_inventory_location/images/location_locked.png' | |||
1994 | 4 | Binary files stock_inventory_location/images/location_locked.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/location_locked.png 2014-06-27 09:18:58 +0000 differ | 246 | Binary files stock_inventory_location/images/location_locked.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/location_locked.png 2014-06-27 09:18:58 +0000 differ |
1995 | === added file 'stock_inventory_location/images/move_error.png' | |||
1996 | 5 | Binary files stock_inventory_location/images/move_error.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/move_error.png 2014-06-27 09:18:58 +0000 differ | 247 | Binary files stock_inventory_location/images/move_error.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/move_error.png 2014-06-27 09:18:58 +0000 differ |
1997 | === added directory 'stock_inventory_location/static' | |||
1998 | === added directory 'stock_inventory_location/static/src' | |||
1999 | === added directory 'stock_inventory_location/static/src/img' | |||
2000 | === added file 'stock_inventory_location/static/src/img/icon.png' | |||
2001 | 6 | Binary files stock_inventory_location/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/static/src/img/icon.png 2014-06-27 09:18:58 +0000 differ | 248 | Binary files stock_inventory_location/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/static/src/img/icon.png 2014-06-27 09:18:58 +0000 differ |
2002 | === added file 'stock_inventory_location/stock_inventory_location.py' | |||
2003 | --- stock_inventory_location/stock_inventory_location.py 1970-01-01 00:00:00 +0000 | |||
2004 | +++ stock_inventory_location/stock_inventory_location.py 2014-06-27 09:18:58 +0000 | |||
2005 | @@ -0,0 +1,353 @@ | |||
2006 | 1 | # -*- coding: utf-8 -*- | ||
2007 | 2 | ############################################################################## | ||
2008 | 3 | # | ||
2009 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
2010 | 5 | # | ||
2011 | 6 | # This program is free software: you can redistribute it and/or modify | ||
2012 | 7 | # it under the terms of the GNU General Public License as published by | ||
2013 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
2014 | 9 | # (at your option) any later version. | ||
2015 | 10 | # | ||
2016 | 11 | # This program is distributed in the hope that it will be useful, | ||
2017 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2018 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2019 | 14 | # GNU General Public License for more details. | ||
2020 | 15 | # | ||
2021 | 16 | # You should have received a copy of the GNU General Public License | ||
2022 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2023 | 18 | # | ||
2024 | 19 | ############################################################################## | ||
2025 | 20 | |||
2026 | 21 | import time | ||
2027 | 22 | from collections import Iterable | ||
2028 | 23 | |||
2029 | 24 | from openerp.osv import orm, fields | ||
2030 | 25 | from openerp.tools.translate import _ | ||
2031 | 26 | # The next 2 imports are only needed for a feature backported from trunk-wms | ||
2032 | 27 | # TODOv8! remove, feature is included upstream | ||
2033 | 28 | from openerp.osv import osv | ||
2034 | 29 | from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT | ||
2035 | 30 | from openerp import SUPERUSER_ID | ||
2036 | 31 | |||
2037 | 32 | from .exceptions import ExhaustiveInventoryException | ||
2038 | 33 | |||
2039 | 34 | |||
2040 | 35 | class StockInventory(orm.Model): | ||
2041 | 36 | """Add locations to the inventories""" | ||
2042 | 37 | _inherit = 'stock.inventory' | ||
2043 | 38 | |||
2044 | 39 | INVENTORY_STATE_SELECTION = [ | ||
2045 | 40 | ('draft', 'Draft'), | ||
2046 | 41 | ('open', 'Open'), | ||
2047 | 42 | ('done', 'Done'), | ||
2048 | 43 | ('confirm', 'Confirmed'), | ||
2049 | 44 | ('cancel', 'Cancelled') | ||
2050 | 45 | ] | ||
2051 | 46 | |||
2052 | 47 | _columns = { | ||
2053 | 48 | # TODO v8: should we use "confirm" instead of adding "open"? | ||
2054 | 49 | 'state': fields.selection( | ||
2055 | 50 | INVENTORY_STATE_SELECTION, 'State', readonly=True, select=True), | ||
2056 | 51 | # TODO v8: remove this, should not be needed anymore | ||
2057 | 52 | # Make the inventory lines read-only in all states except "Open", | ||
2058 | 53 | # to ensure that no unwanted Location can be inserted | ||
2059 | 54 | 'inventory_line_id': fields.one2many( | ||
2060 | 55 | 'stock.inventory.line', 'inventory_id', 'Inventory lines', | ||
2061 | 56 | readonly=True, states={'open': [('readonly', False)]}), | ||
2062 | 57 | # TODO v8: remove this, it's backported from v8 | ||
2063 | 58 | 'location_id': fields.many2one( | ||
2064 | 59 | 'stock.location', 'Inventoried Location', | ||
2065 | 60 | readonly=True, states={'draft': [('readonly', False)]}), | ||
2066 | 61 | 'exhaustive': fields.boolean( | ||
2067 | 62 | 'Exhaustive', readonly=True, | ||
2068 | 63 | states={'draft': [('readonly', False)]}, | ||
2069 | 64 | help="Check the box if you are conducting an exhaustive " | ||
2070 | 65 | "Inventory.\n" | ||
2071 | 66 | "Leave the box unchecked if you are conducting a standard " | ||
2072 | 67 | "Inventory (partial inventory for example).\n" | ||
2073 | 68 | "For an exhaustive Inventory:\n" | ||
2074 | 69 | " - the status \"Draft\" lets you define the list of " | ||
2075 | 70 | "Locations where goods must be counted\n" | ||
2076 | 71 | " - the status \"Open\" indicates that the list of Locations " | ||
2077 | 72 | "is definitive and you are now counting the goods. In that " | ||
2078 | 73 | "status, no Stock Moves can be recorded in/out of the " | ||
2079 | 74 | "Inventory's Locations\n" | ||
2080 | 75 | " - only the Inventory's Locations can be entered in the " | ||
2081 | 76 | "Inventory Lines\n" | ||
2082 | 77 | " - if some of the Inventory's Locations have not been " | ||
2083 | 78 | "entered in the Inventory Lines, OpenERP warns you " | ||
2084 | 79 | "when you confirm the Inventory\n" | ||
2085 | 80 | " - every good that is not in the Inventory Lines is " | ||
2086 | 81 | "considered lost, and gets moved out of the stock when you " | ||
2087 | 82 | "confirm the Inventory"), | ||
2088 | 83 | } | ||
2089 | 84 | |||
2090 | 85 | def action_open(self, cr, uid, ids, context=None): | ||
2091 | 86 | """Change the state of the inventory to 'open'""" | ||
2092 | 87 | return self.write(cr, uid, ids, {'state': 'open'}, context=context) | ||
2093 | 88 | |||
2094 | 89 | # TODO v8: remove this method? the feature looks already done upstream | ||
2095 | 90 | def action_done(self, cr, uid, ids, context=None): | ||
2096 | 91 | """ | ||
2097 | 92 | Don't allow to make an inventory with a date in the future. | ||
2098 | 93 | |||
2099 | 94 | This makes sure no stock moves will be introduced between the | ||
2100 | 95 | moment you finish the inventory and the date of the Stock Moves. | ||
2101 | 96 | Backported from trunk-wms: | ||
2102 | 97 | revid:qdp-launchpad@openerp.com-20140317090656-o7lo22tzm8yuv3r8 | ||
2103 | 98 | |||
2104 | 99 | @raise osv.except_osv: | ||
2105 | 100 | We raise this exception on purpose instead of | ||
2106 | 101 | ExhaustiveInventoryException to ensure forward-compatibility | ||
2107 | 102 | with v8. | ||
2108 | 103 | """ | ||
2109 | 104 | for inventory in self.browse(cr, uid, ids, context=None): | ||
2110 | 105 | if inventory.date > time.strftime(DEFAULT_SERVER_DATETIME_FORMAT): | ||
2111 | 106 | raise osv.except_osv( | ||
2112 | 107 | _('Error!'), | ||
2113 | 108 | _('It\'s impossible to confirm an inventory in the ' | ||
2114 | 109 | 'future. Please change the inventory date to proceed ' | ||
2115 | 110 | 'further.')) | ||
2116 | 111 | return super(StockInventory, self).action_done(cr, uid, ids, | ||
2117 | 112 | context=context) | ||
2118 | 113 | |||
2119 | 114 | # TODO: remove this in v8 | ||
2120 | 115 | def _default_location(self, cr, uid, ids, context=None): | ||
2121 | 116 | """Default stock location | ||
2122 | 117 | |||
2123 | 118 | @return: id of the stock location of the first warehouse of the | ||
2124 | 119 | default company""" | ||
2125 | 120 | location_id = False | ||
2126 | 121 | company_id = self.pool['res.company']._company_default_get( | ||
2127 | 122 | cr, uid, 'stock.warehouse', context=context) | ||
2128 | 123 | warehouse_id = self.pool['stock.warehouse'].search( | ||
2129 | 124 | cr, uid, [('company_id', '=', company_id)], limit=1) | ||
2130 | 125 | if warehouse_id: | ||
2131 | 126 | location_id = self.pool['stock.warehouse'].read( | ||
2132 | 127 | cr, uid, warehouse_id[0], ['lot_stock_id'])['lot_stock_id'][0] | ||
2133 | 128 | return location_id | ||
2134 | 129 | |||
2135 | 130 | _defaults = { | ||
2136 | 131 | 'state': 'draft', | ||
2137 | 132 | 'exhaustive': False, | ||
2138 | 133 | # TODO: remove this in v8 | ||
2139 | 134 | 'location_id': _default_location, | ||
2140 | 135 | } | ||
2141 | 136 | |||
2142 | 137 | def _check_location_free_from_inventories(self, cr, uid, ids): | ||
2143 | 138 | """ | ||
2144 | 139 | Verify that no other Inventory is being conducted on the same locations | ||
2145 | 140 | |||
2146 | 141 | Open Inventories are matched using the exact Location IDs, | ||
2147 | 142 | excluding children. | ||
2148 | 143 | """ | ||
2149 | 144 | # We don't get a context because we're called from a _constraint | ||
2150 | 145 | for inventory in self.browse(cr, uid, ids): | ||
2151 | 146 | if not inventory.exhaustive: | ||
2152 | 147 | # never block standard inventories | ||
2153 | 148 | continue | ||
2154 | 149 | if self.search(cr, uid, | ||
2155 | 150 | [('location_id', '=', inventory.location_id.id), | ||
2156 | 151 | ('id', '!=', inventory.id), | ||
2157 | 152 | ('date', '=', inventory.date), | ||
2158 | 153 | ('exhaustive', '=', True)]): | ||
2159 | 154 | # Quit as soon as one offending inventory is found | ||
2160 | 155 | return False | ||
2161 | 156 | return True | ||
2162 | 157 | |||
2163 | 158 | _constraints = [ | ||
2164 | 159 | (_check_location_free_from_inventories, | ||
2165 | 160 | 'Other Physical inventories are being conducted using the same ' | ||
2166 | 161 | 'Locations.', | ||
2167 | 162 | ['location_id', 'date', 'exhaustive']) | ||
2168 | 163 | ] | ||
2169 | 164 | |||
2170 | 165 | def _get_locations_open_inventories(self, cr, uid, context=None): | ||
2171 | 166 | """IDs of location in open exhaustive inventories, with children""" | ||
2172 | 167 | inv_ids = self.search( | ||
2173 | 168 | cr, uid, [('state', '=', 'open'), ('exhaustive', '=', True)], | ||
2174 | 169 | context=context) | ||
2175 | 170 | if not inv_ids: | ||
2176 | 171 | # Early exit if no match found | ||
2177 | 172 | return [] | ||
2178 | 173 | # List the Locations - normally all exhaustive inventories have one | ||
2179 | 174 | location_ids = [inventory.location_id.id | ||
2180 | 175 | for inventory in self.browse(cr, uid, inv_ids, | ||
2181 | 176 | context=context)] | ||
2182 | 177 | # Extend to the children Locations | ||
2183 | 178 | return self.pool['stock.location'].search( | ||
2184 | 179 | cr, uid, | ||
2185 | 180 | [('location_id', 'child_of', set(location_ids)), | ||
2186 | 181 | ('usage', '=', 'internal')], | ||
2187 | 182 | context=context) | ||
2188 | 183 | |||
2189 | 184 | def get_missing_locations(self, cr, uid, ids, context=None): | ||
2190 | 185 | """Compute the list of location_ids which are missing from the lines | ||
2191 | 186 | |||
2192 | 187 | Here, "missing" means the location is the inventory's location or one | ||
2193 | 188 | of it's children, and the inventory does not contain any line with | ||
2194 | 189 | this location.""" | ||
2195 | 190 | inventories = self.browse(cr, uid, ids, context=context) | ||
2196 | 191 | # Find the locations of the inventories | ||
2197 | 192 | inv_location_ids = [i.location_id.id for i in inventories] | ||
2198 | 193 | # Extend to the children locations | ||
2199 | 194 | inv_location_ids = set(self.pool['stock.location'].search( | ||
2200 | 195 | cr, uid, [ | ||
2201 | 196 | ('location_id', 'child_of', inv_location_ids), | ||
2202 | 197 | ('usage', '=', 'internal')], context=context)) | ||
2203 | 198 | # Find the locations already recorded in inventory lines | ||
2204 | 199 | line_locations_ids = set([l.location_id.id | ||
2205 | 200 | for i in inventories | ||
2206 | 201 | for l in i.inventory_line_id]) | ||
2207 | 202 | return list(inv_location_ids - line_locations_ids) | ||
2208 | 203 | |||
2209 | 204 | def confirm_missing_locations(self, cr, uid, ids, context=None): | ||
2210 | 205 | """Open wizard to confirm empty locations on exhaustive inventories""" | ||
2211 | 206 | for inventory in self.browse(cr, uid, ids, context=context): | ||
2212 | 207 | if (self.get_missing_locations(cr, uid, ids, context=context) | ||
2213 | 208 | and inventory.exhaustive): | ||
2214 | 209 | return { | ||
2215 | 210 | 'type': 'ir.actions.act_window', | ||
2216 | 211 | 'view_type': 'form', | ||
2217 | 212 | 'view_mode': 'form', | ||
2218 | 213 | 'res_model': 'stock.inventory.uninventoried.locations', | ||
2219 | 214 | 'target': 'new', | ||
2220 | 215 | 'context': dict(context, | ||
2221 | 216 | active_ids=ids, | ||
2222 | 217 | active_id=ids[0]), | ||
2223 | 218 | 'nodestroy': True, | ||
2224 | 219 | } | ||
2225 | 220 | return self.action_confirm(cr, uid, ids, context=context) | ||
2226 | 221 | |||
2227 | 222 | |||
2228 | 223 | class StockInventoryLine(orm.Model): | ||
2229 | 224 | """Only allow the Inventory's Locations""" | ||
2230 | 225 | |||
2231 | 226 | _inherit = 'stock.inventory.line' | ||
2232 | 227 | |||
2233 | 228 | def _default_stock_location(self, cr, uid, context=None): | ||
2234 | 229 | res = super(StockInventoryLine, self)._default_stock_location( | ||
2235 | 230 | cr, uid, context=context) | ||
2236 | 231 | if context is None or not context.get('location_id', False): | ||
2237 | 232 | return res | ||
2238 | 233 | else: | ||
2239 | 234 | return context['location_id'] | ||
2240 | 235 | |||
2241 | 236 | _defaults = { | ||
2242 | 237 | 'location_id': _default_stock_location | ||
2243 | 238 | } | ||
2244 | 239 | |||
2245 | 240 | def onchange_location_id(self, cr, uid, ids, inventory_location_id, | ||
2246 | 241 | exhaustive, location_id, context=None): | ||
2247 | 242 | """Warn if the new is not in the location list for this inventory.""" | ||
2248 | 243 | if not exhaustive: | ||
2249 | 244 | # Don't check if partial inventory | ||
2250 | 245 | return True | ||
2251 | 246 | |||
2252 | 247 | # search children of location | ||
2253 | 248 | if location_id not in self.pool['stock.location'].search( | ||
2254 | 249 | cr, uid, [('location_id', 'child_of', inventory_location_id)], | ||
2255 | 250 | context=context): | ||
2256 | 251 | return { | ||
2257 | 252 | 'value': {'location_id': False}, | ||
2258 | 253 | 'warning': { | ||
2259 | 254 | 'title': _('Warning: Wrong location'), | ||
2260 | 255 | 'message': _( | ||
2261 | 256 | "You cannot record an Inventory Line for this " | ||
2262 | 257 | "Location.\n" | ||
2263 | 258 | "You must first add this Location to the list of " | ||
2264 | 259 | "affected Locations on the Inventory form.")} | ||
2265 | 260 | } | ||
2266 | 261 | return True | ||
2267 | 262 | |||
2268 | 263 | |||
2269 | 264 | class StockLocation(orm.Model): | ||
2270 | 265 | """Refuse changes during exhaustive Inventories""" | ||
2271 | 266 | _inherit = 'stock.location' | ||
2272 | 267 | _order = 'name' | ||
2273 | 268 | |||
2274 | 269 | def _check_inventory(self, cr, uid, ids, context=None): | ||
2275 | 270 | """Error if an exhaustive Inventory is being conducted here""" | ||
2276 | 271 | inv_obj = self.pool['stock.inventory'] | ||
2277 | 272 | location_inventory_open_ids = inv_obj._get_locations_open_inventories( | ||
2278 | 273 | cr, SUPERUSER_ID, context=context) | ||
2279 | 274 | if not isinstance(ids, Iterable): | ||
2280 | 275 | ids = [ids] | ||
2281 | 276 | for inv_id in ids: | ||
2282 | 277 | if inv_id in location_inventory_open_ids: | ||
2283 | 278 | raise ExhaustiveInventoryException( | ||
2284 | 279 | _('Error: Location locked down'), | ||
2285 | 280 | _('A Physical Inventory is being conducted at this ' | ||
2286 | 281 | 'location')) | ||
2287 | 282 | return True | ||
2288 | 283 | |||
2289 | 284 | def write(self, cr, uid, ids, vals, context=None): | ||
2290 | 285 | """Refuse write if an inventory is being conducted""" | ||
2291 | 286 | self._check_inventory(cr, uid, ids, context=context) | ||
2292 | 287 | if not isinstance(ids, Iterable): | ||
2293 | 288 | ids_to_check = [ids] | ||
2294 | 289 | else: | ||
2295 | 290 | # Copy the data to avoid changing 'ids', it would trigger an infinite recursion | ||
2296 | 291 | ids_to_check = list(ids) | ||
2297 | 292 | # If changing the parent, no inventory must conducted there either | ||
2298 | 293 | if vals.get('location_id'): | ||
2299 | 294 | ids_to_check.append(vals['location_id']) | ||
2300 | 295 | self._check_inventory(cr, uid, ids_to_check, context=context) | ||
2301 | 296 | return super(StockLocation, self).write(cr, uid, ids, vals, | ||
2302 | 297 | context=context) | ||
2303 | 298 | |||
2304 | 299 | def create(self, cr, uid, vals, context=None): | ||
2305 | 300 | """Refuse create if an inventory is being conducted at the parent""" | ||
2306 | 301 | self._check_inventory(cr, uid, vals.get('location_id'), | ||
2307 | 302 | context=context) | ||
2308 | 303 | return super(StockLocation, self).create(cr, uid, vals, | ||
2309 | 304 | context=context) | ||
2310 | 305 | |||
2311 | 306 | def unlink(self, cr, uid, ids, context=None): | ||
2312 | 307 | """Refuse unlink if an inventory is being conducted""" | ||
2313 | 308 | self._check_inventory(cr, uid, ids, context=context) | ||
2314 | 309 | return super(StockLocation, self).unlink(cr, uid, ids, context=context) | ||
2315 | 310 | |||
2316 | 311 | |||
2317 | 312 | class StockMove(orm.Model): | ||
2318 | 313 | """Refuse Moves during exhaustive Inventories""" | ||
2319 | 314 | |||
2320 | 315 | _inherit = 'stock.move' | ||
2321 | 316 | |||
2322 | 317 | # TODOv7: adapt this to match trunk-wms | ||
2323 | 318 | def _check_open_inventory_location(self, cr, uid, ids, context=None): | ||
2324 | 319 | """ | ||
2325 | 320 | Check that the locations are not locked by an open inventory | ||
2326 | 321 | |||
2327 | 322 | Standard inventories are not checked. | ||
2328 | 323 | |||
2329 | 324 | @raise ExhaustiveInventoryException: an error is raised if locations | ||
2330 | 325 | are locked, instead of returning False, in order to pass an | ||
2331 | 326 | extensive error message back to users. | ||
2332 | 327 | """ | ||
2333 | 328 | message = "" | ||
2334 | 329 | inv_obj = self.pool['stock.inventory'] | ||
2335 | 330 | locked_location_ids = inv_obj._get_locations_open_inventories( | ||
2336 | 331 | cr, SUPERUSER_ID, context=context) | ||
2337 | 332 | if not locked_location_ids: | ||
2338 | 333 | # Nothing to verify | ||
2339 | 334 | return True | ||
2340 | 335 | for move in self.browse(cr, uid, ids, context=context): | ||
2341 | 336 | if (move.location_id.usage != 'inventory' | ||
2342 | 337 | and move.location_dest_id.id in locked_location_ids): | ||
2343 | 338 | message += " - %s\n" % (move.location_dest_id.name) | ||
2344 | 339 | if (move.location_dest_id.usage != 'inventory' | ||
2345 | 340 | and move.location_id.id in locked_location_ids): | ||
2346 | 341 | message += " - %s\n" % (move.location_id.name) | ||
2347 | 342 | if message: | ||
2348 | 343 | raise ExhaustiveInventoryException( | ||
2349 | 344 | _('Error: Location locked down'), | ||
2350 | 345 | _('A Physical Inventory is being conducted at the following ' | ||
2351 | 346 | 'location(s):\n%s') % message) | ||
2352 | 347 | return True | ||
2353 | 348 | |||
2354 | 349 | _constraints = [ | ||
2355 | 350 | (_check_open_inventory_location, | ||
2356 | 351 | "A Physical Inventory is being conducted at this location", | ||
2357 | 352 | ['location_id', 'location_dest_id']), | ||
2358 | 353 | ] | ||
2359 | 0 | 354 | ||
2360 | === added file 'stock_inventory_location/stock_inventory_location_demo.xml' | |||
2361 | --- stock_inventory_location/stock_inventory_location_demo.xml 1970-01-01 00:00:00 +0000 | |||
2362 | +++ stock_inventory_location/stock_inventory_location_demo.xml 2014-06-27 09:18:58 +0000 | |||
2363 | @@ -0,0 +1,26 @@ | |||
2364 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2365 | 2 | <openerp> | ||
2366 | 3 | <data noupdate="0"> | ||
2367 | 4 | <!-- Record a non exhaustive inventory --> | ||
2368 | 5 | <record id="inventory_standard" model="stock.inventory"> | ||
2369 | 6 | <field name="name">Standard inventory</field> | ||
2370 | 7 | <field name="state">draft</field> | ||
2371 | 8 | </record> | ||
2372 | 9 | |||
2373 | 10 | <!-- Record an exhaustive inventory --> | ||
2374 | 11 | <record id="inventory_exhaustive" model="stock.inventory"> | ||
2375 | 12 | <field name="name">Exhaustive inventory</field> | ||
2376 | 13 | <field name="state">draft</field> | ||
2377 | 14 | <field name="exhaustive">True</field> | ||
2378 | 15 | <field name="location_id" model="stock.location" search="[('name', '=', 'Shelf 2')]" /> | ||
2379 | 16 | </record> | ||
2380 | 17 | |||
2381 | 18 | <!-- Record an inventory dated in the future --> | ||
2382 | 19 | <!-- TODOv8: remove this entry, only useful for a test already in trunk-wms --> | ||
2383 | 20 | <record id="inventory_future" model="stock.inventory"> | ||
2384 | 21 | <field name="name">Inventory in the future</field> | ||
2385 | 22 | <field name="state">draft</field> | ||
2386 | 23 | <field name="date">2020-03-01 00:00:00</field> | ||
2387 | 24 | </record> | ||
2388 | 25 | </data> | ||
2389 | 26 | </openerp> | ||
2390 | 0 | 27 | ||
2391 | === added file 'stock_inventory_location/stock_inventory_location_view.xml' | |||
2392 | --- stock_inventory_location/stock_inventory_location_view.xml 1970-01-01 00:00:00 +0000 | |||
2393 | +++ stock_inventory_location/stock_inventory_location_view.xml 2014-06-27 09:18:58 +0000 | |||
2394 | @@ -0,0 +1,81 @@ | |||
2395 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2396 | 2 | <openerp> | ||
2397 | 3 | <data> | ||
2398 | 4 | |||
2399 | 5 | <record model="ir.ui.view" id="stock_inventory_location_form_view"> | ||
2400 | 6 | <field name="name">stock.inventory.location.form</field> | ||
2401 | 7 | <field name="model">stock.inventory</field> | ||
2402 | 8 | <field name="inherit_id" ref="stock.view_inventory_form"/> | ||
2403 | 9 | <field name="priority" eval="10"/> | ||
2404 | 10 | <field name="arch" type="xml"> | ||
2405 | 11 | <!-- Show the state 'done' in the statusbar --> | ||
2406 | 12 | <xpath expr="/form//field[@name='state']" position="attributes"> | ||
2407 | 13 | <attribute name="statusbar_visible">draft,open,confirm</attribute> | ||
2408 | 14 | </xpath> | ||
2409 | 15 | |||
2410 | 16 | <!-- TODO v8 place "exhaustive" next to "location_id" --> | ||
2411 | 17 | <!-- Add type of inventory: standard or exhaustive. --> | ||
2412 | 18 | <xpath expr="/form//field[@name='name']" position="after"> | ||
2413 | 19 | <field name="exhaustive"/> | ||
2414 | 20 | <field name="location_id" groups="stock.group_locations" | ||
2415 | 21 | domain="[('usage','in',('view', 'internal'))]" | ||
2416 | 22 | attrs="{'invisible':[('exhaustive','!=',True)], 'required':[('exhaustive','=',True)]}"/> | ||
2417 | 23 | </xpath> | ||
2418 | 24 | |||
2419 | 25 | <!-- Enable Fill Inventory button when state is open --> | ||
2420 | 26 | <xpath expr="//button[@string='Fill Inventory']" position="attributes"> | ||
2421 | 27 | <attribute name="states">open</attribute> | ||
2422 | 28 | <attribute name="context">{'default_exhaustive': exhaustive}</attribute> | ||
2423 | 29 | </xpath> | ||
2424 | 30 | |||
2425 | 31 | <!-- Control locations added by user on inventory line --> | ||
2426 | 32 | <xpath expr="/form//field[@name='inventory_line_id']" | ||
2427 | 33 | position="attributes"> | ||
2428 | 34 | <attribute name="context">{'location_id': location_id}</attribute> | ||
2429 | 35 | </xpath> | ||
2430 | 36 | <xpath expr="/form//field[@name='inventory_line_id']/tree//field[@name='location_id']" | ||
2431 | 37 | position="attributes"> | ||
2432 | 38 | <attribute name="on_change">onchange_location_id(parent.location_id, parent.exhaustive, location_id)</attribute> | ||
2433 | 39 | </xpath> | ||
2434 | 40 | <xpath expr="/form//field[@name='inventory_line_id']/form//field[@name='location_id']" | ||
2435 | 41 | position="attributes"> | ||
2436 | 42 | <attribute name="on_change">onchange_location_id(parent.location_id, parent.exhaustive, location_id)</attribute> | ||
2437 | 43 | </xpath> | ||
2438 | 44 | |||
2439 | 45 | <!-- Add button to open an inventory. Call wizard on confirm inventory --> | ||
2440 | 46 | <xpath expr="/form//button[@name='action_cancel_inventory']" position="before"> | ||
2441 | 47 | <button name="action_open" states="draft" string="Open Inventory" type="object" class="oe_highlight" groups="stock.group_stock_user"/> | ||
2442 | 48 | </xpath> | ||
2443 | 49 | <!-- Show the "cancel" button in state "open" --> | ||
2444 | 50 | <xpath expr="/form//button[@name='action_cancel_inventory']" position="attributes"> | ||
2445 | 51 | <attribute name="states">draft,open,confirm,done</attribute> | ||
2446 | 52 | </xpath> | ||
2447 | 53 | <!-- hijack the "confirm" button --> | ||
2448 | 54 | <xpath expr="/form//button[@name='action_confirm']" position="attributes"> | ||
2449 | 55 | <attribute name="states">open</attribute> | ||
2450 | 56 | <attribute name="name">confirm_missing_locations</attribute> | ||
2451 | 57 | </xpath> | ||
2452 | 58 | </field> | ||
2453 | 59 | </record> | ||
2454 | 60 | |||
2455 | 61 | <!-- Add filter for complete or partial inventory --> | ||
2456 | 62 | <record model="ir.ui.view" id="view_inventory_complete_filter"> | ||
2457 | 63 | <field name="name">complete.inventory.filter</field> | ||
2458 | 64 | <field name="model">stock.inventory</field> | ||
2459 | 65 | <field name="inherit_id" ref="stock.view_inventory_filter"/> | ||
2460 | 66 | <field name="arch" type="xml"> | ||
2461 | 67 | <xpath expr="//field[@name='name']" position="before"> | ||
2462 | 68 | <filter icon="terp-check" name="exhaustive" string="Exhaustive" domain="[('exhaustive', '=', True)]" | ||
2463 | 69 | help="Only select exhaustive Inventories." /> | ||
2464 | 70 | <separator orientation="vertical"/> | ||
2465 | 71 | </xpath> | ||
2466 | 72 | </field> | ||
2467 | 73 | </record> | ||
2468 | 74 | |||
2469 | 75 | <!-- Show exhaustive inventories by default --> | ||
2470 | 76 | <record id="stock.action_inventory_form" model="ir.actions.act_window"> | ||
2471 | 77 | <field name="context">{'full':'1', 'search_default_exhaustive':1}</field> | ||
2472 | 78 | </record> | ||
2473 | 79 | |||
2474 | 80 | </data> | ||
2475 | 81 | </openerp> | ||
2476 | 0 | \ No newline at end of file | 82 | \ No newline at end of file |
2477 | 1 | 83 | ||
2478 | === added directory 'stock_inventory_location/tests' | |||
2479 | === added file 'stock_inventory_location/tests/__init__.py' | |||
2480 | --- stock_inventory_location/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
2481 | +++ stock_inventory_location/tests/__init__.py 2014-06-27 09:18:58 +0000 | |||
2482 | @@ -0,0 +1,39 @@ | |||
2483 | 1 | # -*- coding: utf-8 -*- | ||
2484 | 2 | # | ||
2485 | 3 | # | ||
2486 | 4 | # Authors: Laetitia Gangloff | ||
2487 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
2488 | 6 | # All Rights Reserved | ||
2489 | 7 | # | ||
2490 | 8 | # WARNING: This program as such is intended to be used by professional | ||
2491 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
2492 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
2493 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
2494 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
2495 | 13 | # Service Company. | ||
2496 | 14 | # | ||
2497 | 15 | # This program is free software: you can redistribute it and/or modify | ||
2498 | 16 | # it under the terms of the GNU Affero General Public License as | ||
2499 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
2500 | 18 | # License, or (at your option) any later version. | ||
2501 | 19 | # | ||
2502 | 20 | # This program is distributed in the hope that it will be useful, | ||
2503 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2504 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2505 | 23 | # GNU Affero General Public License for more details. | ||
2506 | 24 | # | ||
2507 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
2508 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2509 | 27 | # | ||
2510 | 28 | # | ||
2511 | 29 | |||
2512 | 30 | import stock_inventory_location_test | ||
2513 | 31 | |||
2514 | 32 | fast_suite = [ | ||
2515 | 33 | ] | ||
2516 | 34 | |||
2517 | 35 | checks = [ | ||
2518 | 36 | stock_inventory_location_test, | ||
2519 | 37 | ] | ||
2520 | 38 | |||
2521 | 39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2522 | 0 | 40 | ||
2523 | === added file 'stock_inventory_location/tests/inventory_exhaustive_test.yml' | |||
2524 | --- stock_inventory_location/tests/inventory_exhaustive_test.yml 1970-01-01 00:00:00 +0000 | |||
2525 | +++ stock_inventory_location/tests/inventory_exhaustive_test.yml 2014-06-27 09:18:58 +0000 | |||
2526 | @@ -0,0 +1,128 @@ | |||
2527 | 1 | - | ||
2528 | 2 | This file will test an exhaustive inventory. | ||
2529 | 3 | I will call open_action method and check if state of inventories are 'open'. | ||
2530 | 4 | - | ||
2531 | 5 | !python {model: stock.inventory}: | | ||
2532 | 6 | self.action_open(cr, uid, [ref('inventory_exhaustive')]) | ||
2533 | 7 | inventory_state = self.read(cr, uid, [ref('inventory_exhaustive')], ['state'])[0]['state'] | ||
2534 | 8 | assert inventory_state == 'open', "Inventory in state '%s'. It should be 'open'" % inventory_state | ||
2535 | 9 | - | ||
2536 | 10 | I will check that the function get_missing_locations return some locations. | ||
2537 | 11 | - | ||
2538 | 12 | !python {model: stock.inventory}: | | ||
2539 | 13 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('inventory_exhaustive')], context=context) | ||
2540 | 14 | assert len(missing_loc_ids), "get_missing_locations did not return any ID." | ||
2541 | 15 | - | ||
2542 | 16 | I create a wizard record for stock_confirm_uninventoried_location to verify that it contains the uninventoried locations | ||
2543 | 17 | - | ||
2544 | 18 | !python {model: stock.inventory.uninventoried.locations}: | | ||
2545 | 19 | ctx = dict(context, active_ids=[ref('inventory_exhaustive')]) | ||
2546 | 20 | wizard_id = self.create(cr, uid, {}, context=ctx) | ||
2547 | 21 | wizard = self.browse(cr, uid, wizard_id, context=ctx) | ||
2548 | 22 | assert len(wizard.location_ids) > 0 , "The wizard does not contain any lines." | ||
2549 | 23 | - | ||
2550 | 24 | I add products to exhaustive inventory. | ||
2551 | 25 | Adding 17” LCD Monitor. | ||
2552 | 26 | - | ||
2553 | 27 | !record {model: stock.inventory.line, id: lines_inventory_location_pc1}: | ||
2554 | 28 | product_id: product.product_product_7 | ||
2555 | 29 | product_uom: product.product_uom_unit | ||
2556 | 30 | company_id: base.main_company | ||
2557 | 31 | inventory_id: inventory_exhaustive | ||
2558 | 32 | product_qty: 18.0 | ||
2559 | 33 | location_id: stock.stock_location_14 | ||
2560 | 34 | |||
2561 | 35 | - | ||
2562 | 36 | Adding USB Keyboard, QWERTY. | ||
2563 | 37 | - | ||
2564 | 38 | !record {model: stock.inventory.line, id: lines_inventory_location_pc3}: | ||
2565 | 39 | product_id: product.product_product_8 | ||
2566 | 40 | product_uom: product.product_uom_unit | ||
2567 | 41 | company_id: base.main_company | ||
2568 | 42 | inventory_id: inventory_exhaustive | ||
2569 | 43 | product_qty: 5.0 | ||
2570 | 44 | location_id: stock.stock_location_14 | ||
2571 | 45 | |||
2572 | 46 | - | ||
2573 | 47 | I will call the function _get_locations_open_inventories and check the result. | ||
2574 | 48 | The function will return only the location_id of the exhaustive inventory. | ||
2575 | 49 | - | ||
2576 | 50 | !python {model: stock.inventory}: | | ||
2577 | 51 | locations = self._get_locations_open_inventories(cr, uid) | ||
2578 | 52 | assert len(locations) == 1, "Function return wrong results: %s" % locations | ||
2579 | 53 | assert locations[0] == ref('stock.stock_location_14'), "Function '_get_locations_open_inventories' return wrong location_id. Should be '%s': '%s'" % (stock.stock_location_14, locations[0]) | ||
2580 | 54 | - | ||
2581 | 55 | I will call the function onchange_location_id. | ||
2582 | 56 | The function must return True in the first case, and return a warning dictionnary in the second test. | ||
2583 | 57 | - | ||
2584 | 58 | !python {model: stock.inventory.line}: | | ||
2585 | 59 | res = self.onchange_location_id(cr, uid, [], ref('stock.stock_location_14'), True, ref('stock.stock_location_14')) | ||
2586 | 60 | assert res == True, "Exhaustive: The function 'onchange_location_id' should return True and return '%s'" % res | ||
2587 | 61 | res = self.onchange_location_id(cr, uid, [], ref('stock.stock_location_14'), True, ref('stock.stock_location_components')) | ||
2588 | 62 | assert res.get('warning', False) != False , "Function 'onchange_location_id': Warning not raise. ('%s)" % res | ||
2589 | 63 | |||
2590 | 64 | - | ||
2591 | 65 | I will check that the function get_missing_locations does not return any locations. | ||
2592 | 66 | - | ||
2593 | 67 | !python {model: stock.inventory}: | | ||
2594 | 68 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('inventory_exhaustive')], context=context) | ||
2595 | 69 | assert not missing_loc_ids, "get_missing_locations should not return IDs but returned %s" % missing_loc_ids | ||
2596 | 70 | - | ||
2597 | 71 | I create a wizard record for stock_confirm_uninventoried_location and validate it | ||
2598 | 72 | - | ||
2599 | 73 | !python {model: stock.inventory.uninventoried.locations}: | | ||
2600 | 74 | ctx = dict(context, active_ids=[ref('inventory_exhaustive')]) | ||
2601 | 75 | wizard_id = self.create(cr, uid, {}, context=ctx) | ||
2602 | 76 | wizard = self.browse(cr, uid, wizard_id, context=ctx) | ||
2603 | 77 | assert len(wizard.location_ids) == 0 , "The wizard should not contain any lines but contains %s." % wizard.location_ids | ||
2604 | 78 | self.confirm_uninventoried_locations(cr, uid, wizard_id, context=ctx) | ||
2605 | 79 | - | ||
2606 | 80 | Stock moves are not allowed in the locations during the inventory. | ||
2607 | 81 | - | ||
2608 | 82 | !python {model: stock.move}: | | ||
2609 | 83 | # TODOv8: remove this test, this is already part of trunk-wms | ||
2610 | 84 | from stock_inventory_location import ExhaustiveInventoryException | ||
2611 | 85 | try: | ||
2612 | 86 | self.create( | ||
2613 | 87 | cr,uid, { | ||
2614 | 88 | 'name': 'Bad move', | ||
2615 | 89 | 'location_id': ref('stock.stock_location_14'), | ||
2616 | 90 | 'location_dest_id': ref('stock.stock_location_3'), | ||
2617 | 91 | 'product_id': ref('product.product_product_8'), | ||
2618 | 92 | 'product_uom': ref('product.product_uom_unit'), | ||
2619 | 93 | 'date_expected': '2020-01-01 00:00:00' | ||
2620 | 94 | }) | ||
2621 | 95 | except ExhaustiveInventoryException as e: | ||
2622 | 96 | log("Good! The Stock Move was refused: %s" % e) | ||
2623 | 97 | - | ||
2624 | 98 | I will confirm the exhaustive inventory | ||
2625 | 99 | - | ||
2626 | 100 | !python {model: stock.inventory}: | | ||
2627 | 101 | self.action_confirm(cr, uid, [ref('inventory_exhaustive')]) | ||
2628 | 102 | inventory_state = self.read(cr, uid, [ref('inventory_exhaustive')], ['state'])[0]['state'] | ||
2629 | 103 | assert inventory_state == 'confirm', "Exhaustive inventory is in state '%s'. It should be 'confirm'" % inventory_state | ||
2630 | 104 | |||
2631 | 105 | - | ||
2632 | 106 | I will validate the exhaustive inventory | ||
2633 | 107 | - | ||
2634 | 108 | !python {model: stock.inventory}: | | ||
2635 | 109 | self.action_done(cr, uid, [ref('inventory_exhaustive')]) | ||
2636 | 110 | inventory_state = self.read(cr, uid, [ref('inventory_exhaustive')], ['state'])[0]['state'] | ||
2637 | 111 | assert inventory_state == 'done', "Exhaustive inventory is in state '%s'. It should be 'done'" % inventory_state | ||
2638 | 112 | |||
2639 | 113 | - | ||
2640 | 114 | I will verify the quantity for each products. | ||
2641 | 115 | - | ||
2642 | 116 | !python {model: product.product}: | | ||
2643 | 117 | ctx = dict(context, location=[ref('stock.stock_location_14')]) | ||
2644 | 118 | prod_qty_avail = self.read(cr, uid, [ref('product.product_product_7')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2645 | 119 | assert prod_qty_avail == 18.0, "The stock of PC1 was not set to 18.0: %s" % prod_qty_avail | ||
2646 | 120 | |||
2647 | 121 | prod_qty_avail = self.read(cr, uid, [ref('product.product_product_8')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2648 | 122 | assert prod_qty_avail == 5.0, "The stock of PC3 was not set to 5.0: %s" % prod_qty_avail | ||
2649 | 123 | |||
2650 | 124 | prod_qty_avail = self.read(cr, uid, [ref('product.product_product_24')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2651 | 125 | assert prod_qty_avail == 0.0, "The stock of KEYA was not set to 0: %s" % prod_qty_avail | ||
2652 | 126 | |||
2653 | 127 | prod_qty_avail = self.read(cr, uid, [ref('product.product_product_25')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2654 | 128 | assert prod_qty_avail == 0.0, "The stock of MOU was not set to 0: %s" % prod_qty_avail | ||
2655 | 0 | 129 | ||
2656 | === added file 'stock_inventory_location/tests/inventory_future_test.yml' | |||
2657 | --- stock_inventory_location/tests/inventory_future_test.yml 1970-01-01 00:00:00 +0000 | |||
2658 | +++ stock_inventory_location/tests/inventory_future_test.yml 2014-06-27 09:18:58 +0000 | |||
2659 | @@ -0,0 +1,13 @@ | |||
2660 | 1 | - | ||
2661 | 2 | Check that an inventory with a date in the future cannot be opened. | ||
2662 | 3 | - | ||
2663 | 4 | !python {model: stock.inventory}: | | ||
2664 | 5 | # TODO v8: maybe this is already part of the new WMS | ||
2665 | 6 | from osv.osv import except_osv | ||
2666 | 7 | self.action_open(cr, uid, [ref('inventory_future')]) | ||
2667 | 8 | try: | ||
2668 | 9 | self.action_done(cr, uid, [ref('inventory_future')]) | ||
2669 | 10 | except except_osv as e: | ||
2670 | 11 | log("Good! The Inventory could not be opened: %s" % e) | ||
2671 | 12 | inventory_state = self.read(cr, uid, [ref('inventory_future')], ['state'])[0]['state'] | ||
2672 | 13 | assert inventory_state != 'done', "Future inventory is done." | ||
2673 | 0 | 14 | ||
2674 | === added file 'stock_inventory_location/tests/inventory_standard_test.yml' | |||
2675 | --- stock_inventory_location/tests/inventory_standard_test.yml 1970-01-01 00:00:00 +0000 | |||
2676 | +++ stock_inventory_location/tests/inventory_standard_test.yml 2014-06-27 09:18:58 +0000 | |||
2677 | @@ -0,0 +1,100 @@ | |||
2678 | 1 | - | ||
2679 | 2 | This file will test a non exhaustive inventory. | ||
2680 | 3 | I will call open_action method and check if state of inventories are 'open'. | ||
2681 | 4 | - | ||
2682 | 5 | !python {model: stock.inventory}: | | ||
2683 | 6 | self.action_open(cr, uid, [ref('inventory_standard')]) | ||
2684 | 7 | inventory_state = self.read(cr, uid, [ref('inventory_standard')], ['state'])[0]['state'] | ||
2685 | 8 | assert inventory_state == 'open', "Partial inventory have '%s' state. It should be 'open'" % inventory_state | ||
2686 | 9 | |||
2687 | 10 | - | ||
2688 | 11 | In order, I add products to inventory. | ||
2689 | 12 | Adding Azerty Keyboard. | ||
2690 | 13 | - | ||
2691 | 14 | !record {model: stock.inventory.line, id: lines_inventory_location_kbaz}: | ||
2692 | 15 | product_id: product.product_product_9 | ||
2693 | 16 | product_uom: product.product_uom_unit | ||
2694 | 17 | company_id: base.main_company | ||
2695 | 18 | inventory_id: inventory_standard | ||
2696 | 19 | product_qty: 18.0 | ||
2697 | 20 | location_id: stock.stock_location_components | ||
2698 | 21 | |||
2699 | 22 | - | ||
2700 | 23 | Adding Optical Mouse. | ||
2701 | 24 | - | ||
2702 | 25 | !record {model: stock.inventory.line, id: lines_inventory_location_optm}: | ||
2703 | 26 | product_id: product.product_product_10 | ||
2704 | 27 | product_uom: product.product_uom_unit | ||
2705 | 28 | company_id: base.main_company | ||
2706 | 29 | inventory_id: inventory_standard | ||
2707 | 30 | product_qty: 12.0 | ||
2708 | 31 | location_id: stock.stock_location_components | ||
2709 | 32 | |||
2710 | 33 | - | ||
2711 | 34 | Adding Multimedia Speakers. | ||
2712 | 35 | - | ||
2713 | 36 | !record {model: stock.inventory.line, id: lines_inventory_location_grca}: | ||
2714 | 37 | product_id: product.product_template_31 | ||
2715 | 38 | product_uom: product.product_uom_unit | ||
2716 | 39 | company_id: base.main_company | ||
2717 | 40 | inventory_id: inventory_standard | ||
2718 | 41 | product_qty: 32.0 | ||
2719 | 42 | location_id: stock.stock_location_components | ||
2720 | 43 | |||
2721 | 44 | - | ||
2722 | 45 | I will call the function _get_locations_open_inventories and check the result. | ||
2723 | 46 | The function will return no locations because it's not an exhaustive inventory. | ||
2724 | 47 | - | ||
2725 | 48 | !python {model: stock.inventory}: | | ||
2726 | 49 | locations = self._get_locations_open_inventories(cr, uid) | ||
2727 | 50 | assert len(locations) == 0, "Function return wrong results: %s" % locations | ||
2728 | 51 | |||
2729 | 52 | - | ||
2730 | 53 | I will call the function onchange_location_id. | ||
2731 | 54 | The function must to return true in all test case. | ||
2732 | 55 | - | ||
2733 | 56 | !python {model: stock.inventory.line}: | | ||
2734 | 57 | res = self.onchange_location_id(cr, uid, [], [(6,0,[ref('stock.stock_location_components')])], False, ref('stock.stock_location_components')) | ||
2735 | 58 | assert res == True, "The function 'onchange_location_id' should return True and return '%s'" % res | ||
2736 | 59 | res = self.onchange_location_id(cr, uid, [], [(6,0,[ref('stock.stock_location_components')])], False, ref('stock.stock_location_14')) | ||
2737 | 60 | assert res == True, "The function 'onchange_location_id' should return True and return '%s'" % res | ||
2738 | 61 | |||
2739 | 62 | - | ||
2740 | 63 | I will call the function _check_inventory. | ||
2741 | 64 | The function must return True in all test cases. | ||
2742 | 65 | - | ||
2743 | 66 | !python {model: stock.location}: | | ||
2744 | 67 | res = self._check_inventory(cr, uid, ref('stock.stock_location_components')) | ||
2745 | 68 | assert res == True, "The function '_check_inventory' should return True and return '%s'" % res | ||
2746 | 69 | res = self._check_inventory(cr, uid, ref('stock.stock_location_14')) | ||
2747 | 70 | assert res == True, "The function '_check_inventory' should return True and return '%s'" % res | ||
2748 | 71 | |||
2749 | 72 | - | ||
2750 | 73 | I will confirm inventory. | ||
2751 | 74 | - | ||
2752 | 75 | !python {model: stock.inventory}: | | ||
2753 | 76 | self.action_confirm(cr, uid, [ref('inventory_standard')]) | ||
2754 | 77 | inventory_state = self.read(cr, uid, [ref('inventory_standard')], ['state'])[0]['state'] | ||
2755 | 78 | assert inventory_state == 'confirm', "Partial inventory have '%s' state. It should be 'confirm'" % inventory_state | ||
2756 | 79 | |||
2757 | 80 | - | ||
2758 | 81 | I will validate inventory | ||
2759 | 82 | - | ||
2760 | 83 | !python {model: stock.inventory}: | | ||
2761 | 84 | self.action_done(cr, uid, [ref('inventory_standard')]) | ||
2762 | 85 | inventory_state = self.read(cr, uid, [ref('inventory_standard')], ['state'])[0]['state'] | ||
2763 | 86 | assert inventory_state == 'done', "Partial inventory have '%s' state. It should be 'done'" % inventory_state | ||
2764 | 87 | |||
2765 | 88 | - | ||
2766 | 89 | I will verify the quantity for each products. | ||
2767 | 90 | - | ||
2768 | 91 | !python {model: product.product}: | | ||
2769 | 92 | ctx={'location': [ref('stock.stock_location_components')]} | ||
2770 | 93 | prod_qty_avail = self.read(cr, uid, [ref('product.product_product_9')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2771 | 94 | assert prod_qty_avail == 18.0, "The stock of CPU1 was not set to 18.0: %s" % prod_qty_avail | ||
2772 | 95 | |||
2773 | 96 | prod_qty_avail = self.read(cr, uid, [ref('product.product_product_10')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2774 | 97 | assert prod_qty_avail == 12.0, "The stock of CPU3 was not set to 12.0: %s" % prod_qty_avail | ||
2775 | 98 | |||
2776 | 99 | prod_qty_avail = self.read(cr, uid, [ref('product.product_template_31')], ['qty_available'], context=ctx)[0]['qty_available'] | ||
2777 | 100 | assert prod_qty_avail == 32.0, "The stock of FAN was not set to 32.0: %s" % prod_qty_avail | ||
2778 | 0 | 101 | ||
2779 | === added file 'stock_inventory_location/tests/stock_inventory_location_test.py' | |||
2780 | --- stock_inventory_location/tests/stock_inventory_location_test.py 1970-01-01 00:00:00 +0000 | |||
2781 | +++ stock_inventory_location/tests/stock_inventory_location_test.py 2014-06-27 09:18:58 +0000 | |||
2782 | @@ -0,0 +1,47 @@ | |||
2783 | 1 | # -*- coding: utf-8 -*- | ||
2784 | 2 | # | ||
2785 | 3 | # | ||
2786 | 4 | # Authors: Laetitia Gangloff | ||
2787 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
2788 | 6 | # All Rights Reserved | ||
2789 | 7 | # | ||
2790 | 8 | # WARNING: This program as such is intended to be used by professional | ||
2791 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
2792 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
2793 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
2794 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
2795 | 13 | # Service Company. | ||
2796 | 14 | # | ||
2797 | 15 | # This program is free software: you can redistribute it and/or modify | ||
2798 | 16 | # it under the terms of the GNU Affero General Public License as | ||
2799 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
2800 | 18 | # License, or (at your option) any later version. | ||
2801 | 19 | # | ||
2802 | 20 | # This program is distributed in the hope that it will be useful, | ||
2803 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2804 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2805 | 23 | # GNU Affero General Public License for more details. | ||
2806 | 24 | # | ||
2807 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
2808 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2809 | 27 | # | ||
2810 | 28 | # | ||
2811 | 29 | |||
2812 | 30 | import openerp.tests.common as common | ||
2813 | 31 | |||
2814 | 32 | DB = common.DB | ||
2815 | 33 | ADMIN_USER_ID = common.ADMIN_USER_ID | ||
2816 | 34 | |||
2817 | 35 | |||
2818 | 36 | class stock_inventory_location_test(common.TransactionCase): | ||
2819 | 37 | |||
2820 | 38 | def setUp(self): | ||
2821 | 39 | super(stock_inventory_location_test, self).setUp() | ||
2822 | 40 | |||
2823 | 41 | def test_update_parent_location(self): | ||
2824 | 42 | """ | ||
2825 | 43 | Test the update of the parent of a location (no inventory in progress | ||
2826 | 44 | """ | ||
2827 | 45 | self.registry('stock.location').write(self.cr, self.uid, self.ref('stock.stock_location_5'), {'location_id': self.ref('stock.stock_location_4')}) | ||
2828 | 46 | |||
2829 | 47 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2830 | 0 | 48 | ||
2831 | === added directory 'stock_inventory_location/wizard' | |||
2832 | === added file 'stock_inventory_location/wizard/__init__.py' | |||
2833 | --- stock_inventory_location/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
2834 | +++ stock_inventory_location/wizard/__init__.py 2014-06-27 09:18:58 +0000 | |||
2835 | @@ -0,0 +1,22 @@ | |||
2836 | 1 | # -*- coding: utf-8 -*-1 | ||
2837 | 2 | ############################################################################## | ||
2838 | 3 | # | ||
2839 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
2840 | 5 | # | ||
2841 | 6 | # This program is free software: you can redistribute it and/or modify | ||
2842 | 7 | # it under the terms of the GNU General Public License as published by | ||
2843 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
2844 | 9 | # (at your option) any later version. | ||
2845 | 10 | # | ||
2846 | 11 | # This program is distributed in the hope that it will be useful, | ||
2847 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2848 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2849 | 14 | # GNU General Public License for more details. | ||
2850 | 15 | # | ||
2851 | 16 | # You should have received a copy of the GNU General Public License | ||
2852 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2853 | 18 | # | ||
2854 | 19 | ############################################################################## | ||
2855 | 20 | |||
2856 | 21 | import stock_fill_location_inventory | ||
2857 | 22 | import stock_confirm_uninventoried_location | ||
2858 | 0 | 23 | ||
2859 | === added file 'stock_inventory_location/wizard/stock_confirm_uninventoried_location.py' | |||
2860 | --- stock_inventory_location/wizard/stock_confirm_uninventoried_location.py 1970-01-01 00:00:00 +0000 | |||
2861 | +++ stock_inventory_location/wizard/stock_confirm_uninventoried_location.py 2014-06-27 09:18:58 +0000 | |||
2862 | @@ -0,0 +1,68 @@ | |||
2863 | 1 | # -*- encoding: utf-8 -*- | ||
2864 | 2 | ############################################################################## | ||
2865 | 3 | # | ||
2866 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
2867 | 5 | # | ||
2868 | 6 | # This program is free software: you can redistribute it and/or modify | ||
2869 | 7 | # it under the terms of the GNU General Public License as published by | ||
2870 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
2871 | 9 | # (at your option) any later version. | ||
2872 | 10 | # | ||
2873 | 11 | # This program is distributed in the hope that it will be useful, | ||
2874 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2875 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2876 | 14 | # GNU General Public License for more details. | ||
2877 | 15 | # | ||
2878 | 16 | # You should have received a copy of the GNU General Public License | ||
2879 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2880 | 18 | # | ||
2881 | 19 | ############################################################################## | ||
2882 | 20 | |||
2883 | 21 | from openerp.osv import fields, orm, osv | ||
2884 | 22 | |||
2885 | 23 | |||
2886 | 24 | class stock_inventory_uninventoried_location(orm.TransientModel): | ||
2887 | 25 | _name = 'stock.inventory.uninventoried.locations' | ||
2888 | 26 | _description = 'Confirm the uninventoried Locations.' | ||
2889 | 27 | |||
2890 | 28 | _columns = { | ||
2891 | 29 | 'location_ids': fields.many2many( | ||
2892 | 30 | 'stock.location', | ||
2893 | 31 | 'stock_inventory_uninventoried_location_rel', | ||
2894 | 32 | 'location_id', 'wizard_id', | ||
2895 | 33 | 'Uninventoried location', readonly=True), | ||
2896 | 34 | } | ||
2897 | 35 | |||
2898 | 36 | def default_locations(self, cr, uid, context=None): | ||
2899 | 37 | """Initialize view with the list of uninventoried locations.""" | ||
2900 | 38 | return self.pool['stock.inventory'].get_missing_locations( | ||
2901 | 39 | cr, uid, context['active_ids'], context=context) | ||
2902 | 40 | |||
2903 | 41 | _defaults = { | ||
2904 | 42 | 'location_ids': default_locations, | ||
2905 | 43 | } | ||
2906 | 44 | |||
2907 | 45 | def confirm_uninventoried_locations(self, cr, uid, ids, context=None): | ||
2908 | 46 | """Add the missing inventory lines with qty=0 and confirm inventory""" | ||
2909 | 47 | inventory_ids = context['active_ids'] | ||
2910 | 48 | inventory_obj = self.pool['stock.inventory'] | ||
2911 | 49 | wizard_obj = self.pool['stock.fill.inventory'] | ||
2912 | 50 | for inventory in inventory_obj.browse(cr, uid, inventory_ids, | ||
2913 | 51 | context=context): | ||
2914 | 52 | if inventory.exhaustive: | ||
2915 | 53 | # silently run the import wizard with qty=0 | ||
2916 | 54 | try: | ||
2917 | 55 | # on parent inventory it is possible that fill inventory fail with no product | ||
2918 | 56 | wizard_id = wizard_obj.create( | ||
2919 | 57 | cr, uid, {'location_id': inventory.location_id.id, | ||
2920 | 58 | 'recursive': True, | ||
2921 | 59 | 'set_stock_zero': True, | ||
2922 | 60 | 'exhaustive': True}, context=context) | ||
2923 | 61 | wizard_obj.fill_inventory(cr, uid, [wizard_id], | ||
2924 | 62 | context=context) | ||
2925 | 63 | except osv.except_osv, e: | ||
2926 | 64 | if e.value == _('No product in this location. Please select a location in the product form.'): | ||
2927 | 65 | pass | ||
2928 | 66 | |||
2929 | 67 | inventory_obj.action_confirm(cr, uid, inventory_ids, context=context) | ||
2930 | 68 | return {'type': 'ir.actions.act_window_close'} | ||
2931 | 0 | 69 | ||
2932 | === added file 'stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml' | |||
2933 | --- stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml 1970-01-01 00:00:00 +0000 | |||
2934 | +++ stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml 2014-06-27 09:18:58 +0000 | |||
2935 | @@ -0,0 +1,33 @@ | |||
2936 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2937 | 2 | <openerp> | ||
2938 | 3 | <data> | ||
2939 | 4 | <!-- The view definition is similar with stock_inventory_hierarchical_location/wizard/stock_inventory_missing_locations_view.xml, | ||
2940 | 5 | but the code is different. | ||
2941 | 6 | This wizard compare declared locations with locations on inventory lines to present the uninventoried (empty) locations to user. --> | ||
2942 | 7 | <record id="view_confirm_uninventoried_location" model="ir.ui.view"> | ||
2943 | 8 | <field name="name">stock.inventory.uninventoried.locations.form</field> | ||
2944 | 9 | <field name="model">stock.inventory.uninventoried.locations</field> | ||
2945 | 10 | <field name="arch" type="xml"> | ||
2946 | 11 | <form string="Confirm empty locations" version="7.0"> | ||
2947 | 12 | <group colspan="4" col="1"> | ||
2948 | 13 | <separator string="The following Locations are empty"/> | ||
2949 | 14 | <label string="The following Stock Locations are part of the current Physical Inventory, but no Inventory Line has been recorded for them."/> | ||
2950 | 15 | <label string="It could either mean that the Locations are empty, or that the Inventory is not yet complete."/> | ||
2951 | 16 | <label string="If you confirm the Inventory, these Locations will be considered empty and their content will be purged."/> | ||
2952 | 17 | <field name="location_ids" nolabel="1"> | ||
2953 | 18 | <tree> | ||
2954 | 19 | <field name="name"/> | ||
2955 | 20 | </tree> | ||
2956 | 21 | </field> | ||
2957 | 22 | <separator string=""/> | ||
2958 | 23 | </group> | ||
2959 | 24 | <footer> | ||
2960 | 25 | <button name="confirm_uninventoried_locations" string="Purge contents and confirm Inventory" type="object" class="oe_highlight"/> | ||
2961 | 26 | or | ||
2962 | 27 | <button string="Cancel" class="oe_link" special="cancel" default_focus="1"/> | ||
2963 | 28 | </footer> | ||
2964 | 29 | </form> | ||
2965 | 30 | </field> | ||
2966 | 31 | </record> | ||
2967 | 32 | </data> | ||
2968 | 33 | </openerp> | ||
2969 | 0 | \ No newline at end of file | 34 | \ No newline at end of file |
2970 | 1 | 35 | ||
2971 | === added file 'stock_inventory_location/wizard/stock_fill_location_inventory.py' | |||
2972 | --- stock_inventory_location/wizard/stock_fill_location_inventory.py 1970-01-01 00:00:00 +0000 | |||
2973 | +++ stock_inventory_location/wizard/stock_fill_location_inventory.py 2014-06-27 09:18:58 +0000 | |||
2974 | @@ -0,0 +1,47 @@ | |||
2975 | 1 | # -*- coding: utf-8 -*- | ||
2976 | 2 | ############################################################################## | ||
2977 | 3 | # | ||
2978 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
2979 | 5 | # | ||
2980 | 6 | # This program is free software: you can redistribute it and/or modify | ||
2981 | 7 | # it under the terms of the GNU General Public License as published by | ||
2982 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
2983 | 9 | # (at your option) any later version. | ||
2984 | 10 | # | ||
2985 | 11 | # This program is distributed in the hope that it will be useful, | ||
2986 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2987 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2988 | 14 | # GNU General Public License for more details. | ||
2989 | 15 | # | ||
2990 | 16 | # You should have received a copy of the GNU General Public License | ||
2991 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2992 | 18 | # | ||
2993 | 19 | ############################################################################## | ||
2994 | 20 | |||
2995 | 21 | from openerp.osv import fields, orm | ||
2996 | 22 | |||
2997 | 23 | |||
2998 | 24 | class FillInventoryWizard(orm.TransientModel): | ||
2999 | 25 | """Add a field that lets the client make the location read-only""" | ||
3000 | 26 | _inherit = 'stock.fill.inventory' | ||
3001 | 27 | |||
3002 | 28 | _columns = { | ||
3003 | 29 | 'exhaustive': fields.boolean('Exhaustive', readonly=True) | ||
3004 | 30 | } | ||
3005 | 31 | |||
3006 | 32 | def default_get(self, cr, uid, fields, context=None): | ||
3007 | 33 | """Get 'location_id' and 'exhaustive' from the inventory""" | ||
3008 | 34 | if context is None: | ||
3009 | 35 | context = {} | ||
3010 | 36 | inv_id = context.get('active_id') | ||
3011 | 37 | |||
3012 | 38 | res = super(FillInventoryWizard, self).default_get( | ||
3013 | 39 | cr, uid, fields, context=context) | ||
3014 | 40 | if (context.get('active_model') == 'stock.inventory' | ||
3015 | 41 | and inv_id | ||
3016 | 42 | and 'location_id' in fields): | ||
3017 | 43 | inventory = self.pool['stock.inventory'].browse( | ||
3018 | 44 | cr, uid, context['active_id'], context=context) | ||
3019 | 45 | res.update({'location_id': inventory.location_id.id, | ||
3020 | 46 | 'exhaustive': inventory.exhaustive}) | ||
3021 | 47 | return res | ||
3022 | 0 | 48 | ||
3023 | === added file 'stock_inventory_location/wizard/stock_fill_location_inventory_view.xml' | |||
3024 | --- stock_inventory_location/wizard/stock_fill_location_inventory_view.xml 1970-01-01 00:00:00 +0000 | |||
3025 | +++ stock_inventory_location/wizard/stock_fill_location_inventory_view.xml 2014-06-27 09:18:58 +0000 | |||
3026 | @@ -0,0 +1,18 @@ | |||
3027 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
3028 | 2 | <openerp> | ||
3029 | 3 | <data> | ||
3030 | 4 | <record id="view_stock_fill_inventory_location" model="ir.ui.view"> | ||
3031 | 5 | <field name="name">Import Inventory</field> | ||
3032 | 6 | <field name="model">stock.fill.inventory</field> | ||
3033 | 7 | <field name="inherit_id" ref="stock.view_stock_fill_inventory" /> | ||
3034 | 8 | <field name="arch" type="xml"> | ||
3035 | 9 | <xpath expr="//field[@name='location_id']" position="after"> | ||
3036 | 10 | <field name="exhaustive" invisible="1" /> | ||
3037 | 11 | </xpath> | ||
3038 | 12 | <xpath expr="//field[@name='location_id']" position="attributes"> | ||
3039 | 13 | <attribute name="attrs">{'readonly':[('exhaustive','=',True)]}</attribute> | ||
3040 | 14 | </xpath> | ||
3041 | 15 | </field> | ||
3042 | 16 | </record> | ||
3043 | 17 | </data> | ||
3044 | 18 | </openerp> |