Merge lp:~jgrandguillaume-c2c/stock-logistic-tracking/move-stock-barcode-reader into lp:stock-logistic-tracking/6.1
- move-stock-barcode-reader
- Merge into 6.1
Proposed by
Joël Grand-Guillaume @ camptocamp
Status: | Merged |
---|---|
Merged at revision: | 13 |
Proposed branch: | lp:~jgrandguillaume-c2c/stock-logistic-tracking/move-stock-barcode-reader |
Merge into: | lp:stock-logistic-tracking/6.1 |
Diff against target: |
1683 lines (+1614/-0) 12 files modified
stock_barcode_reader/__init__.py (+26/-0) stock_barcode_reader/__openerp__.py (+62/-0) stock_barcode_reader/acquisition_view.xml (+163/-0) stock_barcode_reader/data/acquisition_sequence.xml (+16/-0) stock_barcode_reader/i18n/fr.po (+283/-0) stock_barcode_reader/package_acquisition.py (+805/-0) stock_barcode_reader/security/ir.model.access.csv (+7/-0) stock_barcode_reader/stock.py (+56/-0) stock_barcode_reader/stock_view.xml (+31/-0) stock_barcode_reader/wizard/__init__.py (+24/-0) stock_barcode_reader/wizard/reference.py (+100/-0) stock_barcode_reader/wizard/reference_view.xml (+41/-0) |
To merge this branch: | bzr merge lp:~jgrandguillaume-c2c/stock-logistic-tracking/move-stock-barcode-reader |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Approve | ||
Alexandre Fayolle - camptocamp | Approve | ||
Review via email: mp+134874@code.launchpad.net |
Commit message
Description of the change
Move the stock-barcode-
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
review:
Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Approved and merged
In the same time, I merged lp:~stock-logistic-core-editors/stock-logistic-barcode/move-stock-basrcode-reader in lp:stock-logistic-barcode
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'stock_barcode_reader' | |||
2 | === added file 'stock_barcode_reader/__init__.py' | |||
3 | --- stock_barcode_reader/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ stock_barcode_reader/__init__.py 2012-11-19 11:44:21 +0000 | |||
5 | @@ -0,0 +1,26 @@ | |||
6 | 1 | # -*- coding: utf-8 -*- | ||
7 | 2 | ################################################################################# | ||
8 | 3 | # | ||
9 | 4 | # OpenERP, Open Source Management Solution | ||
10 | 5 | # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> | ||
11 | 6 | # | ||
12 | 7 | # This program is free software: you can redistribute it and/or modify | ||
13 | 8 | # it under the terms of the GNU General Public License as published by | ||
14 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
15 | 10 | # (at your option) any later version. | ||
16 | 11 | # | ||
17 | 12 | # This program is distributed in the hope that it will be useful, | ||
18 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | 15 | # GNU General Public License for more details. | ||
21 | 16 | # | ||
22 | 17 | # You should have received a copy of the GNU General Public License | ||
23 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
24 | 19 | # | ||
25 | 20 | ################################################################################# | ||
26 | 21 | |||
27 | 22 | import package_acquisition | ||
28 | 23 | import stock | ||
29 | 24 | import wizard | ||
30 | 25 | |||
31 | 26 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
32 | 0 | \ No newline at end of file | 27 | \ No newline at end of file |
33 | 1 | 28 | ||
34 | === added file 'stock_barcode_reader/__openerp__.py' | |||
35 | --- stock_barcode_reader/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
36 | +++ stock_barcode_reader/__openerp__.py 2012-11-19 11:44:21 +0000 | |||
37 | @@ -0,0 +1,62 @@ | |||
38 | 1 | # -*- coding: utf-8 -*- | ||
39 | 2 | ################################################################################# | ||
40 | 3 | # | ||
41 | 4 | # OpenERP, Open Source Management Solution | ||
42 | 5 | # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> | ||
43 | 6 | # | ||
44 | 7 | # This program is free software: you can redistribute it and/or modify | ||
45 | 8 | # it under the terms of the GNU General Public License as published by | ||
46 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
47 | 10 | # (at your option) any later version. | ||
48 | 11 | # | ||
49 | 12 | # This program is distributed in the hope that it will be useful, | ||
50 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
51 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
52 | 15 | # GNU General Public License for more details. | ||
53 | 16 | # | ||
54 | 17 | # You should have received a copy of the GNU General Public License | ||
55 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
56 | 19 | # | ||
57 | 20 | ################################################################################# | ||
58 | 21 | |||
59 | 22 | { | ||
60 | 23 | "name" : "Stock bar code reader", | ||
61 | 24 | "version" : "1.0", | ||
62 | 25 | "author" : "Julius Network Solutions", | ||
63 | 26 | "description" : """ | ||
64 | 27 | |||
65 | 28 | Presentation: | ||
66 | 29 | |||
67 | 30 | This module is an ergonomic wizard to fill in package. | ||
68 | 31 | Add menu for acquisition of package. | ||
69 | 32 | Add Button in Stock picking for start acquisition. | ||
70 | 33 | |||
71 | 34 | |||
72 | 35 | Configuration: | ||
73 | 36 | |||
74 | 37 | Warehouse>Configuration>Acquisition Setting | ||
75 | 38 | |||
76 | 39 | This module adds a submenu for acquisition setting with a field Barcode and Action type. | ||
77 | 40 | |||
78 | 41 | """, | ||
79 | 42 | "website" : "http://www.julius.fr", | ||
80 | 43 | "depends" : [ | ||
81 | 44 | "stock", | ||
82 | 45 | "stock_tracking_extended", | ||
83 | 46 | "stock_tracking_add_move", | ||
84 | 47 | ], | ||
85 | 48 | "category" : "Customs/Stock", | ||
86 | 49 | "init_xml" : [], | ||
87 | 50 | "demo_xml" : [], | ||
88 | 51 | "images" : ['images/Acquisition.png'], | ||
89 | 52 | "update_xml" : [ | ||
90 | 53 | 'wizard/reference_view.xml', | ||
91 | 54 | 'acquisition_view.xml', | ||
92 | 55 | 'stock_view.xml', | ||
93 | 56 | 'data/acquisition_sequence.xml', | ||
94 | 57 | "security/ir.model.access.csv", | ||
95 | 58 | ], | ||
96 | 59 | 'test': [], | ||
97 | 60 | 'installable': True, | ||
98 | 61 | 'active': False, | ||
99 | 62 | } | ||
100 | 0 | 63 | ||
101 | === added file 'stock_barcode_reader/acquisition_view.xml' | |||
102 | --- stock_barcode_reader/acquisition_view.xml 1970-01-01 00:00:00 +0000 | |||
103 | +++ stock_barcode_reader/acquisition_view.xml 2012-11-19 11:44:21 +0000 | |||
104 | @@ -0,0 +1,163 @@ | |||
105 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
106 | 2 | <openerp> | ||
107 | 3 | <data> | ||
108 | 4 | |||
109 | 5 | |||
110 | 6 | <act_window | ||
111 | 7 | context="{'default_type':'inventory', 'default_name': 'Scan Inventory '}" | ||
112 | 8 | id="inventory_acquisition_link_1" name="Inventory Acquisition" | ||
113 | 9 | res_model="acquisition.acquisition" | ||
114 | 10 | src_model="stock.inventory" | ||
115 | 11 | view_mode="form"/> | ||
116 | 12 | |||
117 | 13 | <!--<act_window domain="[('inventory_id', '=', active_id)]" | ||
118 | 14 | context="{'default_type':'move_stock', 'default_name': 'Scan Stock Move', 'default_move_stock_destination': location_id}" | ||
119 | 15 | id="move_stock_acquisition_link_2" name="Move Stock Acquisition" | ||
120 | 16 | res_model="acquisition.acquisition" | ||
121 | 17 | src_model="stock.inventory" | ||
122 | 18 | view_mode="form"/>--> | ||
123 | 19 | |||
124 | 20 | <report | ||
125 | 21 | auto="False" | ||
126 | 22 | id="account_invoices" | ||
127 | 23 | model="account.invoice" | ||
128 | 24 | name="account.invoice" | ||
129 | 25 | rml="voltalis_stock_picking_report_aeroo/report/pack_barcode_report.rml" | ||
130 | 26 | string="Invoices" | ||
131 | 27 | attachment_use="1" | ||
132 | 28 | multi="True"/> | ||
133 | 29 | |||
134 | 30 | <record model="ir.ui.view" id="view_stock_tracking_list"> | ||
135 | 31 | <field name="name">Acquisition.list.view</field> | ||
136 | 32 | <field name="model">acquisition.list</field> | ||
137 | 33 | <field name="type">tree</field> | ||
138 | 34 | <field name="arch" type="xml"> | ||
139 | 35 | <tree string="Acquisition list"> | ||
140 | 36 | <field name="barcode_id"/> | ||
141 | 37 | <field name="type"/> | ||
142 | 38 | <field name="quantity"/> | ||
143 | 39 | </tree> | ||
144 | 40 | </field> | ||
145 | 41 | </record> | ||
146 | 42 | |||
147 | 43 | <record model="ir.ui.view" id="view_stock_tracking_form"> | ||
148 | 44 | <field name="name">Acquisition.list.view</field> | ||
149 | 45 | <field name="model">acquisition.list</field> | ||
150 | 46 | <field name="type">form</field> | ||
151 | 47 | <field name="arch" type="xml"> | ||
152 | 48 | <tree string="Acquisition list"> | ||
153 | 49 | <field name="acquisition_id" readonly="True"/> | ||
154 | 50 | <field name="barcode_id" readonly="True"/> | ||
155 | 51 | <field name="type" readonly="True"/> | ||
156 | 52 | <field name="quantity" on_change="on_change_quantity(quantity,barcode_id)"/> | ||
157 | 53 | </tree> | ||
158 | 54 | </field> | ||
159 | 55 | </record> | ||
160 | 56 | |||
161 | 57 | <record model="ir.ui.view" id="view_stock_tracking_acquisition_form"> | ||
162 | 58 | <field name="name">Acquisition.view</field> | ||
163 | 59 | <field name="model">acquisition.acquisition</field> | ||
164 | 60 | <field name="type">form</field> | ||
165 | 61 | <field name="arch" type="xml"> | ||
166 | 62 | <form string="Acquisition name"> | ||
167 | 63 | <group width="400" height="100"> | ||
168 | 64 | <group col="4" colspan="4"> | ||
169 | 65 | <field name="name"/> | ||
170 | 66 | <field name="type"/> | ||
171 | 67 | <field name="origin_id"/> | ||
172 | 68 | <group col="2" colspan="2" attrs="{'invisible':[('type','!=','pack')]}"> | ||
173 | 69 | <field name="logistic_unit" attrs="{'required':[('type','=','pack')]}" widget="selection"/> | ||
174 | 70 | </group> | ||
175 | 71 | <group col="4" colspan="4" attrs="{'invisible':[('type','!=','order')]}"> | ||
176 | 72 | <field name="destination_id" attrs="{'required':[('type','=','order')]}" on_change="onchange_destination(destination_id)"/> | ||
177 | 73 | <field name="address_id" attrs="{'required':[('type','=','order')]}"/> | ||
178 | 74 | </group> | ||
179 | 75 | <group col="4" colspan="4" attrs="{'invisible':[('type','!=','move_stock')]}"> | ||
180 | 76 | <field name="move_stock_destination" attrs="{'required':[('type','=','move_stock')]}"/> | ||
181 | 77 | <field name="move_stock_date" attrs="{'required':[('type','=','move_stock')]}"/> | ||
182 | 78 | </group> | ||
183 | 79 | <group col="2" colspan="2" attrs="{'invisible':[('type','!=','inventory')]}"> | ||
184 | 80 | <field name="inventory_id" attrs="{'required':[('type','=','inventory')]}" on_change="onchange_inventory(inventory_id)"/> | ||
185 | 81 | </group> | ||
186 | 82 | <group col="2" colspan="2" attrs="{'invisible':[('type','!=','move_stock')]}"> | ||
187 | 83 | <field name="move_stock_id"/> | ||
188 | 84 | </group> | ||
189 | 85 | <group col="2" colspan="2" attrs="{'invisible':[('type','!=','order')]}"> | ||
190 | 86 | <field name="picking_id" readonly="1"/> | ||
191 | 87 | </group> | ||
192 | 88 | <group col="2" colspan="2" attrs="{'invisible':[('type','!=','pack')]}"> | ||
193 | 89 | <field name="pack_id" readonly="1"/> | ||
194 | 90 | </group> | ||
195 | 91 | <field name="state" invisible="1"/> | ||
196 | 92 | <field name="acquisition_ids" colspan="4" nolabel="1"/> | ||
197 | 93 | <button name="%(action_stock_reference)d" string="Start" type="action" icon="gtk-execute" states="open"/> | ||
198 | 94 | <button name="process" string="Process" type="object" icon="gtk-ok" states="open"/> | ||
199 | 95 | </group> | ||
200 | 96 | </group> | ||
201 | 97 | </form> | ||
202 | 98 | </field> | ||
203 | 99 | </record> | ||
204 | 100 | |||
205 | 101 | <record model="ir.ui.view" id="view_stock_tracking_acquisition_tree"> | ||
206 | 102 | <field name="name">Acquisition.view</field> | ||
207 | 103 | <field name="model">acquisition.acquisition</field> | ||
208 | 104 | <field name="type">tree</field> | ||
209 | 105 | <field name="arch" type="xml"> | ||
210 | 106 | <tree string="Acquisition name"> | ||
211 | 107 | <field name="name"/> | ||
212 | 108 | <field name="acquisition_ids"/> | ||
213 | 109 | </tree> | ||
214 | 110 | </field> | ||
215 | 111 | </record> | ||
216 | 112 | |||
217 | 113 | <record model="ir.actions.act_window" id="action_stock_tracking_acquisition"> | ||
218 | 114 | <field name="name">Acquisition</field> | ||
219 | 115 | <field name="type">ir.actions.act_window</field> | ||
220 | 116 | <field name="res_model">acquisition.acquisition</field> | ||
221 | 117 | <field name="view_type">form</field> | ||
222 | 118 | <field name="view_mode">tree,form</field> | ||
223 | 119 | <field name="target">current</field> | ||
224 | 120 | <field name="view_id" ref="view_stock_tracking_acquisition_tree"/> | ||
225 | 121 | </record> | ||
226 | 122 | |||
227 | 123 | <menuitem id="menu_stock_tracking_acquisition" action="action_stock_tracking_acquisition" parent="stock.menu_traceability" sequence="7"/> | ||
228 | 124 | |||
229 | 125 | <record model="ir.ui.view" id="view_stock_acquisition_setting_form"> | ||
230 | 126 | <field name="name">Acquisition Setting.view</field> | ||
231 | 127 | <field name="model">acquisition.setting</field> | ||
232 | 128 | <field name="type">form</field> | ||
233 | 129 | <field name="arch" type="xml"> | ||
234 | 130 | <form string="Acquisistion Setting"> | ||
235 | 131 | <group colspan="4"> | ||
236 | 132 | <field name="barcode_id" colspan="2"/> | ||
237 | 133 | <field name="action_type" colspan="2"/> | ||
238 | 134 | </group> | ||
239 | 135 | </form> | ||
240 | 136 | </field> | ||
241 | 137 | </record> | ||
242 | 138 | |||
243 | 139 | <record model="ir.ui.view" id="view_stock_acquisition_setting_tree"> | ||
244 | 140 | <field name="name">Acquisition Setting.view</field> | ||
245 | 141 | <field name="model">acquisition.setting</field> | ||
246 | 142 | <field name="type">tree</field> | ||
247 | 143 | <field name="arch" type="xml"> | ||
248 | 144 | <tree string="Acquisistion Setting"> | ||
249 | 145 | <field name="barcode_id"/> | ||
250 | 146 | <field name="action_type"/> | ||
251 | 147 | </tree> | ||
252 | 148 | </field> | ||
253 | 149 | </record> | ||
254 | 150 | |||
255 | 151 | <record model="ir.actions.act_window" id="action_stock_acquisition_setting"> | ||
256 | 152 | <field name="name">Acquisition Setting</field> | ||
257 | 153 | <field name="type">ir.actions.act_window</field> | ||
258 | 154 | <field name="res_model">acquisition.setting</field> | ||
259 | 155 | <field name="view_type">form</field> | ||
260 | 156 | <field name="view_mode">tree,form</field> | ||
261 | 157 | <field name="view_id" ref="view_stock_acquisition_setting_tree"/> | ||
262 | 158 | </record> | ||
263 | 159 | |||
264 | 160 | <menuitem id="menu_stock_acquisition_setting" action="action_stock_acquisition_setting" parent="stock.menu_stock_configuration" sequence="7"/> | ||
265 | 161 | |||
266 | 162 | </data> | ||
267 | 163 | </openerp> | ||
268 | 0 | 164 | ||
269 | === added directory 'stock_barcode_reader/data' | |||
270 | === added file 'stock_barcode_reader/data/acquisition_sequence.xml' | |||
271 | --- stock_barcode_reader/data/acquisition_sequence.xml 1970-01-01 00:00:00 +0000 | |||
272 | +++ stock_barcode_reader/data/acquisition_sequence.xml 2012-11-19 11:44:21 +0000 | |||
273 | @@ -0,0 +1,16 @@ | |||
274 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
275 | 2 | <openerp> | ||
276 | 3 | <data noupdate="1"> | ||
277 | 4 | <!-- Sequences for acquisition.acquisition --> | ||
278 | 5 | <record id="seq_type_acquisition" model="ir.sequence.type"> | ||
279 | 6 | <field name="name">Acquisition</field> | ||
280 | 7 | <field name="code">acquisition.acquisition</field> | ||
281 | 8 | </record> | ||
282 | 9 | <record id="seq_acquisitionr" model="ir.sequence"> | ||
283 | 10 | <field name="name">Acquisition</field> | ||
284 | 11 | <field name="code">acquisition.acquisition</field> | ||
285 | 12 | <field name="prefix">ACQ</field> | ||
286 | 13 | <field name="padding">5</field> | ||
287 | 14 | </record> | ||
288 | 15 | </data> | ||
289 | 16 | </openerp> | ||
290 | 0 | 17 | ||
291 | === added directory 'stock_barcode_reader/i18n' | |||
292 | === added file 'stock_barcode_reader/i18n/fr.po' | |||
293 | --- stock_barcode_reader/i18n/fr.po 1970-01-01 00:00:00 +0000 | |||
294 | +++ stock_barcode_reader/i18n/fr.po 2012-11-19 11:44:21 +0000 | |||
295 | @@ -0,0 +1,283 @@ | |||
296 | 1 | # Translation of OpenERP Server. | ||
297 | 2 | # This file contains the translation of the following modules: | ||
298 | 3 | # * stock_barcode_reader | ||
299 | 4 | # | ||
300 | 5 | msgid "" | ||
301 | 6 | msgstr "" | ||
302 | 7 | "Project-Id-Version: OpenERP Server 6.0.3\n" | ||
303 | 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" | ||
304 | 9 | "POT-Creation-Date: 2011-12-19 10:43+0000\n" | ||
305 | 10 | "PO-Revision-Date: 2011-12-19 10:43+0000\n" | ||
306 | 11 | "Last-Translator: <>\n" | ||
307 | 12 | "Language-Team: \n" | ||
308 | 13 | "MIME-Version: 1.0\n" | ||
309 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
310 | 15 | "Content-Transfer-Encoding: \n" | ||
311 | 16 | "Plural-Forms: \n" | ||
312 | 17 | |||
313 | 18 | #. module: stock_barcode_reader | ||
314 | 19 | #: view:stock.reference:0 | ||
315 | 20 | msgid "Bad Barcode" | ||
316 | 21 | msgstr "Mauvais code-barres" | ||
317 | 22 | |||
318 | 23 | #. module: stock_barcode_reader | ||
319 | 24 | #: field:stock.reference,bad_barcode:0 | ||
320 | 25 | msgid "Bad barcode list" | ||
321 | 26 | msgstr "Liste des mauvais codes-barres" | ||
322 | 27 | |||
323 | 28 | #. module: stock_barcode_reader | ||
324 | 29 | #: code:addons/stock_barcode_reader/package_acquisition.py:267 | ||
325 | 30 | #: code:addons/stock_barcode_reader/package_acquisition.py:424 | ||
326 | 31 | #, python-format | ||
327 | 32 | msgid "You cannot move this pack because there is a none closed pack inside of it: %s." | ||
328 | 33 | msgstr "Vous ne pouvez pas déplacer ce pack car il y a un pack non fermé à l'intérieur de celui-ci: %s." | ||
329 | 34 | |||
330 | 35 | #. module: stock_barcode_reader | ||
331 | 36 | #: selection:acquisition.list,type:0 | ||
332 | 37 | #: selection:acquisition.setting,action_type:0 | ||
333 | 38 | msgid "End Acquisition" | ||
334 | 39 | msgstr "Fin de saisie" | ||
335 | 40 | |||
336 | 41 | #. module: stock_barcode_reader | ||
337 | 42 | #: selection:acquisition.list,type:0 | ||
338 | 43 | #: selection:acquisition.setting,action_type:0 | ||
339 | 44 | msgid "Close a pack" | ||
340 | 45 | msgstr "Fermer un colis" | ||
341 | 46 | |||
342 | 47 | #. module: stock_barcode_reader | ||
343 | 48 | #: view:acquisition.acquisition:0 | ||
344 | 49 | msgid "Start" | ||
345 | 50 | msgstr "Démarrer" | ||
346 | 51 | |||
347 | 52 | #. module: stock_barcode_reader | ||
348 | 53 | #: field:acquisition.acquisition,state:0 | ||
349 | 54 | msgid "State" | ||
350 | 55 | msgstr "Etat" | ||
351 | 56 | |||
352 | 57 | #. module: stock_barcode_reader | ||
353 | 58 | #: field:acquisition.acquisition,inventory_id:0 | ||
354 | 59 | msgid "Inventory" | ||
355 | 60 | msgstr "Inventaire" | ||
356 | 61 | |||
357 | 62 | #. module: stock_barcode_reader | ||
358 | 63 | #: model:ir.actions.act_window,name:stock_barcode_reader.inventory_acquisition_link | ||
359 | 64 | msgid "Inventory Acquisition" | ||
360 | 65 | msgstr "Acquisition d'un inventaire" | ||
361 | 66 | |||
362 | 67 | #. module: stock_barcode_reader | ||
363 | 68 | #: view:stock.reference:0 | ||
364 | 69 | msgid "Reference acquisistion" | ||
365 | 70 | msgstr "Acquisition de référence" | ||
366 | 71 | |||
367 | 72 | #. module: stock_barcode_reader | ||
368 | 73 | #: field:acquisition.acquisition,logistic_unit:0 | ||
369 | 74 | msgid "Unit Size" | ||
370 | 75 | msgstr "Unité de mesure" | ||
371 | 76 | |||
372 | 77 | #. module: stock_barcode_reader | ||
373 | 78 | #: field:acquisition.acquisition,type:0 | ||
374 | 79 | msgid "Type" | ||
375 | 80 | msgstr "Type" | ||
376 | 81 | |||
377 | 82 | #. module: stock_barcode_reader | ||
378 | 83 | #: field:acquisition.acquisition,name:0 | ||
379 | 84 | msgid "Name" | ||
380 | 85 | msgstr "Nom" | ||
381 | 86 | |||
382 | 87 | #. module: stock_barcode_reader | ||
383 | 88 | #: model:ir.model,name:stock_barcode_reader.model_acquisition_setting | ||
384 | 89 | msgid "acquisition.setting" | ||
385 | 90 | msgstr "acquisition.setting" | ||
386 | 91 | |||
387 | 92 | #. module: stock_barcode_reader | ||
388 | 93 | #: field:stock.reference,text:0 | ||
389 | 94 | msgid "Barcode list" | ||
390 | 95 | msgstr "Liste des codes-barres" | ||
391 | 96 | |||
392 | 97 | #. module: stock_barcode_reader | ||
393 | 98 | #: field:acquisition.list,barcode_id:0 | ||
394 | 99 | #: field:acquisition.setting,barcode_id:0 | ||
395 | 100 | msgid "Barcode" | ||
396 | 101 | msgstr "Code-barres" | ||
397 | 102 | |||
398 | 103 | #. module: stock_barcode_reader | ||
399 | 104 | #: code:addons/stock_barcode_reader/package_acquisition.py:426 | ||
400 | 105 | #, python-format | ||
401 | 106 | msgid "Not developed yet" | ||
402 | 107 | msgstr "Pas encore développée" | ||
403 | 108 | |||
404 | 109 | #. module: stock_barcode_reader | ||
405 | 110 | #: selection:acquisition.acquisition,type:0 | ||
406 | 111 | msgid "Inventory Preparation" | ||
407 | 112 | msgstr "Préparation de l'inventaire" | ||
408 | 113 | |||
409 | 114 | #. module: stock_barcode_reader | ||
410 | 115 | #: field:stock.reference,track_id:0 | ||
411 | 116 | msgid "Track id" | ||
412 | 117 | msgstr "ID colis" | ||
413 | 118 | |||
414 | 119 | #. module: stock_barcode_reader | ||
415 | 120 | #: view:acquisition.acquisition:0 | ||
416 | 121 | msgid "Acquisition name" | ||
417 | 122 | msgstr "Saisie" | ||
418 | 123 | |||
419 | 124 | #. module: stock_barcode_reader | ||
420 | 125 | #: field:acquisition.acquisition,address_id:0 | ||
421 | 126 | msgid "Partner Address" | ||
422 | 127 | msgstr "Adresse du partenaire" | ||
423 | 128 | |||
424 | 129 | #. module: stock_barcode_reader | ||
425 | 130 | #: field:acquisition.acquisition,origin_id:0 | ||
426 | 131 | msgid "Origin Location" | ||
427 | 132 | msgstr "Emplacement courant" | ||
428 | 133 | |||
429 | 134 | #. module: stock_barcode_reader | ||
430 | 135 | #: model:ir.module.module,description:stock_barcode_reader.module_meta_information | ||
431 | 136 | msgid " This module is an ergonomic wizard to fill in package " | ||
432 | 137 | msgstr " Ce module est un assistant d'ergonomie à remplir dans le paquet " | ||
433 | 138 | |||
434 | 139 | #. module: stock_barcode_reader | ||
435 | 140 | #: field:acquisition.acquisition,move_stock_date:0 | ||
436 | 141 | msgid "Move Date" | ||
437 | 142 | msgstr "Date de mouvement" | ||
438 | 143 | |||
439 | 144 | #. module: stock_barcode_reader | ||
440 | 145 | #: model:ir.model,name:stock_barcode_reader.model_acquisition_list | ||
441 | 146 | msgid "acquisition.list" | ||
442 | 147 | msgstr "acquisition.list" | ||
443 | 148 | |||
444 | 149 | #. module: stock_barcode_reader | ||
445 | 150 | #: help:acquisition.setting,action_type:0 | ||
446 | 151 | msgid "Selection of an action" | ||
447 | 152 | msgstr "Sélection d'une action" | ||
448 | 153 | |||
449 | 154 | #. module: stock_barcode_reader | ||
450 | 155 | #: model:ir.module.module,shortdesc:stock_barcode_reader.module_meta_information | ||
451 | 156 | msgid "Stock bar code reader" | ||
452 | 157 | msgstr "Outil de lecteur de code-barres" | ||
453 | 158 | |||
454 | 159 | #. module: stock_barcode_reader | ||
455 | 160 | #: code:addons/stock_barcode_reader/package_acquisition.py:264 | ||
456 | 161 | #: code:addons/stock_barcode_reader/package_acquisition.py:421 | ||
457 | 162 | #, python-format | ||
458 | 163 | msgid "You cannot move this pack because it's inside of an other pack: %s." | ||
459 | 164 | msgstr "Vous ne pouvez pas déplacer ce pack, car il est à l'intérieur d'un autre pack: %s." | ||
460 | 165 | |||
461 | 166 | #. module: stock_barcode_reader | ||
462 | 167 | #: field:acquisition.list,name:0 | ||
463 | 168 | msgid "List Name" | ||
464 | 169 | msgstr "Nom de la liste" | ||
465 | 170 | |||
466 | 171 | #. module: stock_barcode_reader | ||
467 | 172 | #: selection:acquisition.list,type:0 | ||
468 | 173 | #: selection:acquisition.setting,action_type:0 | ||
469 | 174 | msgid "Add a logistic unit" | ||
470 | 175 | msgstr "Ajouter une unité logistique" | ||
471 | 176 | |||
472 | 177 | #. module: stock_barcode_reader | ||
473 | 178 | #: selection:acquisition.acquisition,type:0 | ||
474 | 179 | msgid "Pack Preparation" | ||
475 | 180 | msgstr "Préparation de colis" | ||
476 | 181 | |||
477 | 182 | #. module: stock_barcode_reader | ||
478 | 183 | #: view:stock.reference:0 | ||
479 | 184 | msgid "End of Acquisition" | ||
480 | 185 | msgstr "Fin de la saisie" | ||
481 | 186 | |||
482 | 187 | #. module: stock_barcode_reader | ||
483 | 188 | #: selection:acquisition.list,type:0 | ||
484 | 189 | #: selection:acquisition.setting,action_type:0 | ||
485 | 190 | msgid "Create a pack" | ||
486 | 191 | msgstr "Préparation d'un colis" | ||
487 | 192 | |||
488 | 193 | #. module: stock_barcode_reader | ||
489 | 194 | #: field:acquisition.acquisition,acquisition_ids:0 | ||
490 | 195 | #: field:acquisition.list,acquisition_id:0 | ||
491 | 196 | #: model:ir.actions.act_window,name:stock_barcode_reader.action_stock_tracking_acquisition | ||
492 | 197 | #: model:ir.ui.menu,name:stock_barcode_reader.menu_stock_tracking_acquisition | ||
493 | 198 | msgid "Acquisition" | ||
494 | 199 | msgstr "Module de saisie" | ||
495 | 200 | |||
496 | 201 | #. module: stock_barcode_reader | ||
497 | 202 | #: model:ir.model,name:stock_barcode_reader.model_stock_reference | ||
498 | 203 | msgid "Products Acquisition" | ||
499 | 204 | msgstr "Saisie de produits" | ||
500 | 205 | |||
501 | 206 | #. module: stock_barcode_reader | ||
502 | 207 | #: view:stock.reference:0 | ||
503 | 208 | msgid "Barcode list" | ||
504 | 209 | msgstr "Liste de code-barres" | ||
505 | 210 | |||
506 | 211 | #. module: stock_barcode_reader | ||
507 | 212 | #: view:acquisition.acquisition:0 | ||
508 | 213 | msgid "Process" | ||
509 | 214 | msgstr "Valider" | ||
510 | 215 | |||
511 | 216 | #. module: stock_barcode_reader | ||
512 | 217 | #: selection:acquisition.list,type:0 | ||
513 | 218 | msgid "Logistic Unit" | ||
514 | 219 | msgstr "Unité Logistique" | ||
515 | 220 | |||
516 | 221 | #. module: stock_barcode_reader | ||
517 | 222 | #: model:ir.actions.act_window,name:stock_barcode_reader.action_stock_reference | ||
518 | 223 | #: field:stock.reference,reference:0 | ||
519 | 224 | msgid "Reference" | ||
520 | 225 | msgstr "Référence" | ||
521 | 226 | |||
522 | 227 | #. module: stock_barcode_reader | ||
523 | 228 | #: model:ir.actions.report.xml,name:stock_barcode_reader.account_invoices | ||
524 | 229 | msgid "Invoices" | ||
525 | 230 | msgstr "Factures" | ||
526 | 231 | |||
527 | 232 | #. module: stock_barcode_reader | ||
528 | 233 | #: field:acquisition.acquisition,destination_id:0 | ||
529 | 234 | #: field:acquisition.acquisition,move_stock_destination:0 | ||
530 | 235 | msgid "Destination Location" | ||
531 | 236 | msgstr "Emplacement de destination" | ||
532 | 237 | |||
533 | 238 | #. module: stock_barcode_reader | ||
534 | 239 | #: model:ir.model,name:stock_barcode_reader.model_acquisition_acquisition | ||
535 | 240 | msgid "acquisition.acquisition" | ||
536 | 241 | msgstr "acquisition.acquisition" | ||
537 | 242 | |||
538 | 243 | #. module: stock_barcode_reader | ||
539 | 244 | #: field:acquisition.list,type:0 | ||
540 | 245 | #: field:acquisition.setting,action_type:0 | ||
541 | 246 | msgid "Action Type" | ||
542 | 247 | msgstr "Type d'action" | ||
543 | 248 | |||
544 | 249 | #. module: stock_barcode_reader | ||
545 | 250 | #: selection:acquisition.acquisition,type:0 | ||
546 | 251 | msgid "Order Preparation" | ||
547 | 252 | msgstr "Préparation des commandes" | ||
548 | 253 | |||
549 | 254 | #. module: stock_barcode_reader | ||
550 | 255 | #: view:acquisition.list:0 | ||
551 | 256 | msgid "Acquisition list" | ||
552 | 257 | msgstr "Liste de saisie" | ||
553 | 258 | |||
554 | 259 | #. module: stock_barcode_reader | ||
555 | 260 | #: selection:acquisition.acquisition,state:0 | ||
556 | 261 | msgid "Done" | ||
557 | 262 | msgstr "Terminé" | ||
558 | 263 | |||
559 | 264 | #. module: stock_barcode_reader | ||
560 | 265 | #: code:addons/stock_barcode_reader/package_acquisition.py:264 | ||
561 | 266 | #: code:addons/stock_barcode_reader/package_acquisition.py:267 | ||
562 | 267 | #: code:addons/stock_barcode_reader/package_acquisition.py:421 | ||
563 | 268 | #: code:addons/stock_barcode_reader/package_acquisition.py:424 | ||
564 | 269 | #: code:addons/stock_barcode_reader/package_acquisition.py:426 | ||
565 | 270 | #, python-format | ||
566 | 271 | msgid "Warning!" | ||
567 | 272 | msgstr "Attention!" | ||
568 | 273 | |||
569 | 274 | #. module: stock_barcode_reader | ||
570 | 275 | #: view:stock.reference:0 | ||
571 | 276 | msgid "Close" | ||
572 | 277 | msgstr "Fermé" | ||
573 | 278 | |||
574 | 279 | #. module: stock_barcode_reader | ||
575 | 280 | #: selection:acquisition.acquisition,state:0 | ||
576 | 281 | msgid "Open" | ||
577 | 282 | msgstr "Ouvert" | ||
578 | 283 | |||
579 | 0 | 284 | ||
580 | === added directory 'stock_barcode_reader/images' | |||
581 | === added file 'stock_barcode_reader/images/Acquisition.png' | |||
582 | 1 | Binary files stock_barcode_reader/images/Acquisition.png 1970-01-01 00:00:00 +0000 and stock_barcode_reader/images/Acquisition.png 2012-11-19 11:44:21 +0000 differ | 285 | Binary files stock_barcode_reader/images/Acquisition.png 1970-01-01 00:00:00 +0000 and stock_barcode_reader/images/Acquisition.png 2012-11-19 11:44:21 +0000 differ |
583 | === added file 'stock_barcode_reader/package_acquisition.py' | |||
584 | --- stock_barcode_reader/package_acquisition.py 1970-01-01 00:00:00 +0000 | |||
585 | +++ stock_barcode_reader/package_acquisition.py 2012-11-19 11:44:21 +0000 | |||
586 | @@ -0,0 +1,805 @@ | |||
587 | 1 | # -*- coding: utf-8 -*- | ||
588 | 2 | ################################################################################# | ||
589 | 3 | # | ||
590 | 4 | # OpenERP, Open Source Management Solution | ||
591 | 5 | # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> | ||
592 | 6 | # | ||
593 | 7 | # This program is free software: you can redistribute it and/or modify | ||
594 | 8 | # it under the terms of the GNU General Public License as published by | ||
595 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
596 | 10 | # (at your option) any later version. | ||
597 | 11 | # | ||
598 | 12 | # This program is distributed in the hope that it will be useful, | ||
599 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
600 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
601 | 15 | # GNU General Public License for more details. | ||
602 | 16 | # | ||
603 | 17 | # You should have received a copy of the GNU General Public License | ||
604 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
605 | 19 | # | ||
606 | 20 | ################################################################################# | ||
607 | 21 | |||
608 | 22 | from osv import osv,fields | ||
609 | 23 | from tools.translate import _ | ||
610 | 24 | from report import report_sxw | ||
611 | 25 | from report_aeroo import report_aeroo | ||
612 | 26 | import datetime | ||
613 | 27 | from tools import misc | ||
614 | 28 | |||
615 | 29 | class stock_fill_inventory(osv.osv_memory): | ||
616 | 30 | _inherit = "stock.fill.inventory" | ||
617 | 31 | def fill_inventory(self, cr, uid, ids, context=None): | ||
618 | 32 | res = super(stock_fill_inventory, self).fill_inventory(cr, uid, ids, context=context) | ||
619 | 33 | stock_inventory_obj = self.pool.get('stock.inventory') | ||
620 | 34 | fill_inventory = self.browse(cr, uid, ids[0], context=context) | ||
621 | 35 | if stock_inventory_obj.browse(cr, uid, context.get('active_id', False), context).location_id: | ||
622 | 36 | stock_inventory_obj.write(cr, uid, context.get('active_id', False), {'location_id': fill_inventory.location_id.id}) | ||
623 | 37 | return res | ||
624 | 38 | stock_fill_inventory() | ||
625 | 39 | |||
626 | 40 | class acquisition_acquisition(osv.osv): | ||
627 | 41 | |||
628 | 42 | _name = "acquisition.acquisition" | ||
629 | 43 | _order = 'id desc' | ||
630 | 44 | |||
631 | 45 | _columns = { | ||
632 | 46 | 'state': fields.selection([('open', 'Open'),('done', 'Done'),], 'State', readonly=True), | ||
633 | 47 | 'name': fields.char('Name', size=128, required=True, readonly=True, states={'open':[('readonly',False)]}), | ||
634 | 48 | 'acquisition_ids': fields.one2many('acquisition.list','acquisition_id','Acquisition', readonly=True, states={'open':[('readonly',False)]}), | ||
635 | 49 | 'origin_id': fields.many2one('stock.location', 'Origin Location' , required=True, readonly=True, states={'open':[('readonly',False)]}), | ||
636 | 50 | 'type': fields.selection([ | ||
637 | 51 | ('order','Order Preparation'), | ||
638 | 52 | ('pack','Pack Preparation'), | ||
639 | 53 | ('inventory','Inventory Preparation'), | ||
640 | 54 | ('move_stock','Move Stock'), | ||
641 | 55 | ],'Type', size=128, readonly=True, states={'open':[('readonly',False)]}), | ||
642 | 56 | 'destination_id': fields.many2one('stock.location', 'Destination Location' , readonly=True, states={'open':[('readonly',False)]}), | ||
643 | 57 | 'address_id': fields.many2one('res.partner.address','Partner Address', readonly=True, states={'open':[('readonly',False)]}), | ||
644 | 58 | 'logistic_unit': fields.many2one('product.ul', 'Unit Size', readonly=True, states={'open':[('readonly',False)]}), | ||
645 | 59 | 'inventory_id': fields.many2one('stock.inventory', 'Inventory', readonly=True, states={'open':[('readonly',False)]}, domain="[('type', '!=', 'move')]"), | ||
646 | 60 | 'move_stock_id': fields.many2one('stock.inventory', 'Move stock', readonly=True, domain="[('type', '=', 'move')]"), | ||
647 | 61 | 'pack_id': fields.many2one('stock.tracking', 'Pack', readonly=True), | ||
648 | 62 | 'pack_name': fields.related('pack_id', 'name', type='char', string="Pack Name", size=64, readonly=True), | ||
649 | 63 | 'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True), | ||
650 | 64 | 'picking_name': fields.related('picking_id', 'name', type='char', string="Picking Name", size=64, readonly=True), | ||
651 | 65 | 'move_stock_destination': fields.many2one('stock.location', 'Destination Location' , readonly=True, states={'open':[('readonly',False)]}), | ||
652 | 66 | 'move_stock_date': fields.datetime('Move Date', readonly=True, states={'open':[('readonly',False)]}), | ||
653 | 67 | } | ||
654 | 68 | _defaults = { | ||
655 | 69 | 'state': 'open', | ||
656 | 70 | 'type': 'pack', | ||
657 | 71 | 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'acquisition.acquisition'), | ||
658 | 72 | 'move_stock_date': lambda * a: datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT), | ||
659 | 73 | } | ||
660 | 74 | |||
661 | 75 | def onchange_destination(self, cr, uid, ids, destination_id=False, context=None): | ||
662 | 76 | res = {'value':{'address_id': False}} | ||
663 | 77 | if destination_id: | ||
664 | 78 | destination = self.pool.get('stock.location').browse(cr, uid, destination_id) | ||
665 | 79 | if destination.address_id: | ||
666 | 80 | res['value']['address_id'] = destination.address_id.id | ||
667 | 81 | return res | ||
668 | 82 | |||
669 | 83 | def onchange_inventory(self, cr, uid, ids, inventory_id=False, context=None): | ||
670 | 84 | res = {'value':{'location_id': False}} | ||
671 | 85 | if inventory_id: | ||
672 | 86 | inventory = self.pool.get('stock.inventory').browse(cr, uid, inventory_id) | ||
673 | 87 | if inventory.location_id: | ||
674 | 88 | res['value']['origin_id'] = inventory.location_id.id | ||
675 | 89 | res['value']['name'] = inventory.name | ||
676 | 90 | return res | ||
677 | 91 | |||
678 | 92 | # def print_pack_report(self, cr, uid, ids, context=None): | ||
679 | 93 | # '''init''' | ||
680 | 94 | # if context is None: | ||
681 | 95 | # context = {} | ||
682 | 96 | # | ||
683 | 97 | # '''process''' | ||
684 | 98 | # data = self.pool.get('stock.tracking').read(cr, uid, ids)[0] | ||
685 | 99 | # datas = { | ||
686 | 100 | # 'ids': ids, | ||
687 | 101 | # 'model': 'stock.tracking', | ||
688 | 102 | # 'form': data | ||
689 | 103 | # } | ||
690 | 104 | # '''print report''' | ||
691 | 105 | # return {'type': 'ir.actions.report.xml', | ||
692 | 106 | # 'report_name': 'voltalis.tracking.barcode.report.aeroo', | ||
693 | 107 | # 'datas': datas | ||
694 | 108 | # } | ||
695 | 109 | |||
696 | 110 | def check_production_lot_location(self, cr, uid, origin_id, logistic_unit_id, context=None): | ||
697 | 111 | result = {} | ||
698 | 112 | stock_move_obj = self.pool.get('stock.move') | ||
699 | 113 | stock_production_lot_data = self.pool.get('stock.production.lot').browse(cr, uid, logistic_unit_id) | ||
700 | 114 | logistic_unit_number = stock_production_lot_data.id | ||
701 | 115 | product = stock_production_lot_data.product_id | ||
702 | 116 | name_list = self.pool.get('product.product').name_get(cr, uid, [product.id], context) | ||
703 | 117 | stock_production_lot_name = name_list[0][1] | ||
704 | 118 | '''If the production lot is not in the current stock''' | ||
705 | 119 | '''We add a move form it position to the current stock''' | ||
706 | 120 | if stock_production_lot_data.location_id: | ||
707 | 121 | if stock_production_lot_data.location_id.id != origin_id: | ||
708 | 122 | result = stock_move_obj.create(cr, uid, {'name': stock_production_lot_name, | ||
709 | 123 | 'state': 'draft', | ||
710 | 124 | 'product_id': product.id, | ||
711 | 125 | 'product_uom': product.uom_id.id, | ||
712 | 126 | 'prodlot_id': logistic_unit_number, | ||
713 | 127 | 'location_id': stock_production_lot_data.location_id.id, | ||
714 | 128 | 'location_dest_id': origin_id, | ||
715 | 129 | }) | ||
716 | 130 | return result | ||
717 | 131 | |||
718 | 132 | def update_delivery_order_line(self, cr, uid, product_id=False, res_id=False, order_id=False, origin_id=False, destination_id=False, tracking_id=False, quantity=1, context=None): | ||
719 | 133 | result = {} | ||
720 | 134 | move_obj = self.pool.get('stock.move') | ||
721 | 135 | production_lot_obj = self.pool.get('stock.production.lot') | ||
722 | 136 | split_obj = self.pool.get('stock.move.split') | ||
723 | 137 | split_line_obj = self.pool.get('stock.move.split.lines') | ||
724 | 138 | product_obj = self.pool.get('product.product') | ||
725 | 139 | product_product = False | ||
726 | 140 | if res_id: | ||
727 | 141 | production_lot = production_lot_obj.browse(cr, uid, res_id) | ||
728 | 142 | product_id = production_lot.product_id and production_lot.product_id.id or False | ||
729 | 143 | else: | ||
730 | 144 | product_product = True | ||
731 | 145 | if product_id: | ||
732 | 146 | move_ids = move_obj.search(cr, uid, [ | ||
733 | 147 | ('state', 'not in', ['cancel']), | ||
734 | 148 | ('picking_id', '=', order_id), | ||
735 | 149 | ('product_id', '=', product_id), | ||
736 | 150 | ('prodlot_id', '=', False), | ||
737 | 151 | ]) | ||
738 | 152 | if move_ids and not product_product: | ||
739 | 153 | """ The move can be split """ | ||
740 | 154 | vals = {} | ||
741 | 155 | split_context = context | ||
742 | 156 | split_context.update({'active_id': move_ids[0], 'active_ids': [move_ids[0]], 'active_model': 'stock.move', 'tracking_id': tracking_id}) | ||
743 | 157 | split_id = split_obj.create(cr, uid, vals, split_context) | ||
744 | 158 | split_line_obj.create(cr, uid, {'prodlot_id': res_id, 'wizard_exist_id': split_id, 'quantity':quantity}) | ||
745 | 159 | split_obj.split_lot(cr, uid, [split_id], split_context) | ||
746 | 160 | else: | ||
747 | 161 | """ There are no move """ | ||
748 | 162 | if res_id: | ||
749 | 163 | product = production_lot.product_id | ||
750 | 164 | else: | ||
751 | 165 | product = product_obj.browse(cr, uid, product_id, context=context) | ||
752 | 166 | name_list = product_obj.name_get(cr, uid, [product_id], context) | ||
753 | 167 | stock_production_lot_name = name_list[0][1] | ||
754 | 168 | move_id = move_obj.create(cr, uid, { | ||
755 | 169 | 'name': stock_production_lot_name, | ||
756 | 170 | 'product_id': product_id, | ||
757 | 171 | 'product_uom': product.uom_id.id, | ||
758 | 172 | 'prodlot_id': res_id, | ||
759 | 173 | 'location_id': origin_id, | ||
760 | 174 | 'product_qty': quantity, | ||
761 | 175 | 'location_dest_id': destination_id, | ||
762 | 176 | 'picking_id': order_id, | ||
763 | 177 | 'tracking_id': tracking_id, | ||
764 | 178 | }) | ||
765 | 179 | return result | ||
766 | 180 | |||
767 | 181 | def process(self, cr, uid, ids, context=None): | ||
768 | 182 | if context == None: | ||
769 | 183 | context = {} | ||
770 | 184 | res = {} | ||
771 | 185 | acquisition_data = self.browse(cr, uid, ids, context) | ||
772 | 186 | for acquisition in acquisition_data: | ||
773 | 187 | if acquisition.type == 'order': | ||
774 | 188 | if acquisition.picking_id: | ||
775 | 189 | self.order_preparation(cr, uid, acquisition, context) | ||
776 | 190 | else: | ||
777 | 191 | self.order_creation(cr, uid, acquisition, context) | ||
778 | 192 | elif acquisition.type == 'pack': | ||
779 | 193 | self.pack_preparation(cr, uid, acquisition, context) | ||
780 | 194 | elif acquisition.type == 'inventory': | ||
781 | 195 | self.inventory_preparation(cr, uid, acquisition, context) | ||
782 | 196 | elif acquisition.type == 'move_stock': | ||
783 | 197 | self.move_stock_preparation(cr, uid, acquisition, context) | ||
784 | 198 | self.write(cr, uid, acquisition.id, {'state': 'done'}, context=context) | ||
785 | 199 | return res | ||
786 | 200 | |||
787 | 201 | """ | ||
788 | 202 | ### DELIVERY ORDER PREPARATION ### | ||
789 | 203 | """ | ||
790 | 204 | def order_preparation(self, cr, uid, acquisition, context=None): | ||
791 | 205 | res = {} | ||
792 | 206 | if context==None: | ||
793 | 207 | context = {} | ||
794 | 208 | first_code = True | ||
795 | 209 | parent_id = None | ||
796 | 210 | for line in acquisition.acquisition_ids: | ||
797 | 211 | if first_code == True: | ||
798 | 212 | first_code = False | ||
799 | 213 | self.update_order(cr, uid, acquisition, context) | ||
800 | 214 | parent_id = self.update_stock_move(cr, uid, line, parent_id, context) | ||
801 | 215 | return res | ||
802 | 216 | |||
803 | 217 | '''Updating the order''' | ||
804 | 218 | def update_order(self, cr, uid, acquisition, context=None): | ||
805 | 219 | if context == None: | ||
806 | 220 | context = {} | ||
807 | 221 | stock_picking_obj = self.pool.get('stock.picking') | ||
808 | 222 | address_id = acquisition.address_id.id | ||
809 | 223 | picking_id = acquisition.picking_id.id | ||
810 | 224 | stock_picking_obj.write(cr, uid, picking_id, {'address_id': address_id, 'type': 'out'}) | ||
811 | 225 | return picking_id | ||
812 | 226 | |||
813 | 227 | '''Split moves of the order into different production lot / tracking packs''' | ||
814 | 228 | def update_stock_move(self, cr, uid, line, parent_id=None, context=None): | ||
815 | 229 | stock_tracking_obj = self.pool.get('stock.tracking') | ||
816 | 230 | history_obj = self.pool.get('stock.tracking.history') | ||
817 | 231 | setting_obj = self.pool.get('acquisition.setting') | ||
818 | 232 | if context == None: | ||
819 | 233 | context = {} | ||
820 | 234 | barcode = line.barcode_id | ||
821 | 235 | res_model = barcode.res_model | ||
822 | 236 | res_id = barcode.res_id | ||
823 | 237 | order_id = line.acquisition_id and line.acquisition_id.picking_id and line.acquisition_id.picking_id.id or False | ||
824 | 238 | |||
825 | 239 | acquisition_data = self.browse(cr, uid, line.acquisition_id.id) | ||
826 | 240 | origin_id = acquisition_data.origin_id.id | ||
827 | 241 | destination_id = acquisition_data.destination_id.id | ||
828 | 242 | |||
829 | 243 | """ If a barcode creation pack is detected """ | ||
830 | 244 | acquisition_setting_ids = setting_obj.search(cr, uid, [('barcode_id','=',barcode.id)], limit=1) | ||
831 | 245 | if acquisition_setting_ids: | ||
832 | 246 | acquisition_setting_id = acquisition_setting_ids[0] | ||
833 | 247 | acquisition_setting_data = setting_obj.browse(cr, uid, acquisition_setting_id, context) | ||
834 | 248 | if acquisition_setting_data.action_type == 'create_pack': | ||
835 | 249 | logistic_unit = self.pool.get('product.ul').search(cr, uid, [('type','=','pack')], limit=1)[0] | ||
836 | 250 | parent_id = setting_obj.create_pack(cr, uid, [line.acquisition_id.id], logistic_unit, context) | ||
837 | 251 | return parent_id | ||
838 | 252 | elif parent_id and acquisition_setting_data.action_type == 'close_pack': | ||
839 | 253 | setting_obj.close_pack(cr, uid, [parent_id], context) | ||
840 | 254 | parent_id = None | ||
841 | 255 | if parent_id: | ||
842 | 256 | setting_obj.add_child(cr, uid, barcode.id, parent_id, context) | ||
843 | 257 | |||
844 | 258 | if res_model == 'stock.production.lot': | ||
845 | 259 | """ Check of production lot creation """ | ||
846 | 260 | new_move_id = self.check_production_lot_location(cr, uid, origin_id, res_id, context) | ||
847 | 261 | """ Split in production lot """ | ||
848 | 262 | self.update_delivery_order_line(cr, uid, product_id=False, res_id=res_id, order_id=order_id, \ | ||
849 | 263 | origin_id=origin_id, destination_id=destination_id, tracking_id=parent_id, quantity=1, context=context) | ||
850 | 264 | elif res_model == 'stock.tracking': | ||
851 | 265 | stock_tracking_data = stock_tracking_obj.browse(cr, uid, res_id) | ||
852 | 266 | pack_list = {} | ||
853 | 267 | pack_number = 1 | ||
854 | 268 | """ Check if current pack is available """ | ||
855 | 269 | if stock_tracking_data.parent_id: | ||
856 | 270 | raise osv.except_osv(_('Warning!'),_('You cannot move this pack because it\'s inside of an other pack: %s.') % (stock_tracking_data.parent_id.name)) | ||
857 | 271 | for child in stock_tracking_data.child_ids: | ||
858 | 272 | if child.state != 'close': | ||
859 | 273 | raise osv.except_osv(_('Warning!'),_('You cannot move this pack because there is a none closed pack inside of it: %s.') % (child.name)) | ||
860 | 274 | child_packs = stock_tracking_obj.hierarchy_ids(stock_tracking_data) | ||
861 | 275 | for child_pack in child_packs: | ||
862 | 276 | '''historic creation''' | ||
863 | 277 | hist_id = history_obj.create(cr, uid, { | ||
864 | 278 | 'tracking_id': child_pack.id, | ||
865 | 279 | 'type': 'move', | ||
866 | 280 | 'location_id': child_pack.location_id.id, | ||
867 | 281 | 'location_dest_id': destination_id, | ||
868 | 282 | }) | ||
869 | 283 | for move_data in child_pack.move_ids: | ||
870 | 284 | """ Split in production lot """ | ||
871 | 285 | self.update_delivery_order_line(cr, uid, product_id=False, res_id=move_data.prodlot_id.id, order_id=order_id, \ | ||
872 | 286 | origin_id=origin_id, destination_id=destination_id, tracking_id=res_id, quantity=1, context=context) | ||
873 | 287 | if res_model == 'product.product': | ||
874 | 288 | self.update_delivery_order_line(cr, uid, product_id=res_id, res_id=False, order_id=order_id, \ | ||
875 | 289 | origin_id=origin_id, destination_id=destination_id, tracking_id=parent_id, quantity=line.quantity, context=context) | ||
876 | 290 | return parent_id | ||
877 | 291 | |||
878 | 292 | """ | ||
879 | 293 | ### DELIVERY ORDER CREATION ### | ||
880 | 294 | """ | ||
881 | 295 | def order_creation(self, cr, uid, acquisition, context=None): | ||
882 | 296 | res = {} | ||
883 | 297 | if context==None: | ||
884 | 298 | context = {} | ||
885 | 299 | first_code = True | ||
886 | 300 | acquisition_obj = self.pool.get('acquisition.acquisition') | ||
887 | 301 | setting_obj = self.pool.get('acquisition.setting') | ||
888 | 302 | for line in acquisition.acquisition_ids: | ||
889 | 303 | if first_code == True: | ||
890 | 304 | first_code = False | ||
891 | 305 | order_id = self.create_order(cr, uid, [acquisition.id], context) | ||
892 | 306 | acquisition_obj.write(cr, uid, acquisition.id, {'picking_id': order_id}) | ||
893 | 307 | if line.type == 'object': | ||
894 | 308 | self.add_stock_move(cr, uid, [acquisition.id], line, order_id, context) | ||
895 | 309 | else: | ||
896 | 310 | tracking_id = setting_obj.do_action(cr, uid, [acquisition.id], line.type, context) | ||
897 | 311 | context['tracking_id'] = tracking_id | ||
898 | 312 | return res | ||
899 | 313 | |||
900 | 314 | ''' Picking Creation ''' | ||
901 | 315 | def create_order(self, cr, uid, ids, context=None): | ||
902 | 316 | '''init''' | ||
903 | 317 | if context == None: | ||
904 | 318 | context = {} | ||
905 | 319 | vals = {} | ||
906 | 320 | acquisition_obj = self.pool.get('acquisition.acquisition') | ||
907 | 321 | acquisition_data = acquisition_obj.browse(cr, uid, ids[0]) | ||
908 | 322 | stock_picking_obj = self.pool.get('stock.picking') | ||
909 | 323 | '''variables''' | ||
910 | 324 | address_id = acquisition_data.address_id.id | ||
911 | 325 | '''order creation''' | ||
912 | 326 | order_id = stock_picking_obj.create(cr, uid, {'address_id': address_id, 'type': 'out'}) | ||
913 | 327 | # name = self.pool.get('stock.picking').browse(cr, uid, order_id, context=context).name or False | ||
914 | 328 | # if name: | ||
915 | 329 | # vals['name'] = name | ||
916 | 330 | # self.write(cr, uid, acquisition_data.id, vals, context=context) | ||
917 | 331 | '''End''' | ||
918 | 332 | return order_id | ||
919 | 333 | |||
920 | 334 | ''' Adding move in a picking ''' | ||
921 | 335 | def add_stock_move(self, cr, uid, ids, line, order_id, context=None): | ||
922 | 336 | '''init''' | ||
923 | 337 | res = {} | ||
924 | 338 | if context == None: | ||
925 | 339 | context = {} | ||
926 | 340 | barcode_obj = self.pool.get('tr.barcode') | ||
927 | 341 | stock_move_obj = self.pool.get('stock.move') | ||
928 | 342 | product_obj = self.pool.get('product.product') | ||
929 | 343 | stock_tracking_obj = self.pool.get('stock.tracking') | ||
930 | 344 | history_obj = self.pool.get('stock.tracking.history') | ||
931 | 345 | acquisition_obj = self.pool.get('acquisition.acquisition') | ||
932 | 346 | stock_production_lot_obj = self.pool.get('stock.production.lot') | ||
933 | 347 | |||
934 | 348 | acquisition_data = acquisition_obj.browse(cr, uid, ids[0]) | ||
935 | 349 | |||
936 | 350 | '''process''' | ||
937 | 351 | origin_id = acquisition_data.origin_id.id | ||
938 | 352 | destination_id = acquisition_data.destination_id.id | ||
939 | 353 | barcode_data = line.barcode_id | ||
940 | 354 | logistic_unit_id = barcode_data.res_id | ||
941 | 355 | tracking_id = context.get('tracking_id', False) | ||
942 | 356 | if barcode_data.res_model == 'stock.production.lot': | ||
943 | 357 | stock_production_lot_data = stock_production_lot_obj.browse(cr, uid, logistic_unit_id) | ||
944 | 358 | logistic_unit_number = stock_production_lot_data.id | ||
945 | 359 | product = stock_production_lot_data.product_id | ||
946 | 360 | name_list = self.pool.get('product.product').name_get(cr, uid, [product.id], context) | ||
947 | 361 | stock_production_lot_name = name_list[0][1] | ||
948 | 362 | '''If the production lot is not in the current stock''' | ||
949 | 363 | new_move_id = self.check_production_lot_location(cr, uid, origin_id, logistic_unit_id, context) | ||
950 | 364 | ''''stock move creation''' | ||
951 | 365 | move_id = stock_move_obj.create(cr, uid, { | ||
952 | 366 | 'name': stock_production_lot_name, | ||
953 | 367 | 'product_id': product.id, | ||
954 | 368 | 'product_uom': product.uom_id.id, | ||
955 | 369 | 'prodlot_id': logistic_unit_number, | ||
956 | 370 | 'location_id': origin_id, | ||
957 | 371 | 'location_dest_id': destination_id, | ||
958 | 372 | 'picking_id': order_id, | ||
959 | 373 | 'move_ori_id': new_move_id, | ||
960 | 374 | 'tracking_id' : tracking_id, | ||
961 | 375 | }) | ||
962 | 376 | elif barcode_data.res_model == 'product.product': | ||
963 | 377 | product_data = product_obj.browse(cr, uid, logistic_unit_id) | ||
964 | 378 | move_id = stock_move_obj.create(cr, uid, { | ||
965 | 379 | 'name': product_data.name, | ||
966 | 380 | 'product_id': product_data.id, | ||
967 | 381 | 'product_uom': product_data.uom_id.id, | ||
968 | 382 | 'product_qty': line.quantity, | ||
969 | 383 | 'location_id': origin_id, | ||
970 | 384 | 'location_dest_id': destination_id, | ||
971 | 385 | 'picking_id': order_id, | ||
972 | 386 | 'tracking_id' : tracking_id, | ||
973 | 387 | }) | ||
974 | 388 | elif barcode_data.res_model == 'stock.tracking': | ||
975 | 389 | stock_tracking_data = stock_tracking_obj.browse(cr, uid, logistic_unit_id) | ||
976 | 390 | if stock_tracking_data.parent_id: | ||
977 | 391 | raise osv.except_osv(_('Warning!'),_('You cannot move this pack because it\'s inside of an other pack: %s.') % (stock_tracking_data.parent_id.name)) | ||
978 | 392 | for child in stock_tracking_data.child_ids: | ||
979 | 393 | if child.state != 'close': | ||
980 | 394 | raise osv.except_osv(_('Warning!'),_('You cannot move this pack because there is a none closed pack inside of it: %s.') % (child.name)) | ||
981 | 395 | |||
982 | 396 | for move_data in stock_tracking_data.move_ids: | ||
983 | 397 | if move_data.location_dest_id.id != origin_id: | ||
984 | 398 | new_move_id = stock_move_obj.create(cr, uid, { | ||
985 | 399 | 'name': move_data.name, | ||
986 | 400 | 'state': 'draft', | ||
987 | 401 | 'product_id': move_data.product_id.id, | ||
988 | 402 | 'product_uom': move_data.product_uom.id, | ||
989 | 403 | 'prodlot_id': move_data.prodlot_id.id, | ||
990 | 404 | 'location_id': move_data.location_dest_id.id, | ||
991 | 405 | 'location_dest_id': origin_id, | ||
992 | 406 | }) | ||
993 | 407 | |||
994 | 408 | child_packs = stock_tracking_obj.hierarchy_ids(stock_tracking_data) | ||
995 | 409 | for child_pack in child_packs: | ||
996 | 410 | '''historic creation''' | ||
997 | 411 | hist_id = history_obj.create(cr, uid, { | ||
998 | 412 | 'tracking_id': child_pack.id, | ||
999 | 413 | 'type': 'move', | ||
1000 | 414 | 'location_id': child_pack.location_id.id, | ||
1001 | 415 | 'location_dest_id': destination_id, | ||
1002 | 416 | }) | ||
1003 | 417 | for move_data in child_pack.move_ids: | ||
1004 | 418 | if move_data.location_dest_id.id != origin_id: | ||
1005 | 419 | new_move_id = stock_move_obj.create(cr, uid, {'name': move_data.name, | ||
1006 | 420 | 'state': 'draft', | ||
1007 | 421 | 'product_id': move_data.product_id.id, | ||
1008 | 422 | 'product_uom': move_data.product_uom.id, | ||
1009 | 423 | 'prodlot_id': move_data.prodlot_id.id, | ||
1010 | 424 | 'location_id': move_data.location_dest_id.id, | ||
1011 | 425 | 'location_dest_id': origin_id, | ||
1012 | 426 | }) | ||
1013 | 427 | '''new move creation''' | ||
1014 | 428 | for move in child_pack.current_move_ids: | ||
1015 | 429 | defaults = { | ||
1016 | 430 | 'location_id': origin_id, | ||
1017 | 431 | 'location_dest_id': destination_id, | ||
1018 | 432 | 'picking_id': order_id | ||
1019 | 433 | } | ||
1020 | 434 | new_id = stock_move_obj.copy(cr, uid, move.id, default=defaults, context=context) | ||
1021 | 435 | stock_move_obj.write(cr, uid, [move.id], {'pack_history_id': hist_id, 'move_dest_id': new_id}) | ||
1022 | 436 | |||
1023 | 437 | stock_tracking_obj.write(cr, uid, [child_pack.id], {'location_id': destination_id}) | ||
1024 | 438 | '''End''' | ||
1025 | 439 | return res | ||
1026 | 440 | |||
1027 | 441 | """ | ||
1028 | 442 | ### PACK PREPARATION ### | ||
1029 | 443 | """ | ||
1030 | 444 | def pack_preparation(self, cr, uid, acquisition, context=None): | ||
1031 | 445 | res = {} | ||
1032 | 446 | if context==None: | ||
1033 | 447 | context = {} | ||
1034 | 448 | first_code = True | ||
1035 | 449 | parent_id = False | ||
1036 | 450 | setting_obj = self.pool.get('acquisition.setting') | ||
1037 | 451 | for line in acquisition.acquisition_ids: | ||
1038 | 452 | if first_code == True: | ||
1039 | 453 | first_code = False | ||
1040 | 454 | logistic_unit = acquisition.logistic_unit.id | ||
1041 | 455 | parent_id = setting_obj.create_pack(cr, uid, [acquisition.id], logistic_unit, context) | ||
1042 | 456 | vals = {'pack_id': parent_id} | ||
1043 | 457 | # name = self.pool.get('stock.tracking').browse(cr, uid, parent_id, context=context).name or False | ||
1044 | 458 | # if name: | ||
1045 | 459 | # vals['name'] = name | ||
1046 | 460 | self.write(cr, uid, acquisition.id, vals, context=context) | ||
1047 | 461 | setting_obj.add_child(cr, uid, line.barcode_id.id, parent_id, context) | ||
1048 | 462 | if parent_id: | ||
1049 | 463 | setting_obj.close_pack(cr, uid, [parent_id], context) | ||
1050 | 464 | return res | ||
1051 | 465 | |||
1052 | 466 | """ | ||
1053 | 467 | ### INVENTORY ### | ||
1054 | 468 | """ | ||
1055 | 469 | def inventory_preparation(self, cr, uid, acquisition, context=None): | ||
1056 | 470 | res = {} | ||
1057 | 471 | if context==None: | ||
1058 | 472 | context = {} | ||
1059 | 473 | inventory_id = acquisition.inventory_id or False | ||
1060 | 474 | if not inventory_id: | ||
1061 | 475 | raise osv.except_osv(_('Warning!'),_('There is no inventory, please create one!')) | ||
1062 | 476 | if inventory_id.state != 'draft': | ||
1063 | 477 | raise osv.except_osv(_('Warning!'),_('This inventory is not in draft state, you can\'t continue !')) | ||
1064 | 478 | location_id = acquisition.origin_id or False | ||
1065 | 479 | if not location_id: | ||
1066 | 480 | raise osv.except_osv(_('Warning!'),_('There is no location defined, please select one!')) | ||
1067 | 481 | for line in acquisition.acquisition_ids: | ||
1068 | 482 | self.check_inventory_line(cr, uid, line, context) | ||
1069 | 483 | return res | ||
1070 | 484 | |||
1071 | 485 | def check_inventory_line(self, cr, uid, line, context=None): | ||
1072 | 486 | if context == None: | ||
1073 | 487 | context = {} | ||
1074 | 488 | acquisition = line.acquisition_id | ||
1075 | 489 | barcode = line.barcode_id | ||
1076 | 490 | production_lot_obj = self.pool.get('stock.production.lot') | ||
1077 | 491 | inventory_line_obj = self.pool.get('stock.inventory.line') | ||
1078 | 492 | product_obj = self.pool.get('product.product') | ||
1079 | 493 | inventory_id = acquisition.inventory_id and acquisition.inventory_id.id or False | ||
1080 | 494 | location_id = acquisition.origin_id and acquisition.origin_id.id or False | ||
1081 | 495 | logistic_unit_id = barcode.res_id | ||
1082 | 496 | |||
1083 | 497 | if barcode.res_model == 'stock.production.lot': | ||
1084 | 498 | """ Production Lot Case """ | ||
1085 | 499 | """ TODO What if the production lot is in a tracking ? """ | ||
1086 | 500 | production_lot = production_lot_obj.browse(cr, uid, logistic_unit_id) | ||
1087 | 501 | product = production_lot.product_id | ||
1088 | 502 | lot_id = production_lot.id | ||
1089 | 503 | vals = { | ||
1090 | 504 | 'inventory_id': inventory_id, | ||
1091 | 505 | 'location_id': location_id, | ||
1092 | 506 | 'product_id': product.id, | ||
1093 | 507 | 'product_uom': product.uom_id.id, | ||
1094 | 508 | 'product_qty': 1, | ||
1095 | 509 | 'prod_lot_id': lot_id, | ||
1096 | 510 | } | ||
1097 | 511 | line_ids = inventory_line_obj.search(cr, uid, [('inventory_id', '=', inventory_id), ('product_id', '=', product.id), ('prod_lot_id', '=', lot_id)]) | ||
1098 | 512 | if line_ids: | ||
1099 | 513 | inventory_line_obj.write(cr, uid, [line_ids[0]], vals) | ||
1100 | 514 | else: | ||
1101 | 515 | inventory_line_obj.create(cr, uid, vals) | ||
1102 | 516 | |||
1103 | 517 | elif barcode.res_model == 'product.product': | ||
1104 | 518 | """ Product Case """ | ||
1105 | 519 | product = product_obj.browse(cr, uid, logistic_unit_id) | ||
1106 | 520 | vals = { | ||
1107 | 521 | 'inventory_id': inventory_id, | ||
1108 | 522 | 'location_id': location_id, | ||
1109 | 523 | 'product_id': product.id, | ||
1110 | 524 | 'product_uom': product.uom_id.id, | ||
1111 | 525 | } | ||
1112 | 526 | line_ids = inventory_line_obj.search(cr, uid, [('inventory_id', '=', inventory_id), ('product_id', '=', product.id), ('location_id', '=', location_id)]) | ||
1113 | 527 | if line_ids: | ||
1114 | 528 | qty = inventory_line_obj.read(cr, uid, line_ids[0], ['product_qty'])['product_qty'] | ||
1115 | 529 | vals_update = vals | ||
1116 | 530 | vals_update.update({'product_qty': qty >= 0 and qty + line.quantity or line.quantity}) | ||
1117 | 531 | inventory_line_obj.write(cr, uid, [line_ids[0]], vals_update) | ||
1118 | 532 | else: | ||
1119 | 533 | vals_create = vals | ||
1120 | 534 | vals_create.update({'product_qty': line.quantity}) | ||
1121 | 535 | inventory_line_obj.create(cr, uid, vals_create) | ||
1122 | 536 | |||
1123 | 537 | """ | ||
1124 | 538 | ### MOVE STOCK CREATION ### | ||
1125 | 539 | """ | ||
1126 | 540 | def move_stock_preparation(self, cr, uid, acquisition, context=None): | ||
1127 | 541 | res = {} | ||
1128 | 542 | if context==None: | ||
1129 | 543 | context = {} | ||
1130 | 544 | first_code = True | ||
1131 | 545 | move_stock_id = False | ||
1132 | 546 | name = False | ||
1133 | 547 | vals = {} | ||
1134 | 548 | for line in acquisition.acquisition_ids: | ||
1135 | 549 | if first_code == True: | ||
1136 | 550 | first_code = False | ||
1137 | 551 | move_stock_id = self.create_move_stock(cr, uid, [acquisition.id], context=context) | ||
1138 | 552 | # name = self.pool.get('stock.inventory').browse(cr, uid, move_stock_id, context=context).name or False | ||
1139 | 553 | self.add_stock_move_line(cr, uid, [acquisition.id], line, move_stock_id, context) | ||
1140 | 554 | if move_stock_id: | ||
1141 | 555 | vals['move_stock_id'] = move_stock_id | ||
1142 | 556 | self.write(cr, uid, acquisition.id, vals, context=context) | ||
1143 | 557 | return res | ||
1144 | 558 | |||
1145 | 559 | def create_move_stock(self, cr, uid, ids, context=None): | ||
1146 | 560 | '''init''' | ||
1147 | 561 | if context == None: | ||
1148 | 562 | context = {} | ||
1149 | 563 | acquisition_data = self.browse(cr, uid, ids[0]) | ||
1150 | 564 | stock_inventory_obj = self.pool.get('stock.inventory') | ||
1151 | 565 | |||
1152 | 566 | '''variables''' | ||
1153 | 567 | origin_id = acquisition_data.origin_id.id | ||
1154 | 568 | destination_id = acquisition_data.move_stock_destination.id | ||
1155 | 569 | date = acquisition_data.move_stock_date | ||
1156 | 570 | ''''inventory creation''' | ||
1157 | 571 | context.update({'type':'move'}) | ||
1158 | 572 | move_stock_id = stock_inventory_obj.create(cr, uid, { | ||
1159 | 573 | 'type': 'move', | ||
1160 | 574 | 'date_done': date, | ||
1161 | 575 | 'location_id': origin_id, | ||
1162 | 576 | 'location_dest_id': destination_id, | ||
1163 | 577 | }, context=context) | ||
1164 | 578 | '''End''' | ||
1165 | 579 | return move_stock_id | ||
1166 | 580 | |||
1167 | 581 | def add_stock_move_line(self, cr, uid, ids, line, inventory_id, inventory_line_id, context=None): | ||
1168 | 582 | res = {} | ||
1169 | 583 | '''init''' | ||
1170 | 584 | if context == None: | ||
1171 | 585 | context = {} | ||
1172 | 586 | barcode_obj = self.pool.get('tr.barcode') | ||
1173 | 587 | stock_production_lot_obj = self.pool.get('stock.production.lot') | ||
1174 | 588 | inventory_line_obj = self.pool.get('stock.inventory.line') | ||
1175 | 589 | stock_tracking_obj = self.pool.get('stock.tracking') | ||
1176 | 590 | product_obj = self.pool.get('product.product') | ||
1177 | 591 | barcode_id = line.barcode_id.id | ||
1178 | 592 | barcode_data = barcode_obj.browse(cr, uid, barcode_id, context=context) | ||
1179 | 593 | acquisition_data = self.browse(cr, uid, ids[0], context=context) | ||
1180 | 594 | |||
1181 | 595 | location_id = acquisition_data.origin_id.id | ||
1182 | 596 | logistic_unit_id = barcode_data.res_id | ||
1183 | 597 | if barcode_data.res_model == 'stock.production.lot': | ||
1184 | 598 | stock_production_lot_data = stock_production_lot_obj.browse(cr, uid, logistic_unit_id, context=context) | ||
1185 | 599 | product = stock_production_lot_data.product_id | ||
1186 | 600 | logistic_unit_number = stock_production_lot_data.id | ||
1187 | 601 | vals = { | ||
1188 | 602 | 'inventory_id': inventory_id, | ||
1189 | 603 | 'location_id': location_id, | ||
1190 | 604 | 'product_id': product.id, | ||
1191 | 605 | 'product_uom': product.uom_id.id, | ||
1192 | 606 | 'product_qty': 1, | ||
1193 | 607 | 'prod_lot_id':logistic_unit_number} | ||
1194 | 608 | inventory_line_obj.create(cr, uid, vals) | ||
1195 | 609 | elif barcode_data.res_model == 'product.product': | ||
1196 | 610 | product_data = product_obj.browse(cr, uid, logistic_unit_id) | ||
1197 | 611 | vals = { | ||
1198 | 612 | 'inventory_id': inventory_id, | ||
1199 | 613 | 'location_id': location_id, | ||
1200 | 614 | 'product_id': product_data.id, | ||
1201 | 615 | 'product_uom': product_data.uom_id.id, | ||
1202 | 616 | 'product_qty': line.quantity} | ||
1203 | 617 | inventory_line_obj.create(cr, uid, vals) | ||
1204 | 618 | elif barcode_data.res_model == 'stock.tracking': | ||
1205 | 619 | stock_tracking_data = stock_tracking_obj.browse(cr, uid, logistic_unit_id) | ||
1206 | 620 | if stock_tracking_data.parent_id: | ||
1207 | 621 | raise osv.except_osv(_('Warning!'),_('You cannot move this pack because it\'s inside of an other pack: %s.') % (stock_tracking_data.parent_id.name)) | ||
1208 | 622 | for child in stock_tracking_data.child_ids: | ||
1209 | 623 | if child.state != 'close': | ||
1210 | 624 | raise osv.except_osv(_('Warning!'),_('You cannot move this pack because there is a none closed pack inside of it: %s.') % (child.name)) | ||
1211 | 625 | |||
1212 | 626 | raise osv.except_osv(_('Warning!'),_('Not developed yet')) | ||
1213 | 627 | |||
1214 | 628 | return res | ||
1215 | 629 | |||
1216 | 630 | acquisition_acquisition() | ||
1217 | 631 | |||
1218 | 632 | class acquisition_list(osv.osv): | ||
1219 | 633 | |||
1220 | 634 | _name = "acquisition.list" | ||
1221 | 635 | _columns = { | ||
1222 | 636 | 'name': fields.char('List Name', size=128), | ||
1223 | 637 | 'barcode_id': fields.many2one('tr.barcode', 'Barcode', readonly=True), | ||
1224 | 638 | 'acquisition_id': fields.many2one('acquisition.acquisition','Acquisition'), | ||
1225 | 639 | 'type': fields.selection([ | ||
1226 | 640 | ('object','Logistic Unit'), | ||
1227 | 641 | ('create_add', 'Create a pack and add a logistic unit'), | ||
1228 | 642 | ('create_pack','Create a pack'), | ||
1229 | 643 | ('add_child','Add a logistic unit'), | ||
1230 | 644 | ('close_pack','Close a pack'), | ||
1231 | 645 | ], 'Action Type', size=32), | ||
1232 | 646 | 'quantity': fields.float('Quantity'), | ||
1233 | 647 | } | ||
1234 | 648 | |||
1235 | 649 | _defaults = { | ||
1236 | 650 | 'quantity': 1, | ||
1237 | 651 | } | ||
1238 | 652 | |||
1239 | 653 | def on_change_quantity(self, cr, uid, ids, quantity=1, barcode_id=False, context=None): | ||
1240 | 654 | res = {'value': {'quantity': 1}} | ||
1241 | 655 | if context == None: | ||
1242 | 656 | context = {} | ||
1243 | 657 | if barcode_id: | ||
1244 | 658 | if self.pool.get('tr.barcode').browse(cr, uid, barcode_id).res_model == 'product.product': | ||
1245 | 659 | res = {'value': {'quantity' : quantity}} | ||
1246 | 660 | return res | ||
1247 | 661 | |||
1248 | 662 | def _check_quantity(self, cr, uid, ids, context=None): | ||
1249 | 663 | for record in self.browse(cr, uid, ids, context=context): | ||
1250 | 664 | if record.quantity != 1 and record.barcode_id.res_model!='product.product': | ||
1251 | 665 | return False | ||
1252 | 666 | return True | ||
1253 | 667 | |||
1254 | 668 | _constraints = [ | ||
1255 | 669 | (_check_quantity, | ||
1256 | 670 | 'You assigned a wrong quantity for this line', | ||
1257 | 671 | ['name']), | ||
1258 | 672 | ] | ||
1259 | 673 | |||
1260 | 674 | acquisition_list() | ||
1261 | 675 | |||
1262 | 676 | class acquisition_setting(osv.osv): | ||
1263 | 677 | |||
1264 | 678 | _name = "acquisition.setting" | ||
1265 | 679 | _columns = { | ||
1266 | 680 | 'barcode_id': fields.many2one('tr.barcode', 'Barcode', required=True, readonly=False), | ||
1267 | 681 | 'action_type': fields.selection([ | ||
1268 | 682 | ('create_add', 'Create a pack and add a logistic unit'), | ||
1269 | 683 | ('create_pack','Create a pack'), | ||
1270 | 684 | ('add_child','Add a logistic unit'), | ||
1271 | 685 | ('close_pack','Close a pack'), | ||
1272 | 686 | ], 'Action Type', size=32, required=True, help="Selection of an action"), | ||
1273 | 687 | } | ||
1274 | 688 | |||
1275 | 689 | # def create_add(self, cr, uid, ids, ul_id, context=None): | ||
1276 | 690 | # if context == None: | ||
1277 | 691 | # context = {} | ||
1278 | 692 | # tracking_id = self.create_pack(cr, uid, ids, ul_id, context) | ||
1279 | 693 | # return tracking_id | ||
1280 | 694 | |||
1281 | 695 | def do_action(self, cr, uid, ids, action_type, context=None): | ||
1282 | 696 | if context == None: | ||
1283 | 697 | context = {} | ||
1284 | 698 | tracking_id = False | ||
1285 | 699 | if action_type == 'create_add': | ||
1286 | 700 | tracking_id = self.create_pack(cr, uid, ids, context=context) | ||
1287 | 701 | elif action_type == 'close_pack': | ||
1288 | 702 | tracking_to_close_id = context.get('tracking_id', False) | ||
1289 | 703 | if tracking_to_close_id: | ||
1290 | 704 | self.close_pack(cr, uid, [tracking_to_close_id], context=context) | ||
1291 | 705 | return tracking_id | ||
1292 | 706 | |||
1293 | 707 | '''Function for pack creation''' | ||
1294 | 708 | def create_pack(self, cr, uid, ids, ul_id=None, context=None): | ||
1295 | 709 | '''Init''' | ||
1296 | 710 | res = {} | ||
1297 | 711 | stock_tracking_obj = self.pool.get('stock.tracking') | ||
1298 | 712 | if context == None: | ||
1299 | 713 | context = {} | ||
1300 | 714 | '''Location determination''' | ||
1301 | 715 | acquisition_data = self.pool.get('acquisition.acquisition').browse(cr, uid, ids[0]) | ||
1302 | 716 | location_id = acquisition_data.origin_id.id | ||
1303 | 717 | if ul_id == None: | ||
1304 | 718 | ul_id = self.pool.get('product.ul').search(cr, uid, [], limit=1)[0] | ||
1305 | 719 | logistic_unit = ul_id | ||
1306 | 720 | '''Pack Creation''' | ||
1307 | 721 | tracking_id = stock_tracking_obj.create(cr, uid, {'ul_id': logistic_unit, 'location_id': location_id}) | ||
1308 | 722 | '''Pack name is returned''' | ||
1309 | 723 | return tracking_id | ||
1310 | 724 | |||
1311 | 725 | def add_child(self, cr, uid, barcode_id, parent_id, context=None): | ||
1312 | 726 | '''Init''' | ||
1313 | 727 | res = {} | ||
1314 | 728 | barcode_obj = self.pool.get('tr.barcode') | ||
1315 | 729 | tracking_obj = self.pool.get('stock.tracking') | ||
1316 | 730 | if context == None: | ||
1317 | 731 | context = {} | ||
1318 | 732 | '''Get barcode number''' | ||
1319 | 733 | barcode_data = barcode_obj.browse(cr, uid, barcode_id) | ||
1320 | 734 | barcode_code = barcode_data.code | ||
1321 | 735 | ''' Call of adding function ''' | ||
1322 | 736 | tracking_obj.add_validation(cr, uid, [parent_id], [barcode_id], context=None) | ||
1323 | 737 | return res | ||
1324 | 738 | |||
1325 | 739 | def close_pack(self, cr, uid, ids, context=None): | ||
1326 | 740 | '''init''' | ||
1327 | 741 | if context == None: | ||
1328 | 742 | context = {} | ||
1329 | 743 | tracking_obj = self.pool.get('stock.tracking') | ||
1330 | 744 | '''Call of the function in stock_tracking_reopen''' | ||
1331 | 745 | tracking_obj.set_close(cr, uid, ids, context) | ||
1332 | 746 | '''Call of the function in stock_tracking_reopen''' | ||
1333 | 747 | if self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).picking_id: | ||
1334 | 748 | origin_id = self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).origin_id.id | ||
1335 | 749 | destination_id = self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).destination_id.id | ||
1336 | 750 | stock_move_ids = self.pool.get('stock.move').search(cr, uid, [('tracking_id','=',ids[0])]) | ||
1337 | 751 | for stock_move_id in stock_move_ids: | ||
1338 | 752 | stock_move_data = self.pool.get('stock.move').browse(cr, uid, stock_move_id, context) | ||
1339 | 753 | self.pool.get('stock.move').write(cr, uid, stock_move_id, {'state':'done', 'picking_id': False, 'location_dest_id': origin_id}, context) | ||
1340 | 754 | self.pool.get('stock.move').create(cr, uid, {'name': stock_move_data.name, | ||
1341 | 755 | 'state': 'draft', | ||
1342 | 756 | 'product_id': stock_move_data.product_id.id, | ||
1343 | 757 | 'product_uom': stock_move_data.product_uom.id, | ||
1344 | 758 | 'prodlot_id': stock_move_data.prodlot_id.id, | ||
1345 | 759 | 'tracking_id': stock_move_data.tracking_id.id, | ||
1346 | 760 | 'picking_id': self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).picking_id.id, | ||
1347 | 761 | 'location_id': stock_move_data.location_dest_id.id, | ||
1348 | 762 | 'location_dest_id': destination_id, | ||
1349 | 763 | }) | ||
1350 | 764 | '''Call for a function who will display serial code list and product list in the pack layout''' | ||
1351 | 765 | tracking_obj.get_products(cr, uid, ids, context=None) | ||
1352 | 766 | tracking_obj.get_serials(cr, uid, ids, context=None) | ||
1353 | 767 | return True | ||
1354 | 768 | |||
1355 | 769 | |||
1356 | 770 | |||
1357 | 771 | # def create_inventory(self, cr, uid, ids, context=None): | ||
1358 | 772 | # '''init''' | ||
1359 | 773 | # if context == None: | ||
1360 | 774 | # context = {} | ||
1361 | 775 | # acquisition_obj = self.pool.get('acquisition.acquisition') | ||
1362 | 776 | # acquisition_data = acquisition_obj.browse(cr, uid, ids[0]) | ||
1363 | 777 | # stock_inventory_obj = self.pool.get('stock.inventory') | ||
1364 | 778 | # '''variables''' | ||
1365 | 779 | # date = acquisition_data.inventory_date | ||
1366 | 780 | # ''''inventory creation''' | ||
1367 | 781 | # inventory_id = stock_inventory_obj.create(cr, uid, {'date_done': date}) | ||
1368 | 782 | # '''End''' | ||
1369 | 783 | # return inventory_id | ||
1370 | 784 | |||
1371 | 785 | |||
1372 | 786 | |||
1373 | 787 | # for line in inventory_data.inventory_line_id: | ||
1374 | 788 | # if line.product_id.id == product_data.id: | ||
1375 | 789 | # in_inventory = True | ||
1376 | 790 | # inventory_line_obj.write(cr, uid, [line.id], {'product_qty': 1}) | ||
1377 | 791 | # elif in_inventory == False: | ||
1378 | 792 | # in_inventory = True | ||
1379 | 793 | # vals = { | ||
1380 | 794 | # 'inventory_id': inventory_data.id, | ||
1381 | 795 | # 'location_id': location_id, | ||
1382 | 796 | # 'product_id': product_data.id, | ||
1383 | 797 | # 'product_uom': product_data.uom_id.id, | ||
1384 | 798 | # 'product_qty': 1} | ||
1385 | 799 | # inventory_line_obj.create(cr, uid, vals) | ||
1386 | 800 | |||
1387 | 801 | |||
1388 | 802 | |||
1389 | 803 | acquisition_setting() | ||
1390 | 804 | |||
1391 | 805 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1392 | 0 | 806 | ||
1393 | === added directory 'stock_barcode_reader/security' | |||
1394 | === added file 'stock_barcode_reader/security/ir.model.access.csv' | |||
1395 | --- stock_barcode_reader/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 | |||
1396 | +++ stock_barcode_reader/security/ir.model.access.csv 2012-11-19 11:44:21 +0000 | |||
1397 | @@ -0,0 +1,7 @@ | |||
1398 | 1 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
1399 | 2 | "access_acquisition_acquisition_manager","acquisition.aquisition.manager","model_acquisition_acquisition","stock.group_stock_manager",1,1,1,1 | ||
1400 | 3 | "access_acquisition_acquisition_user","acquisition.aquisition.manager","model_acquisition_acquisition","stock.group_stock_user",1,1,1,0 | ||
1401 | 4 | "access_acquisition_list_manager","acquisition.list.manager","model_acquisition_list","stock.group_stock_manager",1,1,1,1 | ||
1402 | 5 | "access_acquisition_list_user","acquisition.list.manager","model_acquisition_list","stock.group_stock_user",1,1,1,1 | ||
1403 | 6 | "access_acquisition_setting_manager","acquisition.setting.manager","model_acquisition_setting","stock.group_stock_manager",1,1,1,1 | ||
1404 | 7 | "access_acquisition_setting_user","acquisition.setting.manager","model_acquisition_setting","stock.group_stock_user",1,1,1,1 | ||
1405 | 0 | 8 | ||
1406 | === added file 'stock_barcode_reader/stock.py' | |||
1407 | --- stock_barcode_reader/stock.py 1970-01-01 00:00:00 +0000 | |||
1408 | +++ stock_barcode_reader/stock.py 2012-11-19 11:44:21 +0000 | |||
1409 | @@ -0,0 +1,56 @@ | |||
1410 | 1 | # -*- coding: utf-8 -*- | ||
1411 | 2 | ################################################################################# | ||
1412 | 3 | # | ||
1413 | 4 | # OpenERP, Open Source Management Solution | ||
1414 | 5 | # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> | ||
1415 | 6 | # | ||
1416 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1417 | 8 | # it under the terms of the GNU General Public License as published by | ||
1418 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
1419 | 10 | # (at your option) any later version. | ||
1420 | 11 | # | ||
1421 | 12 | # This program is distributed in the hope that it will be useful, | ||
1422 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1423 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1424 | 15 | # GNU General Public License for more details. | ||
1425 | 16 | # | ||
1426 | 17 | # You should have received a copy of the GNU General Public License | ||
1427 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1428 | 19 | # | ||
1429 | 20 | ################################################################################# | ||
1430 | 21 | |||
1431 | 22 | from osv import osv,fields | ||
1432 | 23 | from tools.translate import _ | ||
1433 | 24 | |||
1434 | 25 | class stock_picking(osv.osv): | ||
1435 | 26 | _inherit = "stock.picking" | ||
1436 | 27 | |||
1437 | 28 | def start_acquisition(self, cr, uid, ids, context=None): | ||
1438 | 29 | if context == None: | ||
1439 | 30 | context = {} | ||
1440 | 31 | active = self.browse(cr, uid, ids[0]) | ||
1441 | 32 | name = active.name | ||
1442 | 33 | action_context = {'default_type': 'order', 'default_name': 'Preparation ' + name, 'default_picking_id': ids[0]} | ||
1443 | 34 | address_id = active.address_id and active.address_id.id or False | ||
1444 | 35 | if address_id: | ||
1445 | 36 | action_context.update({'default_address_id': address_id}) | ||
1446 | 37 | location_id = False | ||
1447 | 38 | for move in active.move_lines: | ||
1448 | 39 | location_id = move.location_dest_id and move.location_dest_id.id or False | ||
1449 | 40 | if location_id: | ||
1450 | 41 | action_context.update({'default_destination_id': location_id}) | ||
1451 | 42 | break | ||
1452 | 43 | action = { | ||
1453 | 44 | 'type': 'ir.actions.act_window', | ||
1454 | 45 | 'view_type': 'form', | ||
1455 | 46 | 'view_mode': 'form', | ||
1456 | 47 | 'res_model': 'acquisition.acquisition', | ||
1457 | 48 | 'view_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock_barcode_reader', 'view_stock_tracking_acquisition_form')[1], | ||
1458 | 49 | # 'menu_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'menu_stock_root')[1], | ||
1459 | 50 | 'context': action_context | ||
1460 | 51 | } | ||
1461 | 52 | return action | ||
1462 | 53 | |||
1463 | 54 | stock_picking() | ||
1464 | 55 | |||
1465 | 56 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1466 | 0 | 57 | ||
1467 | === added file 'stock_barcode_reader/stock_view.xml' | |||
1468 | --- stock_barcode_reader/stock_view.xml 1970-01-01 00:00:00 +0000 | |||
1469 | +++ stock_barcode_reader/stock_view.xml 2012-11-19 11:44:21 +0000 | |||
1470 | @@ -0,0 +1,31 @@ | |||
1471 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1472 | 2 | <openerp> | ||
1473 | 3 | <data> | ||
1474 | 4 | |||
1475 | 5 | <record id="view_picking_form" model="ir.ui.view"> | ||
1476 | 6 | <field name="name">stock.picking.form</field> | ||
1477 | 7 | <field name="model">stock.picking</field> | ||
1478 | 8 | <field name="type">form</field> | ||
1479 | 9 | <field eval="12" name="priority"/> | ||
1480 | 10 | <field name="inherit_id" ref="stock.view_picking_form"/> | ||
1481 | 11 | <field name="arch" type="xml"> | ||
1482 | 12 | <button name="action_process" position="before"> | ||
1483 | 13 | <button name="start_acquisition" string="Start Acquisition" states="assigned,confirmed,draft" type="object" icon="gtk-go-forward"/> | ||
1484 | 14 | </button> | ||
1485 | 15 | </field> | ||
1486 | 16 | </record> | ||
1487 | 17 | |||
1488 | 18 | <record id="view_delivery_order_inherit_stock_barcode" model="ir.ui.view"> | ||
1489 | 19 | <field name="name">stock.picking.out.barcode.form</field> | ||
1490 | 20 | <field name="type">form</field> | ||
1491 | 21 | <field name="model">stock.picking</field> | ||
1492 | 22 | <field name="inherit_id" ref="stock.view_picking_out_form"/> | ||
1493 | 23 | <field name="arch" type="xml"> | ||
1494 | 24 | <button name="action_process" position="before"> | ||
1495 | 25 | <button name="start_acquisition" string="Start Acquisition" states="assigned,confirmed,draft" type="object" icon="gtk-go-forward"/> | ||
1496 | 26 | </button> | ||
1497 | 27 | </field> | ||
1498 | 28 | </record> | ||
1499 | 29 | |||
1500 | 30 | </data> | ||
1501 | 31 | </openerp> | ||
1502 | 0 | 32 | ||
1503 | === added directory 'stock_barcode_reader/wizard' | |||
1504 | === added file 'stock_barcode_reader/wizard/__init__.py' | |||
1505 | --- stock_barcode_reader/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
1506 | +++ stock_barcode_reader/wizard/__init__.py 2012-11-19 11:44:21 +0000 | |||
1507 | @@ -0,0 +1,24 @@ | |||
1508 | 1 | # -*- coding: utf-8 -*- | ||
1509 | 2 | ################################################################################# | ||
1510 | 3 | # | ||
1511 | 4 | # OpenERP, Open Source Management Solution | ||
1512 | 5 | # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> | ||
1513 | 6 | # | ||
1514 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1515 | 8 | # it under the terms of the GNU General Public License as published by | ||
1516 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
1517 | 10 | # (at your option) any later version. | ||
1518 | 11 | # | ||
1519 | 12 | # This program is distributed in the hope that it will be useful, | ||
1520 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1521 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1522 | 15 | # GNU General Public License for more details. | ||
1523 | 16 | # | ||
1524 | 17 | # You should have received a copy of the GNU General Public License | ||
1525 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1526 | 19 | # | ||
1527 | 20 | ################################################################################# | ||
1528 | 21 | |||
1529 | 22 | import reference | ||
1530 | 23 | |||
1531 | 24 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1532 | 0 | \ No newline at end of file | 25 | \ No newline at end of file |
1533 | 1 | 26 | ||
1534 | === added file 'stock_barcode_reader/wizard/reference.py' | |||
1535 | --- stock_barcode_reader/wizard/reference.py 1970-01-01 00:00:00 +0000 | |||
1536 | +++ stock_barcode_reader/wizard/reference.py 2012-11-19 11:44:21 +0000 | |||
1537 | @@ -0,0 +1,100 @@ | |||
1538 | 1 | # -*- coding: utf-8 -*- | ||
1539 | 2 | ################################################################################# | ||
1540 | 3 | # | ||
1541 | 4 | # OpenERP, Open Source Management Solution | ||
1542 | 5 | # Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr> | ||
1543 | 6 | # | ||
1544 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1545 | 8 | # it under the terms of the GNU General Public License as published by | ||
1546 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
1547 | 10 | # (at your option) any later version. | ||
1548 | 11 | # | ||
1549 | 12 | # This program is distributed in the hope that it will be useful, | ||
1550 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1551 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1552 | 15 | # GNU General Public License for more details. | ||
1553 | 16 | # | ||
1554 | 17 | # You should have received a copy of the GNU General Public License | ||
1555 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1556 | 19 | # | ||
1557 | 20 | ################################################################################# | ||
1558 | 21 | |||
1559 | 22 | from osv import osv,fields | ||
1560 | 23 | from tools.translate import _ | ||
1561 | 24 | |||
1562 | 25 | class stock_reference(osv.osv_memory): | ||
1563 | 26 | |||
1564 | 27 | _name = "stock.reference" | ||
1565 | 28 | _description = 'Products Acquisition' | ||
1566 | 29 | |||
1567 | 30 | # _rec_name = 'reference' | ||
1568 | 31 | |||
1569 | 32 | def _get_track_id(self, cr, uid, context=None): | ||
1570 | 33 | if context == None: | ||
1571 | 34 | context = {} | ||
1572 | 35 | return context.get('active_id',False) | ||
1573 | 36 | |||
1574 | 37 | _columns = { | ||
1575 | 38 | # 'barcode_id': fields.many2one('tr.barcode', 'Reference', required=True), | ||
1576 | 39 | 'reference': fields.char('Reference', size=128, required=True), | ||
1577 | 40 | 'track_id': fields.many2one('acquisition.acquisition','Track id', required=True), | ||
1578 | 41 | 'text': fields.text('Barcode list',readonly=True), | ||
1579 | 42 | # 'bad_barcode': fields.text('Bad barcode list',readonly=True), | ||
1580 | 43 | } | ||
1581 | 44 | |||
1582 | 45 | _defaults = { | ||
1583 | 46 | 'track_id': _get_track_id, | ||
1584 | 47 | } | ||
1585 | 48 | |||
1586 | 49 | def onchange_reference(self, cr, uid, ids, reference, track_id, barcode_list=''): | ||
1587 | 50 | |||
1588 | 51 | res = {} | ||
1589 | 52 | barcode_obj = self.pool.get('tr.barcode') | ||
1590 | 53 | acquisition_list = self.pool.get('acquisition.list') | ||
1591 | 54 | acquisition_setting = self.pool.get('acquisition.setting') | ||
1592 | 55 | |||
1593 | 56 | text = barcode_list or '' | ||
1594 | 57 | |||
1595 | 58 | if reference: | ||
1596 | 59 | barcode_ids = barcode_obj.search(cr, uid, [('code', '=', reference)], limit=1) | ||
1597 | 60 | if not barcode_ids: | ||
1598 | 61 | reference2 = reference | ||
1599 | 62 | while len(reference2.split('-')) > 1: | ||
1600 | 63 | reference2 = reference2.replace('-','') | ||
1601 | 64 | barcode_ids = barcode_obj.search(cr, uid, [('code2', '=', reference2)], limit=1) | ||
1602 | 65 | |||
1603 | 66 | if barcode_ids: | ||
1604 | 67 | barcode_type = 'object' | ||
1605 | 68 | line_ids = acquisition_list.search(cr, uid, [('barcode_id', '=', barcode_ids[0]), ('acquisition_id', '=', track_id)]) | ||
1606 | 69 | setting_ids = acquisition_setting.search(cr, uid, [('barcode_id', '=', barcode_ids[0])], limit=1) | ||
1607 | 70 | |||
1608 | 71 | if setting_ids: | ||
1609 | 72 | setting_data = acquisition_setting.browse(cr, uid, setting_ids) | ||
1610 | 73 | barcode_type = setting_data[0].action_type | ||
1611 | 74 | create = True | ||
1612 | 75 | if line_ids: | ||
1613 | 76 | create = False | ||
1614 | 77 | line_barcode = barcode_obj.read(cr, uid, barcode_ids[0], ['res_model']) | ||
1615 | 78 | if line_barcode.get('res_model',False) == 'product.product' or setting_ids: | ||
1616 | 79 | create = True | ||
1617 | 80 | if create: | ||
1618 | 81 | acquisition_list.create(cr, uid, { | ||
1619 | 82 | 'barcode_id': barcode_ids[0], | ||
1620 | 83 | 'acquisition_id': track_id, | ||
1621 | 84 | 'type': barcode_type, | ||
1622 | 85 | }) | ||
1623 | 86 | text = reference + '\n' + text | ||
1624 | 87 | |||
1625 | 88 | else: | ||
1626 | 89 | raise osv.except_osv(_('Warning!'),_('Barcode Not found!')) # Return of the wraning msg !! | ||
1627 | 90 | ## bad_barcode = bad_barcode_list or '' | ||
1628 | 91 | # bad_barcode += reference | ||
1629 | 92 | # if bad_barcode: | ||
1630 | 93 | # bad_barcode += '\n' | ||
1631 | 94 | |||
1632 | 95 | |||
1633 | 96 | return {'value': {'reference' : False, 'text' : text}} | ||
1634 | 97 | |||
1635 | 98 | stock_reference() | ||
1636 | 99 | |||
1637 | 100 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1638 | 0 | 101 | ||
1639 | === added file 'stock_barcode_reader/wizard/reference_view.xml' | |||
1640 | --- stock_barcode_reader/wizard/reference_view.xml 1970-01-01 00:00:00 +0000 | |||
1641 | +++ stock_barcode_reader/wizard/reference_view.xml 2012-11-19 11:44:21 +0000 | |||
1642 | @@ -0,0 +1,41 @@ | |||
1643 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1644 | 2 | <openerp> | ||
1645 | 3 | <data> | ||
1646 | 4 | |||
1647 | 5 | <record id="view_stock_reference" model="ir.ui.view" > | ||
1648 | 6 | <field name="name">Acquisition.reference.view</field> | ||
1649 | 7 | <field name="model">stock.reference</field> | ||
1650 | 8 | <field name="type">form</field> | ||
1651 | 9 | <field name="arch" type="xml"> | ||
1652 | 10 | <form string="Reference acquisistion"> | ||
1653 | 11 | <group width="400" height="100"> | ||
1654 | 12 | <group colspan="4"> | ||
1655 | 13 | <field name="reference" on_change="onchange_reference(reference,track_id,text)" colspan="4"/> | ||
1656 | 14 | <field name="track_id" colspan="2" invisible="1"/> | ||
1657 | 15 | <newline/> | ||
1658 | 16 | <separator string="End of Acquisition" colspan="4"/> | ||
1659 | 17 | <button special="cancel" string="Close" icon="gtk-ok"/> | ||
1660 | 18 | <newline/> | ||
1661 | 19 | <separator string="Barcode list" colspan="4"/> | ||
1662 | 20 | <field name="text" colspan="4" nolabel="1"/> | ||
1663 | 21 | <!--<newline/> | ||
1664 | 22 | <separator string="Bad Barcode" colspan="4"/> | ||
1665 | 23 | <field name="bad_barcode" colspan="2" nolabel="1"/>--> | ||
1666 | 24 | </group> | ||
1667 | 25 | </group> | ||
1668 | 26 | </form> | ||
1669 | 27 | </field> | ||
1670 | 28 | </record> | ||
1671 | 29 | |||
1672 | 30 | <record id="action_stock_reference" model="ir.actions.act_window"> | ||
1673 | 31 | <field name="name">Reference</field> | ||
1674 | 32 | <field name="type">ir.actions.act_window</field> | ||
1675 | 33 | <field name="res_model">stock.reference</field> | ||
1676 | 34 | <field name="view_type">form</field> | ||
1677 | 35 | <field name="view_mode">form</field> | ||
1678 | 36 | <field name="view_id" ref="view_stock_reference"/> | ||
1679 | 37 | <field name="target">new</field> | ||
1680 | 38 | </record> | ||
1681 | 39 | |||
1682 | 40 | </data> | ||
1683 | 41 | </openerp> |
ok for me