Merge lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical into lp:stock-logistic-warehouse
- 7.0-inventory-hierarchical
- Merge into 7.0
Status: | Rejected |
---|---|
Rejected by: | Pedro Manuel Baeza |
Proposed branch: | lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical |
Merge into: | lp:stock-logistic-warehouse |
Prerequisite: | lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-location |
Diff against target: |
1935 lines (+1799/-0) 23 files modified
stock_inventory_hierarchical/__init__.py (+28/-0) stock_inventory_hierarchical/__openerp__.py (+46/-0) stock_inventory_hierarchical/exceptions.py (+26/-0) stock_inventory_hierarchical/hierarchical_inventory.py (+202/-0) stock_inventory_hierarchical/hierarchical_inventory_demo.xml (+17/-0) stock_inventory_hierarchical/hierarchical_inventory_view.xml (+84/-0) stock_inventory_hierarchical/i18n/fr.po (+116/-0) stock_inventory_hierarchical/i18n/stock_inventory_hierarchical.pot (+116/-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 (+164/-0) stock_inventory_hierarchical_location/i18n/stock_inventory_hierarchical_location.pot (+166/-0) stock_inventory_hierarchical_location/inventory_hierarchical_location.py (+102/-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) |
To merge this branch: | bzr merge lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-hierarchical |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Fayolle - camptocamp | Needs Resubmitting | ||
Lionel Sausin - Initiatives/Numérigraphe (community) | co-author | Abstain | |
Laetitia Gangloff (Acsone) | Pending | ||
Review via email: mp+223882@code.launchpad.net |
This proposal supersedes a proposal from 2014-03-12.
Commit message
Description of the change
Code cleanup and Bug fixes.
This proposal lets users compose inventories with sub-inventories in
a hierarchical tree.
This is useful in medium/large warehouses where
several teams must work in parallel to make inventories.
The module stock_inventory
stock_inventory
Thanks to Laetitia GANGLOFF from Ascone for her contribution.
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : Posted in a previous version of this proposal | # |
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : Posted in a previous version of this proposal | # |
Loïc and I are still working on this proposal. Good progress was made: we re-aligned the features with v8 in mind, and improved the code style and the views.
Acsone joined in and we're still making tests, and I hope Loïc can make a new proposal in the coming days.
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) : | # |
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
Loïc just noticed a bug when clearing locations in exhaustive and structured inventories, related to Bug #1197467.
When confirming the parent inventory, the children inventories' locations are not excluded from the exhaustivity check, and lines with qty=0 are unduly added to the parent inventory.
I'm fixing this as fast as I can.
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
Fixed partly here and partly in lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-location
- 47. By Numérigraphe
-
[IMP] add button to open subinventories and progresbar on inventory header.
- 48. By Numérigraphe
-
[IMP] French translation
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
The source code management for this project has been moved to https:/
Could you resubmit this MP on the new site?
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
I've finally resubmitted this as part of the pull request at https:/
Please reject the merge proposal here to make it clear it won't be processed on Launchpad.
Unmerged revisions
- 48. By Numérigraphe
-
[IMP] French translation
- 47. By Numérigraphe
-
[IMP] add button to open subinventories and progresbar on inventory header.
- 46. By Laetitia Gangloff (Acsone)
-
[MERGE] raise the same exception as the standard so the other parts of the code can catch it properly
- 45. By Numérigraphe
-
[MERGE] no-change commit to close acsone's MP
- 44. By Numérigraphe
-
[MERGE] take subinventories into account when validating an exhaustive structured inventory
- 43. By Numérigraphe
-
[MERGE] fixes from 7.0-inventory-
location - 42. By Loïc Bellier - Numérigraphe
-
[MERGE]: Exception fault fixed by ACSONE.
- 41. By Loïc Bellier - Numérigraphe
-
[MERGE]: Fix some bugs. Add Merge Proposal of Laetitia Gangloff from ASCONE and thanks to her.
- 40. By Loïc Bellier - Numérigraphe
-
[MERGE]: merge from dev branch
- 39. By Loïc Bellier - Numérigraphe
-
[MERGE]: From dev branch
Preview Diff
1 | === added directory 'stock_inventory_hierarchical' | |||
2 | === added file 'stock_inventory_hierarchical/__init__.py' | |||
3 | --- stock_inventory_hierarchical/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ stock_inventory_hierarchical/__init__.py 2014-07-01 11:47:18 +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-07-01 11:47:18 +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-07-01 11:47:18 +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-07-01 11:47:18 +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 Inventory', 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-07-01 11:47:18 +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-07-01 11:47:18 +0000 | |||
349 | @@ -0,0 +1,84 @@ | |||
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//div[@class='oe_right oe_button_box']" position="inside"> | ||
395 | 46 | <button name="%(action_view_sub_inventory)d" string="View Sub-inventories" type="action" /> | ||
396 | 47 | </xpath> | ||
397 | 48 | <xpath expr="/form//field[@name='name']" position="after"> | ||
398 | 49 | <field name="parent_id"/> | ||
399 | 50 | </xpath> | ||
400 | 51 | <xpath expr="/form//field[@name='date']" position="attributes"> | ||
401 | 52 | <attribute name="attrs">{'readonly':[('parent_id', '!=', False)]}</attribute> | ||
402 | 53 | </xpath> | ||
403 | 54 | <xpath expr="/form//field[@name='date']" position="after"> | ||
404 | 55 | <field name="progress_rate" widget="progressbar" /> | ||
405 | 56 | </xpath> | ||
406 | 57 | <xpath | ||
407 | 58 | expr="//page[@string='General Information']" | ||
408 | 59 | position="after"> | ||
409 | 60 | <page string="Sub-inventories"> | ||
410 | 61 | <field name="inventory_ids" nolabel="1" context="{'default_parent_id': active_id}"> | ||
411 | 62 | <tree> | ||
412 | 63 | <field name="name" /> | ||
413 | 64 | <field name="state" /> | ||
414 | 65 | <field name="progress_rate" widget="progressbar" /> | ||
415 | 66 | </tree> | ||
416 | 67 | </field> | ||
417 | 68 | </page> | ||
418 | 69 | </xpath> | ||
419 | 70 | </field> | ||
420 | 71 | </record> | ||
421 | 72 | |||
422 | 73 | <!-- Open the children of the current Inventory in a distinct list | ||
423 | 74 | to let users work in a normal window instead of a popup --> | ||
424 | 75 | <act_window id="action_view_sub_inventory" | ||
425 | 76 | name="View Sub-inventories" | ||
426 | 77 | res_model="stock.inventory" | ||
427 | 78 | src_model="stock.inventory" | ||
428 | 79 | view_mode="tree,form" | ||
429 | 80 | view_type="form" | ||
430 | 81 | domain="[('parent_id', 'child_of', active_id),('id', '!=', active_id)]" | ||
431 | 82 | context="{'full':1, 'search_default_main_inventories':0}"/> | ||
432 | 83 | </data> | ||
433 | 84 | </openerp> | ||
434 | 0 | 85 | ||
435 | === added directory 'stock_inventory_hierarchical/i18n' | |||
436 | === added file 'stock_inventory_hierarchical/i18n/fr.po' | |||
437 | --- stock_inventory_hierarchical/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
438 | +++ stock_inventory_hierarchical/i18n/fr.po 2014-07-01 11:47:18 +0000 | |||
439 | @@ -0,0 +1,116 @@ | |||
440 | 1 | # Translation of OpenERP Server. | ||
441 | 2 | # This file contains the translation of the following modules: | ||
442 | 3 | # * stock_inventory_hierarchical | ||
443 | 4 | # | ||
444 | 5 | msgid "" | ||
445 | 6 | msgstr "" | ||
446 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
447 | 8 | "Report-Msgid-Bugs-To: \n" | ||
448 | 9 | "POT-Creation-Date: 2014-07-01 11:15+0000\n" | ||
449 | 10 | "PO-Revision-Date: 2014-07-01 11:15+0000\n" | ||
450 | 11 | "Last-Translator: <>\n" | ||
451 | 12 | "Language-Team: \n" | ||
452 | 13 | "MIME-Version: 1.0\n" | ||
453 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
454 | 15 | "Content-Transfer-Encoding: \n" | ||
455 | 16 | "Plural-Forms: \n" | ||
456 | 17 | |||
457 | 18 | #. module: stock_inventory_hierarchical | ||
458 | 19 | #: field:stock.inventory,complete_name:0 | ||
459 | 20 | msgid "Complete reference" | ||
460 | 21 | msgstr "Réference complète" | ||
461 | 22 | |||
462 | 23 | #. module: stock_inventory_hierarchical | ||
463 | 24 | #: constraint:stock.inventory:0 | ||
464 | 25 | msgid "Error: You can not create recursive inventories." | ||
465 | 26 | msgstr "Erreur : Vous ne pouvez pas créer d'inventaire récursifs." | ||
466 | 27 | |||
467 | 28 | #. module: stock_inventory_hierarchical | ||
468 | 29 | #: code:_description:0 | ||
469 | 30 | #: model:ir.model,name:stock_inventory_hierarchical.model_stock_inventory | ||
470 | 31 | #, python-format | ||
471 | 32 | msgid "Inventory" | ||
472 | 33 | msgstr "Inventaire" | ||
473 | 34 | |||
474 | 35 | #. module: stock_inventory_hierarchical | ||
475 | 36 | #: field:stock.inventory,inventory_ids:0 | ||
476 | 37 | msgid "List of Sub-inventories" | ||
477 | 38 | msgstr "Liste des sous-inventaires" | ||
478 | 39 | |||
479 | 40 | #. module: stock_inventory_hierarchical | ||
480 | 41 | #: view:stock.inventory:0 | ||
481 | 42 | msgid "Main inventories" | ||
482 | 43 | msgstr "Inventaires principaux" | ||
483 | 44 | |||
484 | 45 | #. module: stock_inventory_hierarchical | ||
485 | 46 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:174 | ||
486 | 47 | #, python-format | ||
487 | 48 | msgid "One of the parent Inventories is not canceled." | ||
488 | 49 | msgstr "Un des inventaires pères n'est pas annulé." | ||
489 | 50 | |||
490 | 51 | #. module: stock_inventory_hierarchical | ||
491 | 52 | #: view:stock.inventory:0 | ||
492 | 53 | msgid "Only select inventories that have no parents." | ||
493 | 54 | msgstr "Sélectionne uniquement les inventaires qui n'ont pas de père." | ||
494 | 55 | |||
495 | 56 | #. module: stock_inventory_hierarchical | ||
496 | 57 | #: field:stock.inventory,parent_id:0 | ||
497 | 58 | msgid "Parent Inventory" | ||
498 | 59 | msgstr "Inventaire père" | ||
499 | 60 | |||
500 | 61 | #. module: stock_inventory_hierarchical | ||
501 | 62 | #: field:stock.inventory,parent_left:0 | ||
502 | 63 | msgid "Parent Left" | ||
503 | 64 | msgstr "Parent gauche" | ||
504 | 65 | |||
505 | 66 | #. module: stock_inventory_hierarchical | ||
506 | 67 | #: field:stock.inventory,parent_right:0 | ||
507 | 68 | msgid "Parent Right" | ||
508 | 69 | msgstr "Parent droit" | ||
509 | 70 | |||
510 | 71 | #. module: stock_inventory_hierarchical | ||
511 | 72 | #: field:stock.inventory,progress_rate:0 | ||
512 | 73 | msgid "Progress" | ||
513 | 74 | msgstr "Avancement" | ||
514 | 75 | |||
515 | 76 | #. module: stock_inventory_hierarchical | ||
516 | 77 | #: view:stock.inventory:0 | ||
517 | 78 | msgid "Reference" | ||
518 | 79 | msgstr "Référence" | ||
519 | 80 | |||
520 | 81 | #. module: stock_inventory_hierarchical | ||
521 | 82 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:188 | ||
522 | 83 | #, python-format | ||
523 | 84 | msgid "Some Sub-inventories are not confirmed." | ||
524 | 85 | msgstr "Certains sous-inventaires ne sont pas confirmés." | ||
525 | 86 | |||
526 | 87 | #. module: stock_inventory_hierarchical | ||
527 | 88 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:200 | ||
528 | 89 | #, python-format | ||
529 | 90 | msgid "Some Sub-inventories are not validated." | ||
530 | 91 | msgstr "Certains sous-inventaires ne sont pas terminés." | ||
531 | 92 | |||
532 | 93 | #. module: stock_inventory_hierarchical | ||
533 | 94 | #: view:stock.inventory:0 | ||
534 | 95 | msgid "Sub-inventories" | ||
535 | 96 | msgstr "Sous-inventaires" | ||
536 | 97 | |||
537 | 98 | #. module: stock_inventory_hierarchical | ||
538 | 99 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical.action_view_sub_inventory | ||
539 | 100 | #: view:stock.inventory:0 | ||
540 | 101 | msgid "View Sub-inventories" | ||
541 | 102 | msgstr "Voir les sous-inventaires" | ||
542 | 103 | |||
543 | 104 | #. module: stock_inventory_hierarchical | ||
544 | 105 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:173 | ||
545 | 106 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:187 | ||
546 | 107 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:199 | ||
547 | 108 | #, python-format | ||
548 | 109 | msgid "Warning" | ||
549 | 110 | msgstr "Attention" | ||
550 | 111 | |||
551 | 112 | #. module: stock_inventory_hierarchical | ||
552 | 113 | #: view:stock.inventory:0 | ||
553 | 114 | msgid "{'readonly':[('parent_id', '!=', False)]}" | ||
554 | 115 | msgstr "{'readonly':[('parent_id', '!=', False)]}" | ||
555 | 116 | |||
556 | 0 | 117 | ||
557 | === added file 'stock_inventory_hierarchical/i18n/stock_inventory_hierarchical.pot' | |||
558 | --- stock_inventory_hierarchical/i18n/stock_inventory_hierarchical.pot 1970-01-01 00:00:00 +0000 | |||
559 | +++ stock_inventory_hierarchical/i18n/stock_inventory_hierarchical.pot 2014-07-01 11:47:18 +0000 | |||
560 | @@ -0,0 +1,116 @@ | |||
561 | 1 | # Translation of OpenERP Server. | ||
562 | 2 | # This file contains the translation of the following modules: | ||
563 | 3 | # * stock_inventory_hierarchical | ||
564 | 4 | # | ||
565 | 5 | msgid "" | ||
566 | 6 | msgstr "" | ||
567 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
568 | 8 | "Report-Msgid-Bugs-To: \n" | ||
569 | 9 | "POT-Creation-Date: 2014-07-01 11:26+0000\n" | ||
570 | 10 | "PO-Revision-Date: 2014-07-01 11:26+0000\n" | ||
571 | 11 | "Last-Translator: <>\n" | ||
572 | 12 | "Language-Team: \n" | ||
573 | 13 | "MIME-Version: 1.0\n" | ||
574 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
575 | 15 | "Content-Transfer-Encoding: \n" | ||
576 | 16 | "Plural-Forms: \n" | ||
577 | 17 | |||
578 | 18 | #. module: stock_inventory_hierarchical | ||
579 | 19 | #: field:stock.inventory,complete_name:0 | ||
580 | 20 | msgid "Complete reference" | ||
581 | 21 | msgstr "" | ||
582 | 22 | |||
583 | 23 | #. module: stock_inventory_hierarchical | ||
584 | 24 | #: constraint:stock.inventory:0 | ||
585 | 25 | msgid "Error: You can not create recursive inventories." | ||
586 | 26 | msgstr "" | ||
587 | 27 | |||
588 | 28 | #. module: stock_inventory_hierarchical | ||
589 | 29 | #: code:_description:0 | ||
590 | 30 | #: model:ir.model,name:stock_inventory_hierarchical.model_stock_inventory | ||
591 | 31 | #, python-format | ||
592 | 32 | msgid "Inventory" | ||
593 | 33 | msgstr "" | ||
594 | 34 | |||
595 | 35 | #. module: stock_inventory_hierarchical | ||
596 | 36 | #: field:stock.inventory,inventory_ids:0 | ||
597 | 37 | msgid "List of Sub-inventories" | ||
598 | 38 | msgstr "" | ||
599 | 39 | |||
600 | 40 | #. module: stock_inventory_hierarchical | ||
601 | 41 | #: view:stock.inventory:0 | ||
602 | 42 | msgid "Main inventories" | ||
603 | 43 | msgstr "" | ||
604 | 44 | |||
605 | 45 | #. module: stock_inventory_hierarchical | ||
606 | 46 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:174 | ||
607 | 47 | #, python-format | ||
608 | 48 | msgid "One of the parent Inventories is not canceled." | ||
609 | 49 | msgstr "" | ||
610 | 50 | |||
611 | 51 | #. module: stock_inventory_hierarchical | ||
612 | 52 | #: view:stock.inventory:0 | ||
613 | 53 | msgid "Only select inventories that have no parents." | ||
614 | 54 | msgstr "" | ||
615 | 55 | |||
616 | 56 | #. module: stock_inventory_hierarchical | ||
617 | 57 | #: field:stock.inventory,parent_id:0 | ||
618 | 58 | msgid "Parent Inventory" | ||
619 | 59 | msgstr "" | ||
620 | 60 | |||
621 | 61 | #. module: stock_inventory_hierarchical | ||
622 | 62 | #: field:stock.inventory,parent_left:0 | ||
623 | 63 | msgid "Parent Left" | ||
624 | 64 | msgstr "" | ||
625 | 65 | |||
626 | 66 | #. module: stock_inventory_hierarchical | ||
627 | 67 | #: field:stock.inventory,parent_right:0 | ||
628 | 68 | msgid "Parent Right" | ||
629 | 69 | msgstr "" | ||
630 | 70 | |||
631 | 71 | #. module: stock_inventory_hierarchical | ||
632 | 72 | #: field:stock.inventory,progress_rate:0 | ||
633 | 73 | msgid "Progress" | ||
634 | 74 | msgstr "" | ||
635 | 75 | |||
636 | 76 | #. module: stock_inventory_hierarchical | ||
637 | 77 | #: view:stock.inventory:0 | ||
638 | 78 | msgid "Reference" | ||
639 | 79 | msgstr "" | ||
640 | 80 | |||
641 | 81 | #. module: stock_inventory_hierarchical | ||
642 | 82 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:188 | ||
643 | 83 | #, python-format | ||
644 | 84 | msgid "Some Sub-inventories are not confirmed." | ||
645 | 85 | msgstr "" | ||
646 | 86 | |||
647 | 87 | #. module: stock_inventory_hierarchical | ||
648 | 88 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:200 | ||
649 | 89 | #, python-format | ||
650 | 90 | msgid "Some Sub-inventories are not validated." | ||
651 | 91 | msgstr "" | ||
652 | 92 | |||
653 | 93 | #. module: stock_inventory_hierarchical | ||
654 | 94 | #: view:stock.inventory:0 | ||
655 | 95 | msgid "Sub-inventories" | ||
656 | 96 | msgstr "" | ||
657 | 97 | |||
658 | 98 | #. module: stock_inventory_hierarchical | ||
659 | 99 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical.action_view_sub_inventory | ||
660 | 100 | #: view:stock.inventory:0 | ||
661 | 101 | msgid "View Sub-inventories" | ||
662 | 102 | msgstr "" | ||
663 | 103 | |||
664 | 104 | #. module: stock_inventory_hierarchical | ||
665 | 105 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:173 | ||
666 | 106 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:187 | ||
667 | 107 | #: code:addons/stock_inventory_hierarchical/hierarchical_inventory.py:199 | ||
668 | 108 | #, python-format | ||
669 | 109 | msgid "Warning" | ||
670 | 110 | msgstr "" | ||
671 | 111 | |||
672 | 112 | #. module: stock_inventory_hierarchical | ||
673 | 113 | #: view:stock.inventory:0 | ||
674 | 114 | msgid "{'readonly':[('parent_id', '!=', False)]}" | ||
675 | 115 | msgstr "" | ||
676 | 116 | |||
677 | 0 | 117 | ||
678 | === added directory 'stock_inventory_hierarchical/images' | |||
679 | === added file 'stock_inventory_hierarchical/images/inventory_form.png' | |||
680 | 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-07-01 11:47:18 +0000 differ | 118 | 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-07-01 11:47:18 +0000 differ |
681 | === added file 'stock_inventory_hierarchical/images/inventory_form_actions.png' | |||
682 | 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-07-01 11:47:18 +0000 differ | 119 | 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-07-01 11:47:18 +0000 differ |
683 | === added directory 'stock_inventory_hierarchical/static' | |||
684 | === added directory 'stock_inventory_hierarchical/static/src' | |||
685 | === added directory 'stock_inventory_hierarchical/static/src/img' | |||
686 | === added file 'stock_inventory_hierarchical/static/src/img/icon.png' | |||
687 | 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-07-01 11:47:18 +0000 differ | 120 | 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-07-01 11:47:18 +0000 differ |
688 | === added directory 'stock_inventory_hierarchical/test' | |||
689 | === added file 'stock_inventory_hierarchical/test/hierarchical_inventory_test.yml' | |||
690 | --- stock_inventory_hierarchical/test/hierarchical_inventory_test.yml 1970-01-01 00:00:00 +0000 | |||
691 | +++ stock_inventory_hierarchical/test/hierarchical_inventory_test.yml 2014-07-01 11:47:18 +0000 | |||
692 | @@ -0,0 +1,96 @@ | |||
693 | 1 | - | ||
694 | 2 | In this file, i check rules about hierarchical inventories. | ||
695 | 3 | Children date must be the same of parent date for each state, | ||
696 | 4 | the state of parent and children can change only if conditions are correct. | ||
697 | 5 | - | ||
698 | 6 | Check if date of children are the same as the parent's. | ||
699 | 7 | - | ||
700 | 8 | !python {model: stock.inventory}: | | ||
701 | 9 | parent_date = self.read( | ||
702 | 10 | cr, uid, [ref('stock_inventory_parent0')], ['date'])[0]['date'] | ||
703 | 11 | child_1_date = self.read( | ||
704 | 12 | cr, uid, [ref('child_1_id')], ['date'])[0]['date'] | ||
705 | 13 | assert child_1_date == parent_date, "Date are different: %s - %s" % (parent_date, child_1_date) | ||
706 | 14 | |||
707 | 15 | child_2_date = self.read( | ||
708 | 16 | cr, uid, [ref('child_2_id')], ['date'])[0]['date'] | ||
709 | 17 | assert child_2_date == parent_date, "Date are different: %s - %s" % (parent_date, child_2_date) | ||
710 | 18 | |||
711 | 19 | - | ||
712 | 20 | Check if children cannot be canceled if the parent was not canceled. | ||
713 | 21 | I'll try to cancel both children inventory while parent inventory having "draft" state. | ||
714 | 22 | After, i'll verify the state of each inventory. | ||
715 | 23 | - | ||
716 | 24 | !python {model: stock.inventory}: | | ||
717 | 25 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
718 | 26 | try: | ||
719 | 27 | self.action_cancel_inventory(cr, uid, [ref('child_1_id')]) | ||
720 | 28 | except HierarchicalInventoryException as e: | ||
721 | 29 | log("Good ! The Inventory could not be canceled: %s" % e) | ||
722 | 30 | try: | ||
723 | 31 | self.action_cancel_inventory(cr, uid, [ref('child_2_id')]) | ||
724 | 32 | except HierarchicalInventoryException as e: | ||
725 | 33 | log("Good ! The Inventory could not be canceled: %s" % e) | ||
726 | 34 | child_1_state = self.read(cr, uid, [ref('child_1_id')], ['state'])[0]['state'] | ||
727 | 35 | assert child_1_state == 'draft', "Child inventory 1 have '%s' state. It should be 'draft'" % child_1_state | ||
728 | 36 | child_2_state = self.read(cr, uid, [ref('child_2_id')], ['state'])[0]['state'] | ||
729 | 37 | assert child_2_state == 'draft', "Child inventory 2 have '%s' state. It should be 'draft'" % child_2_state | ||
730 | 38 | |||
731 | 39 | - | ||
732 | 40 | Check if children inventory have confirm state before confirm parent inventory. | ||
733 | 41 | To check this, i'll try to confirm parent inventory when children inventory having "draft" state, | ||
734 | 42 | and i'll check if state is still 'draft'. | ||
735 | 43 | - | ||
736 | 44 | !python {model: stock.inventory}: | | ||
737 | 45 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
738 | 46 | try: | ||
739 | 47 | self.action_confirm(cr, uid, [ref('stock_inventory_parent0')]) | ||
740 | 48 | except HierarchicalInventoryException as e: | ||
741 | 49 | log("Good, the inventory could not be confirmed: %s", e) | ||
742 | 50 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
743 | 51 | assert parent_state == 'draft', "Parent inventory have '%s' state. It should be 'draft'" % parent_state | ||
744 | 52 | |||
745 | 53 | - | ||
746 | 54 | In order, i'll confirm the children inventories, and the parent inventory after. | ||
747 | 55 | - | ||
748 | 56 | !python {model: stock.inventory}: | | ||
749 | 57 | self.action_confirm(cr, uid, [ref('child_1_id')]) | ||
750 | 58 | child_1_state = self.read(cr, uid, [ref('child_1_id')], ['state'])[0]['state'] | ||
751 | 59 | assert child_1_state == 'confirm', "Child inventory 1 have '%s' state. It should be 'confirm'" % child_1_state | ||
752 | 60 | |||
753 | 61 | self.action_confirm(cr, uid, [ref('child_2_id')]) | ||
754 | 62 | child_2_state = self.read(cr, uid, [ref('child_2_id')], ['state'])[0]['state'] | ||
755 | 63 | assert child_2_state == 'confirm', "Child inventory 2 have '%s' state. It should be 'confirm'" % child_2_state | ||
756 | 64 | |||
757 | 65 | self.action_confirm(cr, uid, [ref('stock_inventory_parent0')]) | ||
758 | 66 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
759 | 67 | assert parent_state == 'confirm', "Parent inventory have '%s' state. It should be 'confirm'" % parent_state | ||
760 | 68 | |||
761 | 69 | - | ||
762 | 70 | Check if children inventory have done state before validate parent inventory. | ||
763 | 71 | I'll try to validate parent inventory before children. | ||
764 | 72 | - | ||
765 | 73 | !python {model: stock.inventory}: | | ||
766 | 74 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
767 | 75 | try: | ||
768 | 76 | self.action_done(cr, uid, [ref('stock_inventory_parent0')]) | ||
769 | 77 | except HierarchicalInventoryException as e: | ||
770 | 78 | log("Good, the inventory could not be validated: %s", e) | ||
771 | 79 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
772 | 80 | assert parent_state == 'confirm', "Parent inventory have '%s' state. It should be 'confirm'" % parent_state | ||
773 | 81 | |||
774 | 82 | - | ||
775 | 83 | Now, i'll validate all children inventory before validate the parent. | ||
776 | 84 | - | ||
777 | 85 | !python {model: stock.inventory}: | | ||
778 | 86 | self.action_done(cr, uid, [ref('child_1_id')]) | ||
779 | 87 | child_1_state = self.read(cr, uid, [ref('child_1_id')], ['state'])[0]['state'] | ||
780 | 88 | assert child_1_state == 'done', "Child inventory 1 have '%s' state. It should be 'done'" % child_1_state | ||
781 | 89 | |||
782 | 90 | self.action_done(cr, uid, [ref('child_2_id')]) | ||
783 | 91 | child_2_state = self.read(cr, uid, [ref('child_2_id')], ['state'])[0]['state'] | ||
784 | 92 | assert child_2_state == 'done', "Child inventory 2 have '%s' state. It should be 'done'" % child_2_state | ||
785 | 93 | |||
786 | 94 | self.action_done(cr, uid, [ref('stock_inventory_parent0')]) | ||
787 | 95 | parent_state = self.read(cr, uid, [ref('stock_inventory_parent0')], ['state'])[0]['state'] | ||
788 | 96 | assert parent_state == 'done', "Parent inventory have '%s' state. It should be 'done'" % parent_state | ||
789 | 0 | 97 | ||
790 | === added directory 'stock_inventory_hierarchical_location' | |||
791 | === added file 'stock_inventory_hierarchical_location/__init__.py' | |||
792 | --- stock_inventory_hierarchical_location/__init__.py 1970-01-01 00:00:00 +0000 | |||
793 | +++ stock_inventory_hierarchical_location/__init__.py 2014-07-01 11:47:18 +0000 | |||
794 | @@ -0,0 +1,22 @@ | |||
795 | 1 | # -*- coding: utf-8 -*- | ||
796 | 2 | ############################################################################## | ||
797 | 3 | # | ||
798 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
799 | 5 | # | ||
800 | 6 | # This program is free software: you can redistribute it and/or modify | ||
801 | 7 | # it under the terms of the GNU General Public License as published by | ||
802 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
803 | 9 | # (at your option) any later version. | ||
804 | 10 | # | ||
805 | 11 | # This program is distributed in the hope that it will be useful, | ||
806 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
807 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
808 | 14 | # GNU General Public License for more details. | ||
809 | 15 | # | ||
810 | 16 | # You should have received a copy of the GNU General Public License | ||
811 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
812 | 18 | # | ||
813 | 19 | ############################################################################## | ||
814 | 20 | |||
815 | 21 | from . import inventory_hierarchical_location | ||
816 | 22 | from . import wizard | ||
817 | 0 | 23 | ||
818 | === added file 'stock_inventory_hierarchical_location/__openerp__.py' | |||
819 | --- stock_inventory_hierarchical_location/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
820 | +++ stock_inventory_hierarchical_location/__openerp__.py 2014-07-01 11:47:18 +0000 | |||
821 | @@ -0,0 +1,49 @@ | |||
822 | 1 | # -*- coding: utf-8 -*- | ||
823 | 2 | ############################################################################## | ||
824 | 3 | # | ||
825 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
826 | 5 | # | ||
827 | 6 | # This program is free software: you can redistribute it and/or modify | ||
828 | 7 | # it under the terms of the GNU General Public License as published by | ||
829 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
830 | 9 | # (at your option) any later version. | ||
831 | 10 | # | ||
832 | 11 | # This program is distributed in the hope that it will be useful, | ||
833 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
834 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
835 | 14 | # GNU General Public License for more details. | ||
836 | 15 | # | ||
837 | 16 | # You should have received a copy of the GNU General Public License | ||
838 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
839 | 18 | # | ||
840 | 19 | ############################################################################## | ||
841 | 20 | |||
842 | 21 | { | ||
843 | 22 | "name": "Exhaustive and hierarchical Stock Inventories", | ||
844 | 23 | "version": "1.1", | ||
845 | 24 | "depends": ["stock_inventory_hierarchical", "stock_inventory_location"], | ||
846 | 25 | "auto_install": True, | ||
847 | 26 | "author": u"Numérigraphe", | ||
848 | 27 | "category": "Hidden", | ||
849 | 28 | "description": """ | ||
850 | 29 | Make exhaustive Inventories aware of their Sub-Inventories. | ||
851 | 30 | =========================================================== | ||
852 | 31 | |||
853 | 32 | This module allows an inventory to contain a general Location, | ||
854 | 33 | and it's sub-inventories to contain some of it's sub-Locations. | ||
855 | 34 | It will prevent you from setting the Inventories and sub-Inventories | ||
856 | 35 | in inconsistent status. | ||
857 | 36 | |||
858 | 37 | This module will be installed automatically if the modules | ||
859 | 38 | "stock_inventory_location" and "stock_inventory_hierarchical" are both | ||
860 | 39 | installed. | ||
861 | 40 | You must keep this module installed to ensure proper functioning. | ||
862 | 41 | |||
863 | 42 | """, | ||
864 | 43 | "data": [ | ||
865 | 44 | "inventory_hierarchical_location_view.xml", | ||
866 | 45 | "wizard/generate_inventory_view.xml", | ||
867 | 46 | ], | ||
868 | 47 | "test": ["tests/inventory_hierarchical_location_test.yml"], | ||
869 | 48 | "demo": ["inventory_hierarchical_location_demo.xml"], | ||
870 | 49 | } | ||
871 | 0 | 50 | ||
872 | === added directory 'stock_inventory_hierarchical_location/i18n' | |||
873 | === added file 'stock_inventory_hierarchical_location/i18n/fr.po' | |||
874 | --- stock_inventory_hierarchical_location/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
875 | +++ stock_inventory_hierarchical_location/i18n/fr.po 2014-07-01 11:47:18 +0000 | |||
876 | @@ -0,0 +1,164 @@ | |||
877 | 1 | # Translation of OpenERP Server. | ||
878 | 2 | # This file contains the translation of the following modules: | ||
879 | 3 | # * stock_inventory_hierarchical_location | ||
880 | 4 | # | ||
881 | 5 | msgid "" | ||
882 | 6 | msgstr "" | ||
883 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
884 | 8 | "Report-Msgid-Bugs-To: \n" | ||
885 | 9 | "POT-Creation-Date: 2014-07-01 11:35+0000\n" | ||
886 | 10 | "PO-Revision-Date: 2014-07-01 11:35+0000\n" | ||
887 | 11 | "Last-Translator: <>\n" | ||
888 | 12 | "Language-Team: \n" | ||
889 | 13 | "MIME-Version: 1.0\n" | ||
890 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
891 | 15 | "Content-Transfer-Encoding: \n" | ||
892 | 16 | "Plural-Forms: \n" | ||
893 | 17 | |||
894 | 18 | #. module: stock_inventory_hierarchical_location | ||
895 | 19 | #: view:stock.generate.inventory:0 | ||
896 | 20 | msgid "Cancel" | ||
897 | 21 | msgstr "Cancel" | ||
898 | 22 | |||
899 | 23 | #. module: stock_inventory_hierarchical_location | ||
900 | 24 | #: code:_description:0 | ||
901 | 25 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical_location.action_view_stock_generate_inventory | ||
902 | 26 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_generate_inventory | ||
903 | 27 | #: model:ir.ui.menu,name:stock_inventory_hierarchical_location.menu_action_stock_generate_inventory_form | ||
904 | 28 | #: view:stock.generate.inventory:0 | ||
905 | 29 | #, python-format | ||
906 | 30 | msgid "Generate Inventory" | ||
907 | 31 | msgstr "Générer l'inventaire" | ||
908 | 32 | |||
909 | 33 | #. module: stock_inventory_hierarchical_location | ||
910 | 34 | #: help:stock.generate.inventory,only_view:0 | ||
911 | 35 | msgid "If set, only inventory on view location can be created" | ||
912 | 36 | msgstr "Si coché, seuls les inventaires des emplacements vues seront créés." | ||
913 | 37 | |||
914 | 38 | #. module: stock_inventory_hierarchical_location | ||
915 | 39 | #: code:_description:0 | ||
916 | 40 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_fill_inventory | ||
917 | 41 | #, python-format | ||
918 | 42 | msgid "Import Inventory" | ||
919 | 43 | msgstr "Importer un inventaire" | ||
920 | 44 | |||
921 | 45 | #. module: stock_inventory_hierarchical_location | ||
922 | 46 | #: code:_description:0 | ||
923 | 47 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory | ||
924 | 48 | #, python-format | ||
925 | 49 | msgid "Inventory" | ||
926 | 50 | msgstr "Inventaire" | ||
927 | 51 | |||
928 | 52 | #. module: stock_inventory_hierarchical_location | ||
929 | 53 | #: code:addons/stock_inventory_hierarchical_location/wizard/generate_inventory.py:124 | ||
930 | 54 | #, python-format | ||
931 | 55 | msgid "Inventory generated" | ||
932 | 56 | msgstr "Inventaire généré" | ||
933 | 57 | |||
934 | 58 | #. module: stock_inventory_hierarchical_location | ||
935 | 59 | #: field:stock.generate.inventory,prefix_inv_name:0 | ||
936 | 60 | msgid "Inventory prefix" | ||
937 | 61 | msgstr "Préfixe de l'inventaire" | ||
938 | 62 | |||
939 | 63 | #. module: stock_inventory_hierarchical_location | ||
940 | 64 | #: field:stock.generate.inventory,level:0 | ||
941 | 65 | msgid "Level" | ||
942 | 66 | msgstr "Profondeur" | ||
943 | 67 | |||
944 | 68 | #. module: stock_inventory_hierarchical_location | ||
945 | 69 | #: sql_constraint:stock.generate.inventory:0 | ||
946 | 70 | msgid "Level must be positive!" | ||
947 | 71 | msgstr "La profondeur doit être positive!" | ||
948 | 72 | |||
949 | 73 | #. module: stock_inventory_hierarchical_location | ||
950 | 74 | #: field:stock.generate.inventory,location_id:0 | ||
951 | 75 | msgid "Location" | ||
952 | 76 | msgstr "Emplacement" | ||
953 | 77 | |||
954 | 78 | #. module: stock_inventory_hierarchical_location | ||
955 | 79 | #: code:addons/stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py:78 | ||
956 | 80 | #: code:addons/stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py:84 | ||
957 | 81 | #, python-format | ||
958 | 82 | msgid "No product in this location. Please select a location in the product form." | ||
959 | 83 | msgstr "" | ||
960 | 84 | "Aucun article dans cet emplacement. Veuillez choisir un emplacement dans le " | ||
961 | 85 | "formulaire produit." | ||
962 | 86 | |||
963 | 87 | #. module: stock_inventory_hierarchical_location | ||
964 | 88 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:43 | ||
965 | 89 | #, python-format | ||
966 | 90 | msgid "One of the parent inventories is not open." | ||
967 | 91 | msgstr "Un des inventaires pères n'est pas ouvert." | ||
968 | 92 | |||
969 | 93 | #. module: stock_inventory_hierarchical_location | ||
970 | 94 | #: field:stock.generate.inventory,only_view:0 | ||
971 | 95 | msgid "Only view" | ||
972 | 96 | msgstr "Vues seulement" | ||
973 | 97 | |||
974 | 98 | #. module: stock_inventory_hierarchical_location | ||
975 | 99 | #: help:stock.generate.inventory,prefix_inv_name:0 | ||
976 | 100 | msgid "Optional prefix for all created inventory" | ||
977 | 101 | msgstr "Préfixe facultatif ajouté devant les noms des inventaires créés" | ||
978 | 102 | |||
979 | 103 | #. module: stock_inventory_hierarchical_location | ||
980 | 104 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:65 | ||
981 | 105 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:79 | ||
982 | 106 | #, python-format | ||
983 | 107 | msgid "Some Sub-inventories are not confirmed." | ||
984 | 108 | msgstr "Au moins un sous-inventaire n'est pas confirmé." | ||
985 | 109 | |||
986 | 110 | #. module: stock_inventory_hierarchical_location | ||
987 | 111 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:84 | ||
988 | 112 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:98 | ||
989 | 113 | #, python-format | ||
990 | 114 | msgid "This location is not declared on the parent inventory\n" | ||
991 | 115 | "It cannot be added." | ||
992 | 116 | msgstr "Cet emplacement n'est pas déclaré dans l'inventaire parent\n" | ||
993 | 117 | "Vous ne pouvez pas l'ajouter." | ||
994 | 118 | |||
995 | 119 | #. module: stock_inventory_hierarchical_location | ||
996 | 120 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:42 | ||
997 | 121 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:64 | ||
998 | 122 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:78 | ||
999 | 123 | #, python-format | ||
1000 | 124 | msgid "Warning" | ||
1001 | 125 | msgstr "Attention" | ||
1002 | 126 | |||
1003 | 127 | #. module: stock_inventory_hierarchical_location | ||
1004 | 128 | #: code:addons/stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py:84 | ||
1005 | 129 | #, python-format | ||
1006 | 130 | msgid "Warning!" | ||
1007 | 131 | msgstr "Attention!" | ||
1008 | 132 | |||
1009 | 133 | #. module: stock_inventory_hierarchical_location | ||
1010 | 134 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:83 | ||
1011 | 135 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:97 | ||
1012 | 136 | #, python-format | ||
1013 | 137 | msgid "Warning: Wrong location" | ||
1014 | 138 | msgstr "Attention: emplacement incorrect" | ||
1015 | 139 | |||
1016 | 140 | #. module: stock_inventory_hierarchical_location | ||
1017 | 141 | #: help:stock.generate.inventory,level:0 | ||
1018 | 142 | msgid "Maximum number of intermediate sub-inventories between the main inventory and the smallest sub-inventory." | ||
1019 | 143 | msgstr "Nombre maximum de niveaux entre l'inventaire principal et le plus petit sous-inventaire." | ||
1020 | 144 | |||
1021 | 145 | #. module: stock_inventory_hierarchical_location | ||
1022 | 146 | #: view:stock.inventory:0 | ||
1023 | 147 | msgid "onchange_location_id(location_id)" | ||
1024 | 148 | msgstr "onchange_location_id(location_id)" | ||
1025 | 149 | |||
1026 | 150 | #. module: stock_inventory_hierarchical_location | ||
1027 | 151 | #: view:stock.generate.inventory:0 | ||
1028 | 152 | msgid "or" | ||
1029 | 153 | msgstr "ou" | ||
1030 | 154 | |||
1031 | 155 | #. module: stock_inventory_hierarchical_location | ||
1032 | 156 | #: view:stock.inventory:0 | ||
1033 | 157 | msgid "{'default_parent_id': active_id, 'default_exhaustive': exhaustive}" | ||
1034 | 158 | msgstr "{'default_parent_id': active_id, 'default_exhaustive': exhaustive}" | ||
1035 | 159 | |||
1036 | 160 | #. module: stock_inventory_hierarchical_location | ||
1037 | 161 | #: view:stock.inventory:0 | ||
1038 | 162 | msgid "{'readonly':[('parent_id', '!=', False)]}" | ||
1039 | 163 | msgstr "{'readonly':[('parent_id', '!=', False)]}" | ||
1040 | 164 | |||
1041 | 0 | 165 | ||
1042 | === added file 'stock_inventory_hierarchical_location/i18n/stock_inventory_hierarchical_location.pot' | |||
1043 | --- stock_inventory_hierarchical_location/i18n/stock_inventory_hierarchical_location.pot 1970-01-01 00:00:00 +0000 | |||
1044 | +++ stock_inventory_hierarchical_location/i18n/stock_inventory_hierarchical_location.pot 2014-07-01 11:47:18 +0000 | |||
1045 | @@ -0,0 +1,166 @@ | |||
1046 | 1 | # Translation of OpenERP Server. | ||
1047 | 2 | # This file contains the translation of the following modules: | ||
1048 | 3 | # * stock_inventory_hierarchical_location | ||
1049 | 4 | # | ||
1050 | 5 | msgid "" | ||
1051 | 6 | msgstr "" | ||
1052 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
1053 | 8 | "Report-Msgid-Bugs-To: \n" | ||
1054 | 9 | "POT-Creation-Date: 2014-07-01 11:32+0000\n" | ||
1055 | 10 | "PO-Revision-Date: 2014-07-01 11:32+0000\n" | ||
1056 | 11 | "Last-Translator: <>\n" | ||
1057 | 12 | "Language-Team: \n" | ||
1058 | 13 | "MIME-Version: 1.0\n" | ||
1059 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
1060 | 15 | "Content-Transfer-Encoding: \n" | ||
1061 | 16 | "Plural-Forms: \n" | ||
1062 | 17 | |||
1063 | 18 | #. module: stock_inventory_hierarchical_location | ||
1064 | 19 | #: view:stock.generate.inventory:0 | ||
1065 | 20 | msgid "Cancel" | ||
1066 | 21 | msgstr "" | ||
1067 | 22 | |||
1068 | 23 | #. module: stock_inventory_hierarchical_location | ||
1069 | 24 | #: code:_description:0 | ||
1070 | 25 | #: model:ir.actions.act_window,name:stock_inventory_hierarchical_location.action_view_stock_generate_inventory | ||
1071 | 26 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_generate_inventory | ||
1072 | 27 | #: model:ir.ui.menu,name:stock_inventory_hierarchical_location.menu_action_stock_generate_inventory_form | ||
1073 | 28 | #: view:stock.generate.inventory:0 | ||
1074 | 29 | #, python-format | ||
1075 | 30 | msgid "Generate Inventory" | ||
1076 | 31 | msgstr "" | ||
1077 | 32 | |||
1078 | 33 | #. module: stock_inventory_hierarchical_location | ||
1079 | 34 | #: view:stock.generate.inventory:0 | ||
1080 | 35 | msgid "Generate inventory" | ||
1081 | 36 | msgstr "" | ||
1082 | 37 | |||
1083 | 38 | #. module: stock_inventory_hierarchical_location | ||
1084 | 39 | #: help:stock.generate.inventory,only_view:0 | ||
1085 | 40 | msgid "If set, only inventory on view location can be created" | ||
1086 | 41 | msgstr "" | ||
1087 | 42 | |||
1088 | 43 | #. module: stock_inventory_hierarchical_location | ||
1089 | 44 | #: code:_description:0 | ||
1090 | 45 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_fill_inventory | ||
1091 | 46 | #, python-format | ||
1092 | 47 | msgid "Import Inventory" | ||
1093 | 48 | msgstr "" | ||
1094 | 49 | |||
1095 | 50 | #. module: stock_inventory_hierarchical_location | ||
1096 | 51 | #: code:_description:0 | ||
1097 | 52 | #: model:ir.model,name:stock_inventory_hierarchical_location.model_stock_inventory | ||
1098 | 53 | #, python-format | ||
1099 | 54 | msgid "Inventory" | ||
1100 | 55 | msgstr "" | ||
1101 | 56 | |||
1102 | 57 | #. module: stock_inventory_hierarchical_location | ||
1103 | 58 | #: code:addons/stock_inventory_hierarchical_location/wizard/generate_inventory.py:124 | ||
1104 | 59 | #, python-format | ||
1105 | 60 | msgid "Inventory generated" | ||
1106 | 61 | msgstr "" | ||
1107 | 62 | |||
1108 | 63 | #. module: stock_inventory_hierarchical_location | ||
1109 | 64 | #: field:stock.generate.inventory,prefix_inv_name:0 | ||
1110 | 65 | msgid "Inventory prefix" | ||
1111 | 66 | msgstr "" | ||
1112 | 67 | |||
1113 | 68 | #. module: stock_inventory_hierarchical_location | ||
1114 | 69 | #: field:stock.generate.inventory,level:0 | ||
1115 | 70 | msgid "Level" | ||
1116 | 71 | msgstr "" | ||
1117 | 72 | |||
1118 | 73 | #. module: stock_inventory_hierarchical_location | ||
1119 | 74 | #: sql_constraint:stock.generate.inventory:0 | ||
1120 | 75 | msgid "Level must be positive!" | ||
1121 | 76 | msgstr "" | ||
1122 | 77 | |||
1123 | 78 | #. module: stock_inventory_hierarchical_location | ||
1124 | 79 | #: field:stock.generate.inventory,location_id:0 | ||
1125 | 80 | msgid "Location" | ||
1126 | 81 | msgstr "" | ||
1127 | 82 | |||
1128 | 83 | #. module: stock_inventory_hierarchical_location | ||
1129 | 84 | #: code:addons/stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py:78 | ||
1130 | 85 | #: code:addons/stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py:84 | ||
1131 | 86 | #, python-format | ||
1132 | 87 | msgid "No product in this location. Please select a location in the product form." | ||
1133 | 88 | msgstr "" | ||
1134 | 89 | |||
1135 | 90 | #. module: stock_inventory_hierarchical_location | ||
1136 | 91 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:43 | ||
1137 | 92 | #, python-format | ||
1138 | 93 | msgid "One of the parent inventories is not open." | ||
1139 | 94 | msgstr "" | ||
1140 | 95 | |||
1141 | 96 | #. module: stock_inventory_hierarchical_location | ||
1142 | 97 | #: field:stock.generate.inventory,only_view:0 | ||
1143 | 98 | msgid "Only view" | ||
1144 | 99 | msgstr "" | ||
1145 | 100 | |||
1146 | 101 | #. module: stock_inventory_hierarchical_location | ||
1147 | 102 | #: help:stock.generate.inventory,prefix_inv_name:0 | ||
1148 | 103 | msgid "Optional prefix for all created inventory" | ||
1149 | 104 | msgstr "" | ||
1150 | 105 | |||
1151 | 106 | #. module: stock_inventory_hierarchical_location | ||
1152 | 107 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:65 | ||
1153 | 108 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:79 | ||
1154 | 109 | #, python-format | ||
1155 | 110 | msgid "Some Sub-inventories are not confirmed." | ||
1156 | 111 | msgstr "" | ||
1157 | 112 | |||
1158 | 113 | #. module: stock_inventory_hierarchical_location | ||
1159 | 114 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:84 | ||
1160 | 115 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:98 | ||
1161 | 116 | #, python-format | ||
1162 | 117 | msgid "This location is not declared on the parent inventory\n" | ||
1163 | 118 | "It cannot be added." | ||
1164 | 119 | msgstr "" | ||
1165 | 120 | |||
1166 | 121 | #. module: stock_inventory_hierarchical_location | ||
1167 | 122 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:42 | ||
1168 | 123 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:64 | ||
1169 | 124 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:78 | ||
1170 | 125 | #, python-format | ||
1171 | 126 | msgid "Warning" | ||
1172 | 127 | msgstr "" | ||
1173 | 128 | |||
1174 | 129 | #. module: stock_inventory_hierarchical_location | ||
1175 | 130 | #: code:addons/stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py:84 | ||
1176 | 131 | #, python-format | ||
1177 | 132 | msgid "Warning!" | ||
1178 | 133 | msgstr "" | ||
1179 | 134 | |||
1180 | 135 | #. module: stock_inventory_hierarchical_location | ||
1181 | 136 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:83 | ||
1182 | 137 | #: code:addons/stock_inventory_hierarchical_location/inventory_hierarchical_location.py:97 | ||
1183 | 138 | #, python-format | ||
1184 | 139 | msgid "Warning: Wrong location" | ||
1185 | 140 | msgstr "" | ||
1186 | 141 | |||
1187 | 142 | #. module: stock_inventory_hierarchical_location | ||
1188 | 143 | #: help:stock.generate.inventory,level:0 | ||
1189 | 144 | msgid "Maximum number of intermediate sub-inventories between the main inventory and the smallest sub-inventory." | ||
1190 | 145 | msgstr "" | ||
1191 | 146 | |||
1192 | 147 | #. module: stock_inventory_hierarchical_location | ||
1193 | 148 | #: view:stock.inventory:0 | ||
1194 | 149 | msgid "onchange_location_id(location_id)" | ||
1195 | 150 | msgstr "" | ||
1196 | 151 | |||
1197 | 152 | #. module: stock_inventory_hierarchical_location | ||
1198 | 153 | #: view:stock.generate.inventory:0 | ||
1199 | 154 | msgid "or" | ||
1200 | 155 | msgstr "" | ||
1201 | 156 | |||
1202 | 157 | #. module: stock_inventory_hierarchical_location | ||
1203 | 158 | #: view:stock.inventory:0 | ||
1204 | 159 | msgid "{'default_parent_id': active_id, 'default_exhaustive': exhaustive}" | ||
1205 | 160 | msgstr "" | ||
1206 | 161 | |||
1207 | 162 | #. module: stock_inventory_hierarchical_location | ||
1208 | 163 | #: view:stock.inventory:0 | ||
1209 | 164 | msgid "{'readonly':[('parent_id', '!=', False)]}" | ||
1210 | 165 | msgstr "" | ||
1211 | 166 | |||
1212 | 0 | 167 | ||
1213 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location.py' | |||
1214 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location.py 1970-01-01 00:00:00 +0000 | |||
1215 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location.py 2014-07-01 11:47:18 +0000 | |||
1216 | @@ -0,0 +1,102 @@ | |||
1217 | 1 | # -*- coding: utf-8 -*- | ||
1218 | 2 | ############################################################################## | ||
1219 | 3 | # | ||
1220 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1221 | 5 | # | ||
1222 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1223 | 7 | # it under the terms of the GNU General Public License as published by | ||
1224 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1225 | 9 | # (at your option) any later version. | ||
1226 | 10 | # | ||
1227 | 11 | # This program is distributed in the hope that it will be useful, | ||
1228 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1229 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1230 | 14 | # GNU General Public License for more details. | ||
1231 | 15 | # | ||
1232 | 16 | # You should have received a copy of the GNU General Public License | ||
1233 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1234 | 18 | # | ||
1235 | 19 | ############################################################################## | ||
1236 | 20 | |||
1237 | 21 | from openerp.osv import orm | ||
1238 | 22 | from openerp.tools.translate import _ | ||
1239 | 23 | |||
1240 | 24 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
1241 | 25 | |||
1242 | 26 | # Add the date to the list of fields we must propagate to children inventories | ||
1243 | 27 | from stock_inventory_hierarchical import PARENT_VALUES | ||
1244 | 28 | PARENT_VALUES.append('exhaustive') | ||
1245 | 29 | |||
1246 | 30 | |||
1247 | 31 | class HierarchicalExhInventory(orm.Model): | ||
1248 | 32 | """Add hierarchical structure features to exhaustive Inventories""" | ||
1249 | 33 | _inherit = 'stock.inventory' | ||
1250 | 34 | |||
1251 | 35 | def action_open(self, cr, uid, ids, context=None): | ||
1252 | 36 | """Open only if all the parents are Open.""" | ||
1253 | 37 | for inventory in self.browse(cr, uid, ids, context=context): | ||
1254 | 38 | while inventory.parent_id: | ||
1255 | 39 | inventory = inventory.parent_id | ||
1256 | 40 | if inventory.state != 'open': | ||
1257 | 41 | raise HierarchicalInventoryException( | ||
1258 | 42 | _('Warning'), | ||
1259 | 43 | _('One of the parent inventories is not open.')) | ||
1260 | 44 | return super(HierarchicalExhInventory, self).action_open( | ||
1261 | 45 | cr, uid, ids, context=context) | ||
1262 | 46 | |||
1263 | 47 | def get_missing_locations(self, cr, uid, ids, context=None): | ||
1264 | 48 | """Extend the list of inventories with their children""" | ||
1265 | 49 | ids = self.search( | ||
1266 | 50 | cr, uid, [('parent_id', 'child_of', ids)], context=context) | ||
1267 | 51 | missing_ids = super(HierarchicalExhInventory, | ||
1268 | 52 | self).get_missing_locations( | ||
1269 | 53 | cr, uid, ids, context=context) | ||
1270 | 54 | # Find the locations already included in sub-inventories | ||
1271 | 55 | inventories = self.browse(cr, uid, ids, context=context) | ||
1272 | 56 | subinv_location_ids = [sub.location_id.id | ||
1273 | 57 | for i in inventories | ||
1274 | 58 | for sub in i.inventory_ids] | ||
1275 | 59 | if not subinv_location_ids: | ||
1276 | 60 | return missing_ids | ||
1277 | 61 | # Extend to the children locations | ||
1278 | 62 | subinv_location_ids = set(self.pool['stock.location'].search( | ||
1279 | 63 | cr, uid, [ | ||
1280 | 64 | ('location_id', 'child_of', subinv_location_ids), | ||
1281 | 65 | ('usage', '=', 'internal')], context=context)) | ||
1282 | 66 | return list(set(missing_ids) - subinv_location_ids) | ||
1283 | 67 | |||
1284 | 68 | # TODO v8: probably only keep the state "done" | ||
1285 | 69 | def confirm_missing_locations(self, cr, uid, ids, context=None): | ||
1286 | 70 | """Do something only if children state are confirm or done.""" | ||
1287 | 71 | children_count = self.search( | ||
1288 | 72 | cr, uid, [('parent_id', 'child_of', ids), | ||
1289 | 73 | ('id', 'not in', ids), | ||
1290 | 74 | ('state', 'not in', ['confirm', 'done'])], | ||
1291 | 75 | context=context, count=True) | ||
1292 | 76 | if children_count > 0: | ||
1293 | 77 | raise HierarchicalInventoryException( | ||
1294 | 78 | _('Warning'), | ||
1295 | 79 | _('Some Sub-inventories are not confirmed.')) | ||
1296 | 80 | return super(HierarchicalExhInventory, | ||
1297 | 81 | self).confirm_missing_locations( | ||
1298 | 82 | cr, uid, ids, context=context) | ||
1299 | 83 | |||
1300 | 84 | def onchange_location_id(self, cr, uid, ids, location_id, context=None): | ||
1301 | 85 | """Check if location is a child of parent inventory location""" | ||
1302 | 86 | loc_obj = self.pool['stock.location'] | ||
1303 | 87 | for inventory in self.browse(cr, uid, ids, context=context): | ||
1304 | 88 | if inventory.parent_id: | ||
1305 | 89 | allowed_location_ids = loc_obj.search( | ||
1306 | 90 | cr, uid, [('location_id', 'child_of', | ||
1307 | 91 | inventory.parent_id.location_id.id)], | ||
1308 | 92 | context=context) | ||
1309 | 93 | if location_id not in allowed_location_ids: | ||
1310 | 94 | return { | ||
1311 | 95 | 'location_id': False, | ||
1312 | 96 | 'warning': { | ||
1313 | 97 | 'title': _('Warning: Wrong location'), | ||
1314 | 98 | 'message': _("This location is not declared on " | ||
1315 | 99 | "the parent inventory\n" | ||
1316 | 100 | "It cannot be added.")} | ||
1317 | 101 | } | ||
1318 | 102 | return {} | ||
1319 | 0 | 103 | ||
1320 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml' | |||
1321 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 1970-01-01 00:00:00 +0000 | |||
1322 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location_demo.xml 2014-07-01 11:47:18 +0000 | |||
1323 | @@ -0,0 +1,28 @@ | |||
1324 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1325 | 2 | <openerp> | ||
1326 | 3 | <data noupdate="0"> | ||
1327 | 4 | |||
1328 | 5 | <!-- Record inventories we can use in the tests. --> | ||
1329 | 6 | <!-- We need them in the demo data because test data is rolled back | ||
1330 | 7 | whenever an exception is raised. --> | ||
1331 | 8 | |||
1332 | 9 | <!-- Record a hierarchical exhaustive inventory --> | ||
1333 | 10 | <record id="parent_inventory" model="stock.inventory"> | ||
1334 | 11 | <field name="name">Hierarchical exhaustive inventory</field> | ||
1335 | 12 | <field name="state">draft</field> | ||
1336 | 13 | <field name="date">2020-04-15 00:00:00</field> | ||
1337 | 14 | <field name="exhaustive">True</field> | ||
1338 | 15 | <field name="location_id" model="stock.location" ref="stock.stock_location_stock"/> | ||
1339 | 16 | </record> | ||
1340 | 17 | <record id="child_1_id" model="stock.inventory"> | ||
1341 | 18 | <field name="name">Team A</field> | ||
1342 | 19 | <field name="parent_id" ref="parent_inventory"/> | ||
1343 | 20 | <field name="location_id" model="stock.location" ref="stock.stock_location_14"/> | ||
1344 | 21 | </record> | ||
1345 | 22 | <record id="child_2_id" model="stock.inventory"> | ||
1346 | 23 | <field name="name">Team B</field> | ||
1347 | 24 | <field name="parent_id" ref="parent_inventory"/> | ||
1348 | 25 | <field name="location_id" model="stock.location" ref="stock.stock_location_components"/> | ||
1349 | 26 | </record> | ||
1350 | 27 | </data> | ||
1351 | 28 | </openerp> | ||
1352 | 0 | 29 | ||
1353 | === added file 'stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml' | |||
1354 | --- stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml 1970-01-01 00:00:00 +0000 | |||
1355 | +++ stock_inventory_hierarchical_location/inventory_hierarchical_location_view.xml 2014-07-01 11:47:18 +0000 | |||
1356 | @@ -0,0 +1,37 @@ | |||
1357 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1358 | 2 | <openerp> | ||
1359 | 3 | <data> | ||
1360 | 4 | <record model="ir.ui.view" id="stock_inventory_hierarchical_location_form_view"> | ||
1361 | 5 | <field name="name">hierarchical.inventory.location.form</field> | ||
1362 | 6 | <field name="model">stock.inventory</field> | ||
1363 | 7 | <field name="inherit_id" ref="stock.view_inventory_form" /> | ||
1364 | 8 | <field name="arch" type="xml"> | ||
1365 | 9 | |||
1366 | 10 | <xpath expr="/form//field[@name='exhaustive']" position="attributes"> | ||
1367 | 11 | <attribute name="attrs">{'readonly':[('parent_id', '!=', False)]}</attribute> | ||
1368 | 12 | </xpath> | ||
1369 | 13 | |||
1370 | 14 | <xpath expr="/form//field[@name='location_id']" position="attributes"> | ||
1371 | 15 | <attribute name="on_change">onchange_location_id(location_id)</attribute> | ||
1372 | 16 | </xpath> | ||
1373 | 17 | |||
1374 | 18 | </field> | ||
1375 | 19 | </record> | ||
1376 | 20 | |||
1377 | 21 | <record model="ir.ui.view" id="stock_ihl_exhautive_form_view"> | ||
1378 | 22 | <field name="name">hierarchical.inventory.location.exhautive.form</field> | ||
1379 | 23 | <field name="model">stock.inventory</field> | ||
1380 | 24 | <field name="inherit_id" ref="stock_inventory_hierarchical.stock_inventory_hierarchical_form_view" /> | ||
1381 | 25 | <field name="arch" type="xml"> | ||
1382 | 26 | <xpath expr="//field[@name='inventory_ids']" position="attributes"> | ||
1383 | 27 | <attribute name="context">{'default_parent_id': active_id, 'default_exhaustive': exhaustive}</attribute> | ||
1384 | 28 | </xpath> | ||
1385 | 29 | </field> | ||
1386 | 30 | </record> | ||
1387 | 31 | |||
1388 | 32 | <!-- Show hierarchical exhaustive inventories by default --> | ||
1389 | 33 | <record id="stock.action_inventory_form" model="ir.actions.act_window"> | ||
1390 | 34 | <field name="context">{'full':'1', 'search_default_exhaustive':1, 'search_default_main_inventories':1}</field> | ||
1391 | 35 | </record> | ||
1392 | 36 | </data> | ||
1393 | 37 | </openerp> | ||
1394 | 0 | 38 | ||
1395 | === added directory 'stock_inventory_hierarchical_location/static' | |||
1396 | === added directory 'stock_inventory_hierarchical_location/static/src' | |||
1397 | === added directory 'stock_inventory_hierarchical_location/static/src/img' | |||
1398 | === added file 'stock_inventory_hierarchical_location/static/src/img/icon.png' | |||
1399 | 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-07-01 11:47:18 +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-07-01 11:47:18 +0000 differ |
1400 | === added directory 'stock_inventory_hierarchical_location/tests' | |||
1401 | === added file 'stock_inventory_hierarchical_location/tests/__init__.py' | |||
1402 | --- stock_inventory_hierarchical_location/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
1403 | +++ stock_inventory_hierarchical_location/tests/__init__.py 2014-07-01 11:47:18 +0000 | |||
1404 | @@ -0,0 +1,39 @@ | |||
1405 | 1 | # -*- coding: utf-8 -*- | ||
1406 | 2 | # | ||
1407 | 3 | # | ||
1408 | 4 | # Authors: Laetitia Gangloff | ||
1409 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1410 | 6 | # All Rights Reserved | ||
1411 | 7 | # | ||
1412 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1413 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1414 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1415 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1416 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1417 | 13 | # Service Company. | ||
1418 | 14 | # | ||
1419 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1420 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1421 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1422 | 18 | # License, or (at your option) any later version. | ||
1423 | 19 | # | ||
1424 | 20 | # This program is distributed in the hope that it will be useful, | ||
1425 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1426 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1427 | 23 | # GNU Affero General Public License for more details. | ||
1428 | 24 | # | ||
1429 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1430 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1431 | 27 | # | ||
1432 | 28 | # | ||
1433 | 29 | |||
1434 | 30 | import fill_inventory_test | ||
1435 | 31 | |||
1436 | 32 | fast_suite = [ | ||
1437 | 33 | ] | ||
1438 | 34 | |||
1439 | 35 | checks = [ | ||
1440 | 36 | fill_inventory_test, | ||
1441 | 37 | ] | ||
1442 | 38 | |||
1443 | 39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1444 | 0 | 40 | ||
1445 | === added file 'stock_inventory_hierarchical_location/tests/fill_inventory_test.py' | |||
1446 | --- stock_inventory_hierarchical_location/tests/fill_inventory_test.py 1970-01-01 00:00:00 +0000 | |||
1447 | +++ stock_inventory_hierarchical_location/tests/fill_inventory_test.py 2014-07-01 11:47:18 +0000 | |||
1448 | @@ -0,0 +1,118 @@ | |||
1449 | 1 | # -*- coding: utf-8 -*- | ||
1450 | 2 | # | ||
1451 | 3 | # | ||
1452 | 4 | # Authors: Laetitia Gangloff | ||
1453 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1454 | 6 | # All Rights Reserved | ||
1455 | 7 | # | ||
1456 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1457 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1458 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1459 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1460 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1461 | 13 | # Service Company. | ||
1462 | 14 | # | ||
1463 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1464 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1465 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1466 | 18 | # License, or (at your option) any later version. | ||
1467 | 19 | # | ||
1468 | 20 | # This program is distributed in the hope that it will be useful, | ||
1469 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1470 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1471 | 23 | # GNU Affero General Public License for more details. | ||
1472 | 24 | # | ||
1473 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1474 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1475 | 27 | # | ||
1476 | 28 | # | ||
1477 | 29 | |||
1478 | 30 | import openerp.tests.common as common | ||
1479 | 31 | |||
1480 | 32 | DB = common.DB | ||
1481 | 33 | ADMIN_USER_ID = common.ADMIN_USER_ID | ||
1482 | 34 | |||
1483 | 35 | |||
1484 | 36 | class fill_inventory_test(common.TransactionCase): | ||
1485 | 37 | |||
1486 | 38 | def setUp(self): | ||
1487 | 39 | super(fill_inventory_test, self).setUp() | ||
1488 | 40 | |||
1489 | 41 | def test_missing_location(self): | ||
1490 | 42 | """ | ||
1491 | 43 | Test that when confirm a parent inventory, the child location are not in the confirmation result | ||
1492 | 44 | """ | ||
1493 | 45 | parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory') | ||
1494 | 46 | self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id]) | ||
1495 | 47 | # confirm shelf 1 inventory | ||
1496 | 48 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id') | ||
1497 | 49 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1498 | 50 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1499 | 51 | self.assertEqual(len(missing_location), 1, "1 missing location should be find, because the inventory is empty") | ||
1500 | 52 | wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]}) | ||
1501 | 53 | self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1502 | 54 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1503 | 55 | self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is confirmed") | ||
1504 | 56 | # confirm shelf 2 inventory | ||
1505 | 57 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id') | ||
1506 | 58 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1507 | 59 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1508 | 60 | self.assertEqual(len(missing_location), 1, "1 missing location should be fine, because the inventory is empty") | ||
1509 | 61 | self.registry('stock.inventory.line').create(self.cr, self.uid, {'product_id': self.ref('product.product_product_7'), | ||
1510 | 62 | 'product_uom': self.ref('product.product_uom_unit'), | ||
1511 | 63 | 'company_id': self.ref('base.main_company'), | ||
1512 | 64 | 'inventory_id': inventory_id, | ||
1513 | 65 | 'product_qty': 18.0, | ||
1514 | 66 | 'location_id': self.ref('stock.stock_location_14')}) | ||
1515 | 67 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [inventory_id]) | ||
1516 | 68 | self.assertEqual(len(missing_location), 0, "No missing location should be find, because the inventory is filled") | ||
1517 | 69 | wizard_id = self.registry('stock.inventory.uninventoried.locations').create(self.cr, self.uid, {}, context={'active_ids': [inventory_id]}) | ||
1518 | 70 | wizard = self.registry('stock.inventory.uninventoried.locations').browse(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1519 | 71 | self.assertEqual(len(wizard.location_ids), 0, "The wizard should not contain any lines but contains %s." % wizard.location_ids) | ||
1520 | 72 | self.registry('stock.inventory.uninventoried.locations').confirm_uninventoried_locations(self.cr, self.uid, wizard_id, context={'active_ids': [inventory_id]}) | ||
1521 | 73 | # confirm parent inventory | ||
1522 | 74 | missing_location = self.registry('stock.inventory').get_missing_locations(self.cr, self.uid, [parent_inventory_id]) | ||
1523 | 75 | self.assertEqual(len(missing_location), 1, "Only 1 missing location should be find, because there is some location in child inventory") | ||
1524 | 76 | |||
1525 | 77 | def test_fill_inventory(self): | ||
1526 | 78 | """ | ||
1527 | 79 | Test that when fill a parent inventory, the child location are not in the result | ||
1528 | 80 | """ | ||
1529 | 81 | parent_inventory_id = self.ref('stock_inventory_hierarchical_location.parent_inventory') | ||
1530 | 82 | self.registry('stock.inventory').action_open(self.cr, self.uid, [parent_inventory_id]) | ||
1531 | 83 | # confirm shelf 1 inventory | ||
1532 | 84 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_2_id') | ||
1533 | 85 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1534 | 86 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_components'), | ||
1535 | 87 | 'recursive': True, | ||
1536 | 88 | 'exhaustive': True, | ||
1537 | 89 | 'set_stock_zero': True}, context={'active_ids': [inventory_id]}) | ||
1538 | 90 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]}) | ||
1539 | 91 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)]) | ||
1540 | 92 | self.assertEqual(len(inventory_line_ids), 12, "12 inventory line is fount after filling inventory") | ||
1541 | 93 | # confirm shelf 2 inventory | ||
1542 | 94 | inventory_id = self.ref('stock_inventory_hierarchical_location.child_1_id') | ||
1543 | 95 | self.registry('stock.inventory').action_open(self.cr, self.uid, [inventory_id]) | ||
1544 | 96 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_14'), | ||
1545 | 97 | 'recursive': True, | ||
1546 | 98 | 'exhaustive': True, | ||
1547 | 99 | 'set_stock_zero': True}, context={'active_ids': [inventory_id]}) | ||
1548 | 100 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [inventory_id]}) | ||
1549 | 101 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', inventory_id)]) | ||
1550 | 102 | self.assertEqual(len(inventory_line_ids), 4, "1 inventory line is fount after filling inventory") | ||
1551 | 103 | # confirm parent inventory | ||
1552 | 104 | wizard_id = self.registry('stock.fill.inventory').create(self.cr, self.uid, {'location_id': self.ref('stock.stock_location_stock'), | ||
1553 | 105 | 'recursive': True, | ||
1554 | 106 | 'exhaustive': True, | ||
1555 | 107 | 'set_stock_zero': True}, context={'active_ids': [parent_inventory_id]}) | ||
1556 | 108 | try: | ||
1557 | 109 | self.registry('stock.fill.inventory').fill_inventory(self.cr, self.uid, [wizard_id], context={'active_ids': [parent_inventory_id]}) | ||
1558 | 110 | except Exception, e: | ||
1559 | 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.''") | ||
1560 | 112 | exception_happened = True | ||
1561 | 113 | pass | ||
1562 | 114 | self.assertTrue(exception_happened) | ||
1563 | 115 | inventory_line_ids = self.registry('stock.inventory.line').search(self.cr, self.uid, [('inventory_id', '=', parent_inventory_id)]) | ||
1564 | 116 | self.assertEqual(len(inventory_line_ids), 0, "No inventory line is fount after filling inventory") | ||
1565 | 117 | |||
1566 | 118 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1567 | 0 | 119 | ||
1568 | === added file 'stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml' | |||
1569 | --- stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml 1970-01-01 00:00:00 +0000 | |||
1570 | +++ stock_inventory_hierarchical_location/tests/inventory_hierarchical_location_test.yml 2014-07-01 11:47:18 +0000 | |||
1571 | @@ -0,0 +1,56 @@ | |||
1572 | 1 | - | ||
1573 | 2 | Check that the exhaustive field of parent inventory has been propagated to children. | ||
1574 | 3 | - | ||
1575 | 4 | !python {model: stock.inventory}: | | ||
1576 | 5 | exhaustive = self.read(cr, uid, [ref("child_1_id")], ['exhaustive'])[0]['exhaustive'] | ||
1577 | 6 | assert exhaustive, "Exhaustive field not propagated to child inventory" | ||
1578 | 7 | |||
1579 | 8 | - | ||
1580 | 9 | Check that I can't open child inventory while parent inventory is open. | ||
1581 | 10 | - | ||
1582 | 11 | !python {model: stock.inventory}: | | ||
1583 | 12 | from stock_inventory_hierarchical import HierarchicalInventoryException | ||
1584 | 13 | parent_state = self.read(cr, uid, [ref("parent_inventory")], ['state'])[0]['state'] | ||
1585 | 14 | assert parent_state == 'draft', "Parent inventory in state '%s'. It should be 'draft'" % parent_state | ||
1586 | 15 | try: | ||
1587 | 16 | self.action_open(cr, uid, [ref("child_1_id")]) | ||
1588 | 17 | except HierarchicalInventoryException as e: | ||
1589 | 18 | log("Good ! The Inventory could not be opened: %s" % e) | ||
1590 | 19 | child_1_state = self.read(cr, uid, [ref("child_1_id")], ['state'])[0]['state'] | ||
1591 | 20 | assert child_1_state == 'draft', "Child inventory 1 have '%s' state. It should be 'draft'" % child_1_state | ||
1592 | 21 | |||
1593 | 22 | - | ||
1594 | 23 | I will check that the function get_missing_locations return some locations. | ||
1595 | 24 | - | ||
1596 | 25 | !python {model: stock.inventory}: | | ||
1597 | 26 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('parent_inventory')], context=context) | ||
1598 | 27 | assert len(missing_loc_ids)==3, "get_missing_locations did not return any ID." | ||
1599 | 28 | |||
1600 | 29 | - | ||
1601 | 30 | I will fill the inventory and check that the function get_missing_locations return no locations. | ||
1602 | 31 | Adding 17” LCD Monitor. | ||
1603 | 32 | - | ||
1604 | 33 | !record {model: stock.inventory.line, id: lines_inventory_location_pc1}: | ||
1605 | 34 | product_id: product.product_product_7 | ||
1606 | 35 | product_uom: product.product_uom_unit | ||
1607 | 36 | company_id: base.main_company | ||
1608 | 37 | inventory_id: child_1_id | ||
1609 | 38 | product_qty: 18.0 | ||
1610 | 39 | location_id: stock.stock_location_14 | ||
1611 | 40 | |||
1612 | 41 | - | ||
1613 | 42 | Adding USB Keyboard, QWERTY. | ||
1614 | 43 | - | ||
1615 | 44 | !record {model: stock.inventory.line, id: lines_inventory_location_pc3}: | ||
1616 | 45 | product_id: product.product_product_8 | ||
1617 | 46 | product_uom: product.product_uom_unit | ||
1618 | 47 | company_id: base.main_company | ||
1619 | 48 | inventory_id: child_2_id | ||
1620 | 49 | product_qty: 5.0 | ||
1621 | 50 | location_id: stock.stock_location_components | ||
1622 | 51 | |||
1623 | 52 | - | ||
1624 | 53 | !python {model: stock.inventory}: | | ||
1625 | 54 | |||
1626 | 55 | missing_loc_ids = self.get_missing_locations(cr, uid, [ref('parent_inventory')], context=context) | ||
1627 | 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) | ||
1628 | 0 | 57 | ||
1629 | === added directory 'stock_inventory_hierarchical_location/wizard' | |||
1630 | === added file 'stock_inventory_hierarchical_location/wizard/__init__.py' | |||
1631 | --- stock_inventory_hierarchical_location/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
1632 | +++ stock_inventory_hierarchical_location/wizard/__init__.py 2014-07-01 11:47:18 +0000 | |||
1633 | @@ -0,0 +1,22 @@ | |||
1634 | 1 | # -*- coding: utf-8 -*- | ||
1635 | 2 | ############################################################################## | ||
1636 | 3 | # | ||
1637 | 4 | # This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved. | ||
1638 | 5 | # | ||
1639 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1640 | 7 | # it under the terms of the GNU General Public License as published by | ||
1641 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
1642 | 9 | # (at your option) any later version. | ||
1643 | 10 | # | ||
1644 | 11 | # This program is distributed in the hope that it will be useful, | ||
1645 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1646 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1647 | 14 | # GNU General Public License for more details. | ||
1648 | 15 | # | ||
1649 | 16 | # You should have received a copy of the GNU General Public License | ||
1650 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1651 | 18 | # | ||
1652 | 19 | ############################################################################## | ||
1653 | 20 | |||
1654 | 21 | from . import stock_fill_location_inventory | ||
1655 | 22 | from . import generate_inventory | ||
1656 | 0 | 23 | ||
1657 | === added file 'stock_inventory_hierarchical_location/wizard/generate_inventory.py' | |||
1658 | --- stock_inventory_hierarchical_location/wizard/generate_inventory.py 1970-01-01 00:00:00 +0000 | |||
1659 | +++ stock_inventory_hierarchical_location/wizard/generate_inventory.py 2014-07-01 11:47:18 +0000 | |||
1660 | @@ -0,0 +1,134 @@ | |||
1661 | 1 | # -*- coding: utf-8 -*- | ||
1662 | 2 | # | ||
1663 | 3 | # | ||
1664 | 4 | # Authors: Laetitia Gangloff | ||
1665 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1666 | 6 | # All Rights Reserved | ||
1667 | 7 | # | ||
1668 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1669 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1670 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1671 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1672 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1673 | 13 | # Service Company. | ||
1674 | 14 | # | ||
1675 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1676 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1677 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1678 | 18 | # License, or (at your option) any later version. | ||
1679 | 19 | # | ||
1680 | 20 | # This program is distributed in the hope that it will be useful, | ||
1681 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1682 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1683 | 23 | # GNU Affero General Public License for more details. | ||
1684 | 24 | # | ||
1685 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1686 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1687 | 27 | # | ||
1688 | 28 | # | ||
1689 | 29 | |||
1690 | 30 | from openerp.osv import fields, orm | ||
1691 | 31 | from openerp.tools.translate import _ | ||
1692 | 32 | |||
1693 | 33 | |||
1694 | 34 | class GenerateInventoryWizard(orm.TransientModel): | ||
1695 | 35 | """ This wizard generate an inventory and all related sub-inventories for the specified location and level | ||
1696 | 36 | Example: location = Stock / level = 1 => 1 inventory on Stock (similar to create) | ||
1697 | 37 | location = Stock / level = 2 => 1 inventory on Stock, 1 sub-inventory on Shelf1, 1 sub-inventory on Shelf2 | ||
1698 | 38 | """ | ||
1699 | 39 | |||
1700 | 40 | _name = "stock.generate.inventory" | ||
1701 | 41 | _description = "Generate Inventory" | ||
1702 | 42 | |||
1703 | 43 | _columns = { | ||
1704 | 44 | 'prefix_inv_name': fields.char('Inventory prefix', help="Optional prefix for all created inventory"), | ||
1705 | 45 | 'location_id': fields.many2one('stock.location', 'Location', required=True), | ||
1706 | 46 | 'level': fields.integer("Level", help="Maximum number of intermediate sub-inventories between the main inventory and the smallest sub-inventory."), | ||
1707 | 47 | 'only_view': fields.boolean('Only view', help="If set, only inventory on view location can be created"), | ||
1708 | 48 | } | ||
1709 | 49 | |||
1710 | 50 | def _default_location(self, cr, uid, ids, context=None): | ||
1711 | 51 | """Default stock location | ||
1712 | 52 | |||
1713 | 53 | @return: id of the stock location of the first warehouse of the | ||
1714 | 54 | default company""" | ||
1715 | 55 | location_id = False | ||
1716 | 56 | company_id = self.pool['res.company']._company_default_get( | ||
1717 | 57 | cr, uid, 'stock.warehouse', context=context) | ||
1718 | 58 | warehouse_id = self.pool['stock.warehouse'].search( | ||
1719 | 59 | cr, uid, [('company_id', '=', company_id)], limit=1) | ||
1720 | 60 | if warehouse_id: | ||
1721 | 61 | location_id = self.pool['stock.warehouse'].read( | ||
1722 | 62 | cr, uid, warehouse_id[0], ['lot_stock_id'])['lot_stock_id'][0] | ||
1723 | 63 | return location_id | ||
1724 | 64 | |||
1725 | 65 | _defaults = { | ||
1726 | 66 | 'location_id': _default_location, | ||
1727 | 67 | 'level': 1, | ||
1728 | 68 | 'only_view': True, | ||
1729 | 69 | } | ||
1730 | 70 | |||
1731 | 71 | _sql_constraints = [ | ||
1732 | 72 | ('level', 'CHECK (level>0)', 'Level must be positive!'), | ||
1733 | 73 | ] | ||
1734 | 74 | |||
1735 | 75 | def _create_subinventory(self, cr, uid, inventory_ids, prefix_inv_name, only_view, context): | ||
1736 | 76 | new_inventory_ids = [] | ||
1737 | 77 | for inventory_id in inventory_ids: | ||
1738 | 78 | location_id = self.pool['stock.inventory'].read(cr, uid, inventory_id, ['location_id'], context=context)['location_id'][0] | ||
1739 | 79 | domain = [('location_id', '=', location_id)] | ||
1740 | 80 | if only_view: | ||
1741 | 81 | domain.append(('usage', '=', 'view')) | ||
1742 | 82 | location_ids = self.pool['stock.location'].search(cr, uid, domain, context=context) | ||
1743 | 83 | for location_id in location_ids: | ||
1744 | 84 | location_name = self.pool['stock.location'].read(cr, uid, location_id, ['name'], context=context)['name'] | ||
1745 | 85 | new_inventory_ids.append(self.pool['stock.inventory'].create(cr, uid, {'name': prefix_inv_name + location_name, | ||
1746 | 86 | 'exhaustive': True, | ||
1747 | 87 | 'location_id': location_id, | ||
1748 | 88 | 'parent_id': inventory_id}, context=context)) | ||
1749 | 89 | return new_inventory_ids | ||
1750 | 90 | |||
1751 | 91 | def generate_inventory(self, cr, uid, ids, context=None): | ||
1752 | 92 | """ Generate inventory and sub-inventories for specified location and level | ||
1753 | 93 | |||
1754 | 94 | @param self: The object pointer. | ||
1755 | 95 | @param cr: A database cursor | ||
1756 | 96 | @param uid: ID of the user currently logged in | ||
1757 | 97 | @param ids: the ID or list of IDs if we want more than one | ||
1758 | 98 | @param context: A standard dictionary | ||
1759 | 99 | @return: | ||
1760 | 100 | """ | ||
1761 | 101 | if context is None: | ||
1762 | 102 | context = {} | ||
1763 | 103 | |||
1764 | 104 | if ids and len(ids): | ||
1765 | 105 | ids = ids[0] | ||
1766 | 106 | else: | ||
1767 | 107 | return {'type': 'ir.actions.act_window_close'} | ||
1768 | 108 | generate_inventory = self.browse(cr, uid, ids, context=context) | ||
1769 | 109 | # create first level inventory | ||
1770 | 110 | prefix_inv_name = generate_inventory.prefix_inv_name or '' | ||
1771 | 111 | location_id = generate_inventory.location_id.id | ||
1772 | 112 | only_view = generate_inventory.only_view | ||
1773 | 113 | parent_inventory_id = self.pool['stock.inventory'].create(cr, uid, {'name': prefix_inv_name + generate_inventory.location_id.name, | ||
1774 | 114 | 'exhaustive': True, | ||
1775 | 115 | 'location_id': location_id}, context=context) | ||
1776 | 116 | |||
1777 | 117 | inventory_ids = [parent_inventory_id] | ||
1778 | 118 | for i in range(1, generate_inventory.level): | ||
1779 | 119 | inventory_ids = self._create_subinventory(cr, uid, inventory_ids, prefix_inv_name, only_view, context) | ||
1780 | 120 | |||
1781 | 121 | mod_obj = self.pool['ir.model.data'] | ||
1782 | 122 | result = mod_obj.get_object_reference(cr, uid, 'stock', 'view_inventory_form') | ||
1783 | 123 | view_id = result and result[1] or False | ||
1784 | 124 | return {'name': _('Inventory generated'), | ||
1785 | 125 | 'view_mode': 'form', | ||
1786 | 126 | 'view_type': 'form', | ||
1787 | 127 | 'res_model': 'stock.inventory', | ||
1788 | 128 | 'type': 'ir.actions.act_window', | ||
1789 | 129 | 'view_id': view_id, | ||
1790 | 130 | 'res_id': int(parent_inventory_id), | ||
1791 | 131 | } | ||
1792 | 132 | |||
1793 | 133 | |||
1794 | 134 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1795 | 0 | 135 | ||
1796 | === added file 'stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml' | |||
1797 | --- stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml 1970-01-01 00:00:00 +0000 | |||
1798 | +++ stock_inventory_hierarchical_location/wizard/generate_inventory_view.xml 2014-07-01 11:47:18 +0000 | |||
1799 | @@ -0,0 +1,42 @@ | |||
1800 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1801 | 2 | <openerp> | ||
1802 | 3 | <data> | ||
1803 | 4 | <record id="view_stock_generate_inventory" model="ir.ui.view"> | ||
1804 | 5 | <field name="name">Generate Inventory</field> | ||
1805 | 6 | <field name="model">stock.generate.inventory</field> | ||
1806 | 7 | <field name="arch" type="xml"> | ||
1807 | 8 | <form string="Generate Inventory" version="7.0"> | ||
1808 | 9 | <separator string="Generate Inventory"/> | ||
1809 | 10 | <group> | ||
1810 | 11 | <field name="prefix_inv_name"/> | ||
1811 | 12 | <field name="location_id"/> | ||
1812 | 13 | <field name="only_view"/> | ||
1813 | 14 | <field name="level"/> | ||
1814 | 15 | </group> | ||
1815 | 16 | <footer> | ||
1816 | 17 | <button name="generate_inventory" string="Generate Inventory" type="object" class="oe_highlight"/> | ||
1817 | 18 | or | ||
1818 | 19 | <button string="Cancel" class="oe_link" special="cancel" /> | ||
1819 | 20 | </footer> | ||
1820 | 21 | </form> | ||
1821 | 22 | </field> | ||
1822 | 23 | </record> | ||
1823 | 24 | |||
1824 | 25 | <record id="action_view_stock_generate_inventory" model="ir.actions.act_window"> | ||
1825 | 26 | <field name="name">Generate Inventory</field> | ||
1826 | 27 | <field name="type">ir.actions.act_window</field> | ||
1827 | 28 | <field name="res_model">stock.generate.inventory</field> | ||
1828 | 29 | <field name="view_type">form</field> | ||
1829 | 30 | <field name="view_mode">form</field> | ||
1830 | 31 | <field name="view_id" ref="view_stock_generate_inventory"/> | ||
1831 | 32 | <field name="target">new</field> | ||
1832 | 33 | </record> | ||
1833 | 34 | |||
1834 | 35 | <menuitem action="action_view_stock_generate_inventory" | ||
1835 | 36 | id="menu_action_stock_generate_inventory_form" | ||
1836 | 37 | parent="stock.menu_stock_inventory_control" | ||
1837 | 38 | sequence="20" | ||
1838 | 39 | groups="stock.group_locations"/> | ||
1839 | 40 | |||
1840 | 41 | </data> | ||
1841 | 42 | </openerp> | ||
1842 | 0 | 43 | ||
1843 | === added file 'stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py' | |||
1844 | --- stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 1970-01-01 00:00:00 +0000 | |||
1845 | +++ stock_inventory_hierarchical_location/wizard/stock_fill_location_inventory.py 2014-07-01 11:47:18 +0000 | |||
1846 | @@ -0,0 +1,89 @@ | |||
1847 | 1 | # -*- coding: utf-8 -*- | ||
1848 | 2 | # | ||
1849 | 3 | # | ||
1850 | 4 | # Authors: Laetitia Gangloff | ||
1851 | 5 | # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) | ||
1852 | 6 | # All Rights Reserved | ||
1853 | 7 | # | ||
1854 | 8 | # WARNING: This program as such is intended to be used by professional | ||
1855 | 9 | # programmers who take the whole responsibility of assessing all potential | ||
1856 | 10 | # consequences resulting from its eventual inadequacies and bugs. | ||
1857 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
1858 | 12 | # guarantees and support are strongly advised to contact a Free Software | ||
1859 | 13 | # Service Company. | ||
1860 | 14 | # | ||
1861 | 15 | # This program is free software: you can redistribute it and/or modify | ||
1862 | 16 | # it under the terms of the GNU Affero General Public License as | ||
1863 | 17 | # published by the Free Software Foundation, either version 3 of the | ||
1864 | 18 | # License, or (at your option) any later version. | ||
1865 | 19 | # | ||
1866 | 20 | # This program is distributed in the hope that it will be useful, | ||
1867 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1868 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1869 | 23 | # GNU Affero General Public License for more details. | ||
1870 | 24 | # | ||
1871 | 25 | # You should have received a copy of the GNU Affero General Public License | ||
1872 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1873 | 27 | # | ||
1874 | 28 | # | ||
1875 | 29 | |||
1876 | 30 | from openerp.osv import orm, osv | ||
1877 | 31 | from openerp.tools.translate import _ | ||
1878 | 32 | |||
1879 | 33 | |||
1880 | 34 | class FillInventoryWizard(orm.TransientModel): | ||
1881 | 35 | """If inventory as sub inventories, do not fill with sub inventories location""" | ||
1882 | 36 | _inherit = 'stock.fill.inventory' | ||
1883 | 37 | |||
1884 | 38 | def fill_inventory(self, cr, uid, ids, context=None): | ||
1885 | 39 | """ To Import stock inventory according to products available in the location and not already in a sub inventory | ||
1886 | 40 | |||
1887 | 41 | We split fill_inventory on many fill_inventory (one for each location) | ||
1888 | 42 | @param self: The object pointer. | ||
1889 | 43 | @param cr: A database cursor | ||
1890 | 44 | @param uid: ID of the user currently logged in | ||
1891 | 45 | @param ids: the ID or list of IDs if we want more than one | ||
1892 | 46 | @param context: A standard dictionary | ||
1893 | 47 | @return: | ||
1894 | 48 | """ | ||
1895 | 49 | if context is None: | ||
1896 | 50 | context = {} | ||
1897 | 51 | |||
1898 | 52 | if ids and len(ids): | ||
1899 | 53 | ids = ids[0] | ||
1900 | 54 | else: | ||
1901 | 55 | return {'type': 'ir.actions.act_window_close'} | ||
1902 | 56 | fill_inventory = self.browse(cr, uid, ids, context=context) | ||
1903 | 57 | if fill_inventory.recursive and fill_inventory.exhaustive: | ||
1904 | 58 | exclude_location_ids = [] | ||
1905 | 59 | for i in self.pool['stock.inventory'].browse(cr, uid, context['active_ids']): | ||
1906 | 60 | for sub_inventory in i.inventory_ids: | ||
1907 | 61 | # exclude these location | ||
1908 | 62 | exclude_location_ids.append(sub_inventory.location_id.id) | ||
1909 | 63 | domain = [('location_id', 'child_of', [fill_inventory.location_id.id])] | ||
1910 | 64 | if exclude_location_ids: | ||
1911 | 65 | domain.append('!') | ||
1912 | 66 | domain.append(('location_id', 'child_of', exclude_location_ids)) | ||
1913 | 67 | location_ids = self.pool['stock.location'].search(cr, uid, domain, | ||
1914 | 68 | order="id", | ||
1915 | 69 | context=context) | ||
1916 | 70 | all_in_exception = 0 | ||
1917 | 71 | for location_id in location_ids: | ||
1918 | 72 | try: | ||
1919 | 73 | super(FillInventoryWizard, self).fill_inventory(cr, uid, | ||
1920 | 74 | [self.copy(cr, uid, ids, {'location_id': location_id, | ||
1921 | 75 | 'recursive': False, }, context=context)], | ||
1922 | 76 | context=context) | ||
1923 | 77 | except osv.except_osv, e: | ||
1924 | 78 | if e.value == _('No product in this location. Please select a location in the product form.'): | ||
1925 | 79 | all_in_exception = all_in_exception + 1 | ||
1926 | 80 | pass | ||
1927 | 81 | else: | ||
1928 | 82 | raise e | ||
1929 | 83 | if all_in_exception == len(location_ids): | ||
1930 | 84 | raise osv.except_osv(_('Warning!'), _('No product in this location. Please select a location in the product form.')) | ||
1931 | 85 | return {'type': 'ir.actions.act_window_close'} | ||
1932 | 86 | else: | ||
1933 | 87 | return super(FillInventoryWizard, self).fill_inventory(cr, uid, [ids], context=context) | ||
1934 | 88 | |||
1935 | 89 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
Loic and I are improving this proposal WRT the 7.0 coding style and latest v8 updates.