Merge lp:~jgrandguillaume-c2c/stock-logistic-tracking/move-stock-barcode-reader into lp:stock-logistic-tracking/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
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Alexandre Fayolle - camptocamp Approve
Review via email: mp+134874@code.launchpad.net

Description of the change

Move the stock-barcode-reader module to the right project according to bug report : https://bugs.launchpad.net/stock-logistic-barcode/+bug/1079738

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

ok for me

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

Subscribers

People subscribed via source and target branches