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
=== added directory 'stock_barcode_reader'
=== added file 'stock_barcode_reader/__init__.py'
--- stock_barcode_reader/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/__init__.py 2012-11-19 11:44:21 +0000
@@ -0,0 +1,26 @@
1# -*- coding: utf-8 -*-
2#################################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20#################################################################################
21
22import package_acquisition
23import stock
24import wizard
25
26# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file27\ No newline at end of file
128
=== added file 'stock_barcode_reader/__openerp__.py'
--- stock_barcode_reader/__openerp__.py 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/__openerp__.py 2012-11-19 11:44:21 +0000
@@ -0,0 +1,62 @@
1# -*- coding: utf-8 -*-
2#################################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20#################################################################################
21
22{
23 "name" : "Stock bar code reader",
24 "version" : "1.0",
25 "author" : "Julius Network Solutions",
26 "description" : """
27
28Presentation:
29
30This module is an ergonomic wizard to fill in package.
31Add menu for acquisition of package.
32Add Button in Stock picking for start acquisition.
33
34
35Configuration:
36
37Warehouse>Configuration>Acquisition Setting
38
39This module adds a submenu for acquisition setting with a field Barcode and Action type.
40
41 """,
42 "website" : "http://www.julius.fr",
43 "depends" : [
44 "stock",
45 "stock_tracking_extended",
46 "stock_tracking_add_move",
47 ],
48 "category" : "Customs/Stock",
49 "init_xml" : [],
50 "demo_xml" : [],
51 "images" : ['images/Acquisition.png'],
52 "update_xml" : [
53 'wizard/reference_view.xml',
54 'acquisition_view.xml',
55 'stock_view.xml',
56 'data/acquisition_sequence.xml',
57 "security/ir.model.access.csv",
58 ],
59 'test': [],
60 'installable': True,
61 'active': False,
62}
063
=== added file 'stock_barcode_reader/acquisition_view.xml'
--- stock_barcode_reader/acquisition_view.xml 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/acquisition_view.xml 2012-11-19 11:44:21 +0000
@@ -0,0 +1,163 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5
6 <act_window
7 context="{'default_type':'inventory', 'default_name': 'Scan Inventory '}"
8 id="inventory_acquisition_link_1" name="Inventory Acquisition"
9 res_model="acquisition.acquisition"
10 src_model="stock.inventory"
11 view_mode="form"/>
12
13 <!--<act_window domain="[('inventory_id', '=', active_id)]"
14 context="{'default_type':'move_stock', 'default_name': 'Scan Stock Move', 'default_move_stock_destination': location_id}"
15 id="move_stock_acquisition_link_2" name="Move Stock Acquisition"
16 res_model="acquisition.acquisition"
17 src_model="stock.inventory"
18 view_mode="form"/>-->
19
20 <report
21 auto="False"
22 id="account_invoices"
23 model="account.invoice"
24 name="account.invoice"
25 rml="voltalis_stock_picking_report_aeroo/report/pack_barcode_report.rml"
26 string="Invoices"
27 attachment_use="1"
28 multi="True"/>
29
30 <record model="ir.ui.view" id="view_stock_tracking_list">
31 <field name="name">Acquisition.list.view</field>
32 <field name="model">acquisition.list</field>
33 <field name="type">tree</field>
34 <field name="arch" type="xml">
35 <tree string="Acquisition list">
36 <field name="barcode_id"/>
37 <field name="type"/>
38 <field name="quantity"/>
39 </tree>
40 </field>
41 </record>
42
43 <record model="ir.ui.view" id="view_stock_tracking_form">
44 <field name="name">Acquisition.list.view</field>
45 <field name="model">acquisition.list</field>
46 <field name="type">form</field>
47 <field name="arch" type="xml">
48 <tree string="Acquisition list">
49 <field name="acquisition_id" readonly="True"/>
50 <field name="barcode_id" readonly="True"/>
51 <field name="type" readonly="True"/>
52 <field name="quantity" on_change="on_change_quantity(quantity,barcode_id)"/>
53 </tree>
54 </field>
55 </record>
56
57 <record model="ir.ui.view" id="view_stock_tracking_acquisition_form">
58 <field name="name">Acquisition.view</field>
59 <field name="model">acquisition.acquisition</field>
60 <field name="type">form</field>
61 <field name="arch" type="xml">
62 <form string="Acquisition name">
63 <group width="400" height="100">
64 <group col="4" colspan="4">
65 <field name="name"/>
66 <field name="type"/>
67 <field name="origin_id"/>
68 <group col="2" colspan="2" attrs="{'invisible':[('type','!=','pack')]}">
69 <field name="logistic_unit" attrs="{'required':[('type','=','pack')]}" widget="selection"/>
70 </group>
71 <group col="4" colspan="4" attrs="{'invisible':[('type','!=','order')]}">
72 <field name="destination_id" attrs="{'required':[('type','=','order')]}" on_change="onchange_destination(destination_id)"/>
73 <field name="address_id" attrs="{'required':[('type','=','order')]}"/>
74 </group>
75 <group col="4" colspan="4" attrs="{'invisible':[('type','!=','move_stock')]}">
76 <field name="move_stock_destination" attrs="{'required':[('type','=','move_stock')]}"/>
77 <field name="move_stock_date" attrs="{'required':[('type','=','move_stock')]}"/>
78 </group>
79 <group col="2" colspan="2" attrs="{'invisible':[('type','!=','inventory')]}">
80 <field name="inventory_id" attrs="{'required':[('type','=','inventory')]}" on_change="onchange_inventory(inventory_id)"/>
81 </group>
82 <group col="2" colspan="2" attrs="{'invisible':[('type','!=','move_stock')]}">
83 <field name="move_stock_id"/>
84 </group>
85 <group col="2" colspan="2" attrs="{'invisible':[('type','!=','order')]}">
86 <field name="picking_id" readonly="1"/>
87 </group>
88 <group col="2" colspan="2" attrs="{'invisible':[('type','!=','pack')]}">
89 <field name="pack_id" readonly="1"/>
90 </group>
91 <field name="state" invisible="1"/>
92 <field name="acquisition_ids" colspan="4" nolabel="1"/>
93 <button name="%(action_stock_reference)d" string="Start" type="action" icon="gtk-execute" states="open"/>
94 <button name="process" string="Process" type="object" icon="gtk-ok" states="open"/>
95 </group>
96 </group>
97 </form>
98 </field>
99 </record>
100
101 <record model="ir.ui.view" id="view_stock_tracking_acquisition_tree">
102 <field name="name">Acquisition.view</field>
103 <field name="model">acquisition.acquisition</field>
104 <field name="type">tree</field>
105 <field name="arch" type="xml">
106 <tree string="Acquisition name">
107 <field name="name"/>
108 <field name="acquisition_ids"/>
109 </tree>
110 </field>
111 </record>
112
113 <record model="ir.actions.act_window" id="action_stock_tracking_acquisition">
114 <field name="name">Acquisition</field>
115 <field name="type">ir.actions.act_window</field>
116 <field name="res_model">acquisition.acquisition</field>
117 <field name="view_type">form</field>
118 <field name="view_mode">tree,form</field>
119 <field name="target">current</field>
120 <field name="view_id" ref="view_stock_tracking_acquisition_tree"/>
121 </record>
122
123 <menuitem id="menu_stock_tracking_acquisition" action="action_stock_tracking_acquisition" parent="stock.menu_traceability" sequence="7"/>
124
125 <record model="ir.ui.view" id="view_stock_acquisition_setting_form">
126 <field name="name">Acquisition Setting.view</field>
127 <field name="model">acquisition.setting</field>
128 <field name="type">form</field>
129 <field name="arch" type="xml">
130 <form string="Acquisistion Setting">
131 <group colspan="4">
132 <field name="barcode_id" colspan="2"/>
133 <field name="action_type" colspan="2"/>
134 </group>
135 </form>
136 </field>
137 </record>
138
139 <record model="ir.ui.view" id="view_stock_acquisition_setting_tree">
140 <field name="name">Acquisition Setting.view</field>
141 <field name="model">acquisition.setting</field>
142 <field name="type">tree</field>
143 <field name="arch" type="xml">
144 <tree string="Acquisistion Setting">
145 <field name="barcode_id"/>
146 <field name="action_type"/>
147 </tree>
148 </field>
149 </record>
150
151 <record model="ir.actions.act_window" id="action_stock_acquisition_setting">
152 <field name="name">Acquisition Setting</field>
153 <field name="type">ir.actions.act_window</field>
154 <field name="res_model">acquisition.setting</field>
155 <field name="view_type">form</field>
156 <field name="view_mode">tree,form</field>
157 <field name="view_id" ref="view_stock_acquisition_setting_tree"/>
158 </record>
159
160 <menuitem id="menu_stock_acquisition_setting" action="action_stock_acquisition_setting" parent="stock.menu_stock_configuration" sequence="7"/>
161
162 </data>
163</openerp>
0164
=== added directory 'stock_barcode_reader/data'
=== added file 'stock_barcode_reader/data/acquisition_sequence.xml'
--- stock_barcode_reader/data/acquisition_sequence.xml 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/data/acquisition_sequence.xml 2012-11-19 11:44:21 +0000
@@ -0,0 +1,16 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4 <!-- Sequences for acquisition.acquisition -->
5 <record id="seq_type_acquisition" model="ir.sequence.type">
6 <field name="name">Acquisition</field>
7 <field name="code">acquisition.acquisition</field>
8 </record>
9 <record id="seq_acquisitionr" model="ir.sequence">
10 <field name="name">Acquisition</field>
11 <field name="code">acquisition.acquisition</field>
12 <field name="prefix">ACQ</field>
13 <field name="padding">5</field>
14 </record>
15 </data>
16</openerp>
017
=== added directory 'stock_barcode_reader/i18n'
=== added file 'stock_barcode_reader/i18n/fr.po'
--- stock_barcode_reader/i18n/fr.po 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/i18n/fr.po 2012-11-19 11:44:21 +0000
@@ -0,0 +1,283 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * stock_barcode_reader
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.0.3\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"
9"POT-Creation-Date: 2011-12-19 10:43+0000\n"
10"PO-Revision-Date: 2011-12-19 10:43+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: stock_barcode_reader
19#: view:stock.reference:0
20msgid "Bad Barcode"
21msgstr "Mauvais code-barres"
22
23#. module: stock_barcode_reader
24#: field:stock.reference,bad_barcode:0
25msgid "Bad barcode list"
26msgstr "Liste des mauvais codes-barres"
27
28#. module: stock_barcode_reader
29#: code:addons/stock_barcode_reader/package_acquisition.py:267
30#: code:addons/stock_barcode_reader/package_acquisition.py:424
31#, python-format
32msgid "You cannot move this pack because there is a none closed pack inside of it: %s."
33msgstr "Vous ne pouvez pas déplacer ce pack car il y a un pack non fermé à l'intérieur de celui-ci: %s."
34
35#. module: stock_barcode_reader
36#: selection:acquisition.list,type:0
37#: selection:acquisition.setting,action_type:0
38msgid "End Acquisition"
39msgstr "Fin de saisie"
40
41#. module: stock_barcode_reader
42#: selection:acquisition.list,type:0
43#: selection:acquisition.setting,action_type:0
44msgid "Close a pack"
45msgstr "Fermer un colis"
46
47#. module: stock_barcode_reader
48#: view:acquisition.acquisition:0
49msgid "Start"
50msgstr "Démarrer"
51
52#. module: stock_barcode_reader
53#: field:acquisition.acquisition,state:0
54msgid "State"
55msgstr "Etat"
56
57#. module: stock_barcode_reader
58#: field:acquisition.acquisition,inventory_id:0
59msgid "Inventory"
60msgstr "Inventaire"
61
62#. module: stock_barcode_reader
63#: model:ir.actions.act_window,name:stock_barcode_reader.inventory_acquisition_link
64msgid "Inventory Acquisition"
65msgstr "Acquisition d'un inventaire"
66
67#. module: stock_barcode_reader
68#: view:stock.reference:0
69msgid "Reference acquisistion"
70msgstr "Acquisition de référence"
71
72#. module: stock_barcode_reader
73#: field:acquisition.acquisition,logistic_unit:0
74msgid "Unit Size"
75msgstr "Unité de mesure"
76
77#. module: stock_barcode_reader
78#: field:acquisition.acquisition,type:0
79msgid "Type"
80msgstr "Type"
81
82#. module: stock_barcode_reader
83#: field:acquisition.acquisition,name:0
84msgid "Name"
85msgstr "Nom"
86
87#. module: stock_barcode_reader
88#: model:ir.model,name:stock_barcode_reader.model_acquisition_setting
89msgid "acquisition.setting"
90msgstr "acquisition.setting"
91
92#. module: stock_barcode_reader
93#: field:stock.reference,text:0
94msgid "Barcode list"
95msgstr "Liste des codes-barres"
96
97#. module: stock_barcode_reader
98#: field:acquisition.list,barcode_id:0
99#: field:acquisition.setting,barcode_id:0
100msgid "Barcode"
101msgstr "Code-barres"
102
103#. module: stock_barcode_reader
104#: code:addons/stock_barcode_reader/package_acquisition.py:426
105#, python-format
106msgid "Not developed yet"
107msgstr "Pas encore développée"
108
109#. module: stock_barcode_reader
110#: selection:acquisition.acquisition,type:0
111msgid "Inventory Preparation"
112msgstr "Préparation de l'inventaire"
113
114#. module: stock_barcode_reader
115#: field:stock.reference,track_id:0
116msgid "Track id"
117msgstr "ID colis"
118
119#. module: stock_barcode_reader
120#: view:acquisition.acquisition:0
121msgid "Acquisition name"
122msgstr "Saisie"
123
124#. module: stock_barcode_reader
125#: field:acquisition.acquisition,address_id:0
126msgid "Partner Address"
127msgstr "Adresse du partenaire"
128
129#. module: stock_barcode_reader
130#: field:acquisition.acquisition,origin_id:0
131msgid "Origin Location"
132msgstr "Emplacement courant"
133
134#. module: stock_barcode_reader
135#: model:ir.module.module,description:stock_barcode_reader.module_meta_information
136msgid " This module is an ergonomic wizard to fill in package "
137msgstr " Ce module est un assistant d'ergonomie à remplir dans le paquet "
138
139#. module: stock_barcode_reader
140#: field:acquisition.acquisition,move_stock_date:0
141msgid "Move Date"
142msgstr "Date de mouvement"
143
144#. module: stock_barcode_reader
145#: model:ir.model,name:stock_barcode_reader.model_acquisition_list
146msgid "acquisition.list"
147msgstr "acquisition.list"
148
149#. module: stock_barcode_reader
150#: help:acquisition.setting,action_type:0
151msgid "Selection of an action"
152msgstr "Sélection d'une action"
153
154#. module: stock_barcode_reader
155#: model:ir.module.module,shortdesc:stock_barcode_reader.module_meta_information
156msgid "Stock bar code reader"
157msgstr "Outil de lecteur de code-barres"
158
159#. module: stock_barcode_reader
160#: code:addons/stock_barcode_reader/package_acquisition.py:264
161#: code:addons/stock_barcode_reader/package_acquisition.py:421
162#, python-format
163msgid "You cannot move this pack because it's inside of an other pack: %s."
164msgstr "Vous ne pouvez pas déplacer ce pack, car il est à l'intérieur d'un autre pack: %s."
165
166#. module: stock_barcode_reader
167#: field:acquisition.list,name:0
168msgid "List Name"
169msgstr "Nom de la liste"
170
171#. module: stock_barcode_reader
172#: selection:acquisition.list,type:0
173#: selection:acquisition.setting,action_type:0
174msgid "Add a logistic unit"
175msgstr "Ajouter une unité logistique"
176
177#. module: stock_barcode_reader
178#: selection:acquisition.acquisition,type:0
179msgid "Pack Preparation"
180msgstr "Préparation de colis"
181
182#. module: stock_barcode_reader
183#: view:stock.reference:0
184msgid "End of Acquisition"
185msgstr "Fin de la saisie"
186
187#. module: stock_barcode_reader
188#: selection:acquisition.list,type:0
189#: selection:acquisition.setting,action_type:0
190msgid "Create a pack"
191msgstr "Préparation d'un colis"
192
193#. module: stock_barcode_reader
194#: field:acquisition.acquisition,acquisition_ids:0
195#: field:acquisition.list,acquisition_id:0
196#: model:ir.actions.act_window,name:stock_barcode_reader.action_stock_tracking_acquisition
197#: model:ir.ui.menu,name:stock_barcode_reader.menu_stock_tracking_acquisition
198msgid "Acquisition"
199msgstr "Module de saisie"
200
201#. module: stock_barcode_reader
202#: model:ir.model,name:stock_barcode_reader.model_stock_reference
203msgid "Products Acquisition"
204msgstr "Saisie de produits"
205
206#. module: stock_barcode_reader
207#: view:stock.reference:0
208msgid "Barcode list"
209msgstr "Liste de code-barres"
210
211#. module: stock_barcode_reader
212#: view:acquisition.acquisition:0
213msgid "Process"
214msgstr "Valider"
215
216#. module: stock_barcode_reader
217#: selection:acquisition.list,type:0
218msgid "Logistic Unit"
219msgstr "Unité Logistique"
220
221#. module: stock_barcode_reader
222#: model:ir.actions.act_window,name:stock_barcode_reader.action_stock_reference
223#: field:stock.reference,reference:0
224msgid "Reference"
225msgstr "Référence"
226
227#. module: stock_barcode_reader
228#: model:ir.actions.report.xml,name:stock_barcode_reader.account_invoices
229msgid "Invoices"
230msgstr "Factures"
231
232#. module: stock_barcode_reader
233#: field:acquisition.acquisition,destination_id:0
234#: field:acquisition.acquisition,move_stock_destination:0
235msgid "Destination Location"
236msgstr "Emplacement de destination"
237
238#. module: stock_barcode_reader
239#: model:ir.model,name:stock_barcode_reader.model_acquisition_acquisition
240msgid "acquisition.acquisition"
241msgstr "acquisition.acquisition"
242
243#. module: stock_barcode_reader
244#: field:acquisition.list,type:0
245#: field:acquisition.setting,action_type:0
246msgid "Action Type"
247msgstr "Type d'action"
248
249#. module: stock_barcode_reader
250#: selection:acquisition.acquisition,type:0
251msgid "Order Preparation"
252msgstr "Préparation des commandes"
253
254#. module: stock_barcode_reader
255#: view:acquisition.list:0
256msgid "Acquisition list"
257msgstr "Liste de saisie"
258
259#. module: stock_barcode_reader
260#: selection:acquisition.acquisition,state:0
261msgid "Done"
262msgstr "Terminé"
263
264#. module: stock_barcode_reader
265#: code:addons/stock_barcode_reader/package_acquisition.py:264
266#: code:addons/stock_barcode_reader/package_acquisition.py:267
267#: code:addons/stock_barcode_reader/package_acquisition.py:421
268#: code:addons/stock_barcode_reader/package_acquisition.py:424
269#: code:addons/stock_barcode_reader/package_acquisition.py:426
270#, python-format
271msgid "Warning!"
272msgstr "Attention!"
273
274#. module: stock_barcode_reader
275#: view:stock.reference:0
276msgid "Close"
277msgstr "Fermé"
278
279#. module: stock_barcode_reader
280#: selection:acquisition.acquisition,state:0
281msgid "Open"
282msgstr "Ouvert"
283
0284
=== added directory 'stock_barcode_reader/images'
=== added file 'stock_barcode_reader/images/Acquisition.png'
1Binary 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 differ285Binary 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
=== added file 'stock_barcode_reader/package_acquisition.py'
--- stock_barcode_reader/package_acquisition.py 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/package_acquisition.py 2012-11-19 11:44:21 +0000
@@ -0,0 +1,805 @@
1# -*- coding: utf-8 -*-
2#################################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20#################################################################################
21
22from osv import osv,fields
23from tools.translate import _
24from report import report_sxw
25from report_aeroo import report_aeroo
26import datetime
27from tools import misc
28
29class stock_fill_inventory(osv.osv_memory):
30 _inherit = "stock.fill.inventory"
31 def fill_inventory(self, cr, uid, ids, context=None):
32 res = super(stock_fill_inventory, self).fill_inventory(cr, uid, ids, context=context)
33 stock_inventory_obj = self.pool.get('stock.inventory')
34 fill_inventory = self.browse(cr, uid, ids[0], context=context)
35 if stock_inventory_obj.browse(cr, uid, context.get('active_id', False), context).location_id:
36 stock_inventory_obj.write(cr, uid, context.get('active_id', False), {'location_id': fill_inventory.location_id.id})
37 return res
38stock_fill_inventory()
39
40class acquisition_acquisition(osv.osv):
41
42 _name = "acquisition.acquisition"
43 _order = 'id desc'
44
45 _columns = {
46 'state': fields.selection([('open', 'Open'),('done', 'Done'),], 'State', readonly=True),
47 'name': fields.char('Name', size=128, required=True, readonly=True, states={'open':[('readonly',False)]}),
48 'acquisition_ids': fields.one2many('acquisition.list','acquisition_id','Acquisition', readonly=True, states={'open':[('readonly',False)]}),
49 'origin_id': fields.many2one('stock.location', 'Origin Location' , required=True, readonly=True, states={'open':[('readonly',False)]}),
50 'type': fields.selection([
51 ('order','Order Preparation'),
52 ('pack','Pack Preparation'),
53 ('inventory','Inventory Preparation'),
54 ('move_stock','Move Stock'),
55 ],'Type', size=128, readonly=True, states={'open':[('readonly',False)]}),
56 'destination_id': fields.many2one('stock.location', 'Destination Location' , readonly=True, states={'open':[('readonly',False)]}),
57 'address_id': fields.many2one('res.partner.address','Partner Address', readonly=True, states={'open':[('readonly',False)]}),
58 'logistic_unit': fields.many2one('product.ul', 'Unit Size', readonly=True, states={'open':[('readonly',False)]}),
59 'inventory_id': fields.many2one('stock.inventory', 'Inventory', readonly=True, states={'open':[('readonly',False)]}, domain="[('type', '!=', 'move')]"),
60 'move_stock_id': fields.many2one('stock.inventory', 'Move stock', readonly=True, domain="[('type', '=', 'move')]"),
61 'pack_id': fields.many2one('stock.tracking', 'Pack', readonly=True),
62 'pack_name': fields.related('pack_id', 'name', type='char', string="Pack Name", size=64, readonly=True),
63 'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True),
64 'picking_name': fields.related('picking_id', 'name', type='char', string="Picking Name", size=64, readonly=True),
65 'move_stock_destination': fields.many2one('stock.location', 'Destination Location' , readonly=True, states={'open':[('readonly',False)]}),
66 'move_stock_date': fields.datetime('Move Date', readonly=True, states={'open':[('readonly',False)]}),
67 }
68 _defaults = {
69 'state': 'open',
70 'type': 'pack',
71 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'acquisition.acquisition'),
72 'move_stock_date': lambda * a: datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT),
73 }
74
75 def onchange_destination(self, cr, uid, ids, destination_id=False, context=None):
76 res = {'value':{'address_id': False}}
77 if destination_id:
78 destination = self.pool.get('stock.location').browse(cr, uid, destination_id)
79 if destination.address_id:
80 res['value']['address_id'] = destination.address_id.id
81 return res
82
83 def onchange_inventory(self, cr, uid, ids, inventory_id=False, context=None):
84 res = {'value':{'location_id': False}}
85 if inventory_id:
86 inventory = self.pool.get('stock.inventory').browse(cr, uid, inventory_id)
87 if inventory.location_id:
88 res['value']['origin_id'] = inventory.location_id.id
89 res['value']['name'] = inventory.name
90 return res
91
92# def print_pack_report(self, cr, uid, ids, context=None):
93# '''init'''
94# if context is None:
95# context = {}
96#
97# '''process'''
98# data = self.pool.get('stock.tracking').read(cr, uid, ids)[0]
99# datas = {
100# 'ids': ids,
101# 'model': 'stock.tracking',
102# 'form': data
103# }
104# '''print report'''
105# return {'type': 'ir.actions.report.xml',
106# 'report_name': 'voltalis.tracking.barcode.report.aeroo',
107# 'datas': datas
108# }
109
110 def check_production_lot_location(self, cr, uid, origin_id, logistic_unit_id, context=None):
111 result = {}
112 stock_move_obj = self.pool.get('stock.move')
113 stock_production_lot_data = self.pool.get('stock.production.lot').browse(cr, uid, logistic_unit_id)
114 logistic_unit_number = stock_production_lot_data.id
115 product = stock_production_lot_data.product_id
116 name_list = self.pool.get('product.product').name_get(cr, uid, [product.id], context)
117 stock_production_lot_name = name_list[0][1]
118 '''If the production lot is not in the current stock'''
119 '''We add a move form it position to the current stock'''
120 if stock_production_lot_data.location_id:
121 if stock_production_lot_data.location_id.id != origin_id:
122 result = stock_move_obj.create(cr, uid, {'name': stock_production_lot_name,
123 'state': 'draft',
124 'product_id': product.id,
125 'product_uom': product.uom_id.id,
126 'prodlot_id': logistic_unit_number,
127 'location_id': stock_production_lot_data.location_id.id,
128 'location_dest_id': origin_id,
129 })
130 return result
131
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):
133 result = {}
134 move_obj = self.pool.get('stock.move')
135 production_lot_obj = self.pool.get('stock.production.lot')
136 split_obj = self.pool.get('stock.move.split')
137 split_line_obj = self.pool.get('stock.move.split.lines')
138 product_obj = self.pool.get('product.product')
139 product_product = False
140 if res_id:
141 production_lot = production_lot_obj.browse(cr, uid, res_id)
142 product_id = production_lot.product_id and production_lot.product_id.id or False
143 else:
144 product_product = True
145 if product_id:
146 move_ids = move_obj.search(cr, uid, [
147 ('state', 'not in', ['cancel']),
148 ('picking_id', '=', order_id),
149 ('product_id', '=', product_id),
150 ('prodlot_id', '=', False),
151 ])
152 if move_ids and not product_product:
153 """ The move can be split """
154 vals = {}
155 split_context = context
156 split_context.update({'active_id': move_ids[0], 'active_ids': [move_ids[0]], 'active_model': 'stock.move', 'tracking_id': tracking_id})
157 split_id = split_obj.create(cr, uid, vals, split_context)
158 split_line_obj.create(cr, uid, {'prodlot_id': res_id, 'wizard_exist_id': split_id, 'quantity':quantity})
159 split_obj.split_lot(cr, uid, [split_id], split_context)
160 else:
161 """ There are no move """
162 if res_id:
163 product = production_lot.product_id
164 else:
165 product = product_obj.browse(cr, uid, product_id, context=context)
166 name_list = product_obj.name_get(cr, uid, [product_id], context)
167 stock_production_lot_name = name_list[0][1]
168 move_id = move_obj.create(cr, uid, {
169 'name': stock_production_lot_name,
170 'product_id': product_id,
171 'product_uom': product.uom_id.id,
172 'prodlot_id': res_id,
173 'location_id': origin_id,
174 'product_qty': quantity,
175 'location_dest_id': destination_id,
176 'picking_id': order_id,
177 'tracking_id': tracking_id,
178 })
179 return result
180
181 def process(self, cr, uid, ids, context=None):
182 if context == None:
183 context = {}
184 res = {}
185 acquisition_data = self.browse(cr, uid, ids, context)
186 for acquisition in acquisition_data:
187 if acquisition.type == 'order':
188 if acquisition.picking_id:
189 self.order_preparation(cr, uid, acquisition, context)
190 else:
191 self.order_creation(cr, uid, acquisition, context)
192 elif acquisition.type == 'pack':
193 self.pack_preparation(cr, uid, acquisition, context)
194 elif acquisition.type == 'inventory':
195 self.inventory_preparation(cr, uid, acquisition, context)
196 elif acquisition.type == 'move_stock':
197 self.move_stock_preparation(cr, uid, acquisition, context)
198 self.write(cr, uid, acquisition.id, {'state': 'done'}, context=context)
199 return res
200
201 """
202 ### DELIVERY ORDER PREPARATION ###
203 """
204 def order_preparation(self, cr, uid, acquisition, context=None):
205 res = {}
206 if context==None:
207 context = {}
208 first_code = True
209 parent_id = None
210 for line in acquisition.acquisition_ids:
211 if first_code == True:
212 first_code = False
213 self.update_order(cr, uid, acquisition, context)
214 parent_id = self.update_stock_move(cr, uid, line, parent_id, context)
215 return res
216
217 '''Updating the order'''
218 def update_order(self, cr, uid, acquisition, context=None):
219 if context == None:
220 context = {}
221 stock_picking_obj = self.pool.get('stock.picking')
222 address_id = acquisition.address_id.id
223 picking_id = acquisition.picking_id.id
224 stock_picking_obj.write(cr, uid, picking_id, {'address_id': address_id, 'type': 'out'})
225 return picking_id
226
227 '''Split moves of the order into different production lot / tracking packs'''
228 def update_stock_move(self, cr, uid, line, parent_id=None, context=None):
229 stock_tracking_obj = self.pool.get('stock.tracking')
230 history_obj = self.pool.get('stock.tracking.history')
231 setting_obj = self.pool.get('acquisition.setting')
232 if context == None:
233 context = {}
234 barcode = line.barcode_id
235 res_model = barcode.res_model
236 res_id = barcode.res_id
237 order_id = line.acquisition_id and line.acquisition_id.picking_id and line.acquisition_id.picking_id.id or False
238
239 acquisition_data = self.browse(cr, uid, line.acquisition_id.id)
240 origin_id = acquisition_data.origin_id.id
241 destination_id = acquisition_data.destination_id.id
242
243 """ If a barcode creation pack is detected """
244 acquisition_setting_ids = setting_obj.search(cr, uid, [('barcode_id','=',barcode.id)], limit=1)
245 if acquisition_setting_ids:
246 acquisition_setting_id = acquisition_setting_ids[0]
247 acquisition_setting_data = setting_obj.browse(cr, uid, acquisition_setting_id, context)
248 if acquisition_setting_data.action_type == 'create_pack':
249 logistic_unit = self.pool.get('product.ul').search(cr, uid, [('type','=','pack')], limit=1)[0]
250 parent_id = setting_obj.create_pack(cr, uid, [line.acquisition_id.id], logistic_unit, context)
251 return parent_id
252 elif parent_id and acquisition_setting_data.action_type == 'close_pack':
253 setting_obj.close_pack(cr, uid, [parent_id], context)
254 parent_id = None
255 if parent_id:
256 setting_obj.add_child(cr, uid, barcode.id, parent_id, context)
257
258 if res_model == 'stock.production.lot':
259 """ Check of production lot creation """
260 new_move_id = self.check_production_lot_location(cr, uid, origin_id, res_id, context)
261 """ Split in production lot """
262 self.update_delivery_order_line(cr, uid, product_id=False, res_id=res_id, order_id=order_id, \
263 origin_id=origin_id, destination_id=destination_id, tracking_id=parent_id, quantity=1, context=context)
264 elif res_model == 'stock.tracking':
265 stock_tracking_data = stock_tracking_obj.browse(cr, uid, res_id)
266 pack_list = {}
267 pack_number = 1
268 """ Check if current pack is available """
269 if stock_tracking_data.parent_id:
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))
271 for child in stock_tracking_data.child_ids:
272 if child.state != 'close':
273 raise osv.except_osv(_('Warning!'),_('You cannot move this pack because there is a none closed pack inside of it: %s.') % (child.name))
274 child_packs = stock_tracking_obj.hierarchy_ids(stock_tracking_data)
275 for child_pack in child_packs:
276 '''historic creation'''
277 hist_id = history_obj.create(cr, uid, {
278 'tracking_id': child_pack.id,
279 'type': 'move',
280 'location_id': child_pack.location_id.id,
281 'location_dest_id': destination_id,
282 })
283 for move_data in child_pack.move_ids:
284 """ Split in production lot """
285 self.update_delivery_order_line(cr, uid, product_id=False, res_id=move_data.prodlot_id.id, order_id=order_id, \
286 origin_id=origin_id, destination_id=destination_id, tracking_id=res_id, quantity=1, context=context)
287 if res_model == 'product.product':
288 self.update_delivery_order_line(cr, uid, product_id=res_id, res_id=False, order_id=order_id, \
289 origin_id=origin_id, destination_id=destination_id, tracking_id=parent_id, quantity=line.quantity, context=context)
290 return parent_id
291
292 """
293 ### DELIVERY ORDER CREATION ###
294 """
295 def order_creation(self, cr, uid, acquisition, context=None):
296 res = {}
297 if context==None:
298 context = {}
299 first_code = True
300 acquisition_obj = self.pool.get('acquisition.acquisition')
301 setting_obj = self.pool.get('acquisition.setting')
302 for line in acquisition.acquisition_ids:
303 if first_code == True:
304 first_code = False
305 order_id = self.create_order(cr, uid, [acquisition.id], context)
306 acquisition_obj.write(cr, uid, acquisition.id, {'picking_id': order_id})
307 if line.type == 'object':
308 self.add_stock_move(cr, uid, [acquisition.id], line, order_id, context)
309 else:
310 tracking_id = setting_obj.do_action(cr, uid, [acquisition.id], line.type, context)
311 context['tracking_id'] = tracking_id
312 return res
313
314 ''' Picking Creation '''
315 def create_order(self, cr, uid, ids, context=None):
316 '''init'''
317 if context == None:
318 context = {}
319 vals = {}
320 acquisition_obj = self.pool.get('acquisition.acquisition')
321 acquisition_data = acquisition_obj.browse(cr, uid, ids[0])
322 stock_picking_obj = self.pool.get('stock.picking')
323 '''variables'''
324 address_id = acquisition_data.address_id.id
325 '''order creation'''
326 order_id = stock_picking_obj.create(cr, uid, {'address_id': address_id, 'type': 'out'})
327# name = self.pool.get('stock.picking').browse(cr, uid, order_id, context=context).name or False
328# if name:
329# vals['name'] = name
330# self.write(cr, uid, acquisition_data.id, vals, context=context)
331 '''End'''
332 return order_id
333
334 ''' Adding move in a picking '''
335 def add_stock_move(self, cr, uid, ids, line, order_id, context=None):
336 '''init'''
337 res = {}
338 if context == None:
339 context = {}
340 barcode_obj = self.pool.get('tr.barcode')
341 stock_move_obj = self.pool.get('stock.move')
342 product_obj = self.pool.get('product.product')
343 stock_tracking_obj = self.pool.get('stock.tracking')
344 history_obj = self.pool.get('stock.tracking.history')
345 acquisition_obj = self.pool.get('acquisition.acquisition')
346 stock_production_lot_obj = self.pool.get('stock.production.lot')
347
348 acquisition_data = acquisition_obj.browse(cr, uid, ids[0])
349
350 '''process'''
351 origin_id = acquisition_data.origin_id.id
352 destination_id = acquisition_data.destination_id.id
353 barcode_data = line.barcode_id
354 logistic_unit_id = barcode_data.res_id
355 tracking_id = context.get('tracking_id', False)
356 if barcode_data.res_model == 'stock.production.lot':
357 stock_production_lot_data = stock_production_lot_obj.browse(cr, uid, logistic_unit_id)
358 logistic_unit_number = stock_production_lot_data.id
359 product = stock_production_lot_data.product_id
360 name_list = self.pool.get('product.product').name_get(cr, uid, [product.id], context)
361 stock_production_lot_name = name_list[0][1]
362 '''If the production lot is not in the current stock'''
363 new_move_id = self.check_production_lot_location(cr, uid, origin_id, logistic_unit_id, context)
364 ''''stock move creation'''
365 move_id = stock_move_obj.create(cr, uid, {
366 'name': stock_production_lot_name,
367 'product_id': product.id,
368 'product_uom': product.uom_id.id,
369 'prodlot_id': logistic_unit_number,
370 'location_id': origin_id,
371 'location_dest_id': destination_id,
372 'picking_id': order_id,
373 'move_ori_id': new_move_id,
374 'tracking_id' : tracking_id,
375 })
376 elif barcode_data.res_model == 'product.product':
377 product_data = product_obj.browse(cr, uid, logistic_unit_id)
378 move_id = stock_move_obj.create(cr, uid, {
379 'name': product_data.name,
380 'product_id': product_data.id,
381 'product_uom': product_data.uom_id.id,
382 'product_qty': line.quantity,
383 'location_id': origin_id,
384 'location_dest_id': destination_id,
385 'picking_id': order_id,
386 'tracking_id' : tracking_id,
387 })
388 elif barcode_data.res_model == 'stock.tracking':
389 stock_tracking_data = stock_tracking_obj.browse(cr, uid, logistic_unit_id)
390 if stock_tracking_data.parent_id:
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))
392 for child in stock_tracking_data.child_ids:
393 if child.state != 'close':
394 raise osv.except_osv(_('Warning!'),_('You cannot move this pack because there is a none closed pack inside of it: %s.') % (child.name))
395
396 for move_data in stock_tracking_data.move_ids:
397 if move_data.location_dest_id.id != origin_id:
398 new_move_id = stock_move_obj.create(cr, uid, {
399 'name': move_data.name,
400 'state': 'draft',
401 'product_id': move_data.product_id.id,
402 'product_uom': move_data.product_uom.id,
403 'prodlot_id': move_data.prodlot_id.id,
404 'location_id': move_data.location_dest_id.id,
405 'location_dest_id': origin_id,
406 })
407
408 child_packs = stock_tracking_obj.hierarchy_ids(stock_tracking_data)
409 for child_pack in child_packs:
410 '''historic creation'''
411 hist_id = history_obj.create(cr, uid, {
412 'tracking_id': child_pack.id,
413 'type': 'move',
414 'location_id': child_pack.location_id.id,
415 'location_dest_id': destination_id,
416 })
417 for move_data in child_pack.move_ids:
418 if move_data.location_dest_id.id != origin_id:
419 new_move_id = stock_move_obj.create(cr, uid, {'name': move_data.name,
420 'state': 'draft',
421 'product_id': move_data.product_id.id,
422 'product_uom': move_data.product_uom.id,
423 'prodlot_id': move_data.prodlot_id.id,
424 'location_id': move_data.location_dest_id.id,
425 'location_dest_id': origin_id,
426 })
427 '''new move creation'''
428 for move in child_pack.current_move_ids:
429 defaults = {
430 'location_id': origin_id,
431 'location_dest_id': destination_id,
432 'picking_id': order_id
433 }
434 new_id = stock_move_obj.copy(cr, uid, move.id, default=defaults, context=context)
435 stock_move_obj.write(cr, uid, [move.id], {'pack_history_id': hist_id, 'move_dest_id': new_id})
436
437 stock_tracking_obj.write(cr, uid, [child_pack.id], {'location_id': destination_id})
438 '''End'''
439 return res
440
441 """
442 ### PACK PREPARATION ###
443 """
444 def pack_preparation(self, cr, uid, acquisition, context=None):
445 res = {}
446 if context==None:
447 context = {}
448 first_code = True
449 parent_id = False
450 setting_obj = self.pool.get('acquisition.setting')
451 for line in acquisition.acquisition_ids:
452 if first_code == True:
453 first_code = False
454 logistic_unit = acquisition.logistic_unit.id
455 parent_id = setting_obj.create_pack(cr, uid, [acquisition.id], logistic_unit, context)
456 vals = {'pack_id': parent_id}
457# name = self.pool.get('stock.tracking').browse(cr, uid, parent_id, context=context).name or False
458# if name:
459# vals['name'] = name
460 self.write(cr, uid, acquisition.id, vals, context=context)
461 setting_obj.add_child(cr, uid, line.barcode_id.id, parent_id, context)
462 if parent_id:
463 setting_obj.close_pack(cr, uid, [parent_id], context)
464 return res
465
466 """
467 ### INVENTORY ###
468 """
469 def inventory_preparation(self, cr, uid, acquisition, context=None):
470 res = {}
471 if context==None:
472 context = {}
473 inventory_id = acquisition.inventory_id or False
474 if not inventory_id:
475 raise osv.except_osv(_('Warning!'),_('There is no inventory, please create one!'))
476 if inventory_id.state != 'draft':
477 raise osv.except_osv(_('Warning!'),_('This inventory is not in draft state, you can\'t continue !'))
478 location_id = acquisition.origin_id or False
479 if not location_id:
480 raise osv.except_osv(_('Warning!'),_('There is no location defined, please select one!'))
481 for line in acquisition.acquisition_ids:
482 self.check_inventory_line(cr, uid, line, context)
483 return res
484
485 def check_inventory_line(self, cr, uid, line, context=None):
486 if context == None:
487 context = {}
488 acquisition = line.acquisition_id
489 barcode = line.barcode_id
490 production_lot_obj = self.pool.get('stock.production.lot')
491 inventory_line_obj = self.pool.get('stock.inventory.line')
492 product_obj = self.pool.get('product.product')
493 inventory_id = acquisition.inventory_id and acquisition.inventory_id.id or False
494 location_id = acquisition.origin_id and acquisition.origin_id.id or False
495 logistic_unit_id = barcode.res_id
496
497 if barcode.res_model == 'stock.production.lot':
498 """ Production Lot Case """
499 """ TODO What if the production lot is in a tracking ? """
500 production_lot = production_lot_obj.browse(cr, uid, logistic_unit_id)
501 product = production_lot.product_id
502 lot_id = production_lot.id
503 vals = {
504 'inventory_id': inventory_id,
505 'location_id': location_id,
506 'product_id': product.id,
507 'product_uom': product.uom_id.id,
508 'product_qty': 1,
509 'prod_lot_id': lot_id,
510 }
511 line_ids = inventory_line_obj.search(cr, uid, [('inventory_id', '=', inventory_id), ('product_id', '=', product.id), ('prod_lot_id', '=', lot_id)])
512 if line_ids:
513 inventory_line_obj.write(cr, uid, [line_ids[0]], vals)
514 else:
515 inventory_line_obj.create(cr, uid, vals)
516
517 elif barcode.res_model == 'product.product':
518 """ Product Case """
519 product = product_obj.browse(cr, uid, logistic_unit_id)
520 vals = {
521 'inventory_id': inventory_id,
522 'location_id': location_id,
523 'product_id': product.id,
524 'product_uom': product.uom_id.id,
525 }
526 line_ids = inventory_line_obj.search(cr, uid, [('inventory_id', '=', inventory_id), ('product_id', '=', product.id), ('location_id', '=', location_id)])
527 if line_ids:
528 qty = inventory_line_obj.read(cr, uid, line_ids[0], ['product_qty'])['product_qty']
529 vals_update = vals
530 vals_update.update({'product_qty': qty >= 0 and qty + line.quantity or line.quantity})
531 inventory_line_obj.write(cr, uid, [line_ids[0]], vals_update)
532 else:
533 vals_create = vals
534 vals_create.update({'product_qty': line.quantity})
535 inventory_line_obj.create(cr, uid, vals_create)
536
537 """
538 ### MOVE STOCK CREATION ###
539 """
540 def move_stock_preparation(self, cr, uid, acquisition, context=None):
541 res = {}
542 if context==None:
543 context = {}
544 first_code = True
545 move_stock_id = False
546 name = False
547 vals = {}
548 for line in acquisition.acquisition_ids:
549 if first_code == True:
550 first_code = False
551 move_stock_id = self.create_move_stock(cr, uid, [acquisition.id], context=context)
552# name = self.pool.get('stock.inventory').browse(cr, uid, move_stock_id, context=context).name or False
553 self.add_stock_move_line(cr, uid, [acquisition.id], line, move_stock_id, context)
554 if move_stock_id:
555 vals['move_stock_id'] = move_stock_id
556 self.write(cr, uid, acquisition.id, vals, context=context)
557 return res
558
559 def create_move_stock(self, cr, uid, ids, context=None):
560 '''init'''
561 if context == None:
562 context = {}
563 acquisition_data = self.browse(cr, uid, ids[0])
564 stock_inventory_obj = self.pool.get('stock.inventory')
565
566 '''variables'''
567 origin_id = acquisition_data.origin_id.id
568 destination_id = acquisition_data.move_stock_destination.id
569 date = acquisition_data.move_stock_date
570 ''''inventory creation'''
571 context.update({'type':'move'})
572 move_stock_id = stock_inventory_obj.create(cr, uid, {
573 'type': 'move',
574 'date_done': date,
575 'location_id': origin_id,
576 'location_dest_id': destination_id,
577 }, context=context)
578 '''End'''
579 return move_stock_id
580
581 def add_stock_move_line(self, cr, uid, ids, line, inventory_id, inventory_line_id, context=None):
582 res = {}
583 '''init'''
584 if context == None:
585 context = {}
586 barcode_obj = self.pool.get('tr.barcode')
587 stock_production_lot_obj = self.pool.get('stock.production.lot')
588 inventory_line_obj = self.pool.get('stock.inventory.line')
589 stock_tracking_obj = self.pool.get('stock.tracking')
590 product_obj = self.pool.get('product.product')
591 barcode_id = line.barcode_id.id
592 barcode_data = barcode_obj.browse(cr, uid, barcode_id, context=context)
593 acquisition_data = self.browse(cr, uid, ids[0], context=context)
594
595 location_id = acquisition_data.origin_id.id
596 logistic_unit_id = barcode_data.res_id
597 if barcode_data.res_model == 'stock.production.lot':
598 stock_production_lot_data = stock_production_lot_obj.browse(cr, uid, logistic_unit_id, context=context)
599 product = stock_production_lot_data.product_id
600 logistic_unit_number = stock_production_lot_data.id
601 vals = {
602 'inventory_id': inventory_id,
603 'location_id': location_id,
604 'product_id': product.id,
605 'product_uom': product.uom_id.id,
606 'product_qty': 1,
607 'prod_lot_id':logistic_unit_number}
608 inventory_line_obj.create(cr, uid, vals)
609 elif barcode_data.res_model == 'product.product':
610 product_data = product_obj.browse(cr, uid, logistic_unit_id)
611 vals = {
612 'inventory_id': inventory_id,
613 'location_id': location_id,
614 'product_id': product_data.id,
615 'product_uom': product_data.uom_id.id,
616 'product_qty': line.quantity}
617 inventory_line_obj.create(cr, uid, vals)
618 elif barcode_data.res_model == 'stock.tracking':
619 stock_tracking_data = stock_tracking_obj.browse(cr, uid, logistic_unit_id)
620 if stock_tracking_data.parent_id:
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))
622 for child in stock_tracking_data.child_ids:
623 if child.state != 'close':
624 raise osv.except_osv(_('Warning!'),_('You cannot move this pack because there is a none closed pack inside of it: %s.') % (child.name))
625
626 raise osv.except_osv(_('Warning!'),_('Not developed yet'))
627
628 return res
629
630acquisition_acquisition()
631
632class acquisition_list(osv.osv):
633
634 _name = "acquisition.list"
635 _columns = {
636 'name': fields.char('List Name', size=128),
637 'barcode_id': fields.many2one('tr.barcode', 'Barcode', readonly=True),
638 'acquisition_id': fields.many2one('acquisition.acquisition','Acquisition'),
639 'type': fields.selection([
640 ('object','Logistic Unit'),
641 ('create_add', 'Create a pack and add a logistic unit'),
642 ('create_pack','Create a pack'),
643 ('add_child','Add a logistic unit'),
644 ('close_pack','Close a pack'),
645 ], 'Action Type', size=32),
646 'quantity': fields.float('Quantity'),
647 }
648
649 _defaults = {
650 'quantity': 1,
651 }
652
653 def on_change_quantity(self, cr, uid, ids, quantity=1, barcode_id=False, context=None):
654 res = {'value': {'quantity': 1}}
655 if context == None:
656 context = {}
657 if barcode_id:
658 if self.pool.get('tr.barcode').browse(cr, uid, barcode_id).res_model == 'product.product':
659 res = {'value': {'quantity' : quantity}}
660 return res
661
662 def _check_quantity(self, cr, uid, ids, context=None):
663 for record in self.browse(cr, uid, ids, context=context):
664 if record.quantity != 1 and record.barcode_id.res_model!='product.product':
665 return False
666 return True
667
668 _constraints = [
669 (_check_quantity,
670 'You assigned a wrong quantity for this line',
671 ['name']),
672 ]
673
674acquisition_list()
675
676class acquisition_setting(osv.osv):
677
678 _name = "acquisition.setting"
679 _columns = {
680 'barcode_id': fields.many2one('tr.barcode', 'Barcode', required=True, readonly=False),
681 'action_type': fields.selection([
682 ('create_add', 'Create a pack and add a logistic unit'),
683 ('create_pack','Create a pack'),
684 ('add_child','Add a logistic unit'),
685 ('close_pack','Close a pack'),
686 ], 'Action Type', size=32, required=True, help="Selection of an action"),
687 }
688
689# def create_add(self, cr, uid, ids, ul_id, context=None):
690# if context == None:
691# context = {}
692# tracking_id = self.create_pack(cr, uid, ids, ul_id, context)
693# return tracking_id
694
695 def do_action(self, cr, uid, ids, action_type, context=None):
696 if context == None:
697 context = {}
698 tracking_id = False
699 if action_type == 'create_add':
700 tracking_id = self.create_pack(cr, uid, ids, context=context)
701 elif action_type == 'close_pack':
702 tracking_to_close_id = context.get('tracking_id', False)
703 if tracking_to_close_id:
704 self.close_pack(cr, uid, [tracking_to_close_id], context=context)
705 return tracking_id
706
707 '''Function for pack creation'''
708 def create_pack(self, cr, uid, ids, ul_id=None, context=None):
709 '''Init'''
710 res = {}
711 stock_tracking_obj = self.pool.get('stock.tracking')
712 if context == None:
713 context = {}
714 '''Location determination'''
715 acquisition_data = self.pool.get('acquisition.acquisition').browse(cr, uid, ids[0])
716 location_id = acquisition_data.origin_id.id
717 if ul_id == None:
718 ul_id = self.pool.get('product.ul').search(cr, uid, [], limit=1)[0]
719 logistic_unit = ul_id
720 '''Pack Creation'''
721 tracking_id = stock_tracking_obj.create(cr, uid, {'ul_id': logistic_unit, 'location_id': location_id})
722 '''Pack name is returned'''
723 return tracking_id
724
725 def add_child(self, cr, uid, barcode_id, parent_id, context=None):
726 '''Init'''
727 res = {}
728 barcode_obj = self.pool.get('tr.barcode')
729 tracking_obj = self.pool.get('stock.tracking')
730 if context == None:
731 context = {}
732 '''Get barcode number'''
733 barcode_data = barcode_obj.browse(cr, uid, barcode_id)
734 barcode_code = barcode_data.code
735 ''' Call of adding function '''
736 tracking_obj.add_validation(cr, uid, [parent_id], [barcode_id], context=None)
737 return res
738
739 def close_pack(self, cr, uid, ids, context=None):
740 '''init'''
741 if context == None:
742 context = {}
743 tracking_obj = self.pool.get('stock.tracking')
744 '''Call of the function in stock_tracking_reopen'''
745 tracking_obj.set_close(cr, uid, ids, context)
746 '''Call of the function in stock_tracking_reopen'''
747 if self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).picking_id:
748 origin_id = self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).origin_id.id
749 destination_id = self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).destination_id.id
750 stock_move_ids = self.pool.get('stock.move').search(cr, uid, [('tracking_id','=',ids[0])])
751 for stock_move_id in stock_move_ids:
752 stock_move_data = self.pool.get('stock.move').browse(cr, uid, stock_move_id, context)
753 self.pool.get('stock.move').write(cr, uid, stock_move_id, {'state':'done', 'picking_id': False, 'location_dest_id': origin_id}, context)
754 self.pool.get('stock.move').create(cr, uid, {'name': stock_move_data.name,
755 'state': 'draft',
756 'product_id': stock_move_data.product_id.id,
757 'product_uom': stock_move_data.product_uom.id,
758 'prodlot_id': stock_move_data.prodlot_id.id,
759 'tracking_id': stock_move_data.tracking_id.id,
760 'picking_id': self.pool.get('acquisition.acquisition').browse(cr, uid, context.get('current_id'), context).picking_id.id,
761 'location_id': stock_move_data.location_dest_id.id,
762 'location_dest_id': destination_id,
763 })
764 '''Call for a function who will display serial code list and product list in the pack layout'''
765 tracking_obj.get_products(cr, uid, ids, context=None)
766 tracking_obj.get_serials(cr, uid, ids, context=None)
767 return True
768
769
770
771# def create_inventory(self, cr, uid, ids, context=None):
772# '''init'''
773# if context == None:
774# context = {}
775# acquisition_obj = self.pool.get('acquisition.acquisition')
776# acquisition_data = acquisition_obj.browse(cr, uid, ids[0])
777# stock_inventory_obj = self.pool.get('stock.inventory')
778# '''variables'''
779# date = acquisition_data.inventory_date
780# ''''inventory creation'''
781# inventory_id = stock_inventory_obj.create(cr, uid, {'date_done': date})
782# '''End'''
783# return inventory_id
784
785
786
787# for line in inventory_data.inventory_line_id:
788# if line.product_id.id == product_data.id:
789# in_inventory = True
790# inventory_line_obj.write(cr, uid, [line.id], {'product_qty': 1})
791# elif in_inventory == False:
792# in_inventory = True
793# vals = {
794# 'inventory_id': inventory_data.id,
795# 'location_id': location_id,
796# 'product_id': product_data.id,
797# 'product_uom': product_data.uom_id.id,
798# 'product_qty': 1}
799# inventory_line_obj.create(cr, uid, vals)
800
801
802
803acquisition_setting()
804
805# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0806
=== added directory 'stock_barcode_reader/security'
=== added file 'stock_barcode_reader/security/ir.model.access.csv'
--- stock_barcode_reader/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/security/ir.model.access.csv 2012-11-19 11:44:21 +0000
@@ -0,0 +1,7 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_acquisition_acquisition_manager","acquisition.aquisition.manager","model_acquisition_acquisition","stock.group_stock_manager",1,1,1,1
3"access_acquisition_acquisition_user","acquisition.aquisition.manager","model_acquisition_acquisition","stock.group_stock_user",1,1,1,0
4"access_acquisition_list_manager","acquisition.list.manager","model_acquisition_list","stock.group_stock_manager",1,1,1,1
5"access_acquisition_list_user","acquisition.list.manager","model_acquisition_list","stock.group_stock_user",1,1,1,1
6"access_acquisition_setting_manager","acquisition.setting.manager","model_acquisition_setting","stock.group_stock_manager",1,1,1,1
7"access_acquisition_setting_user","acquisition.setting.manager","model_acquisition_setting","stock.group_stock_user",1,1,1,1
08
=== added file 'stock_barcode_reader/stock.py'
--- stock_barcode_reader/stock.py 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/stock.py 2012-11-19 11:44:21 +0000
@@ -0,0 +1,56 @@
1# -*- coding: utf-8 -*-
2#################################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20#################################################################################
21
22from osv import osv,fields
23from tools.translate import _
24
25class stock_picking(osv.osv):
26 _inherit = "stock.picking"
27
28 def start_acquisition(self, cr, uid, ids, context=None):
29 if context == None:
30 context = {}
31 active = self.browse(cr, uid, ids[0])
32 name = active.name
33 action_context = {'default_type': 'order', 'default_name': 'Preparation ' + name, 'default_picking_id': ids[0]}
34 address_id = active.address_id and active.address_id.id or False
35 if address_id:
36 action_context.update({'default_address_id': address_id})
37 location_id = False
38 for move in active.move_lines:
39 location_id = move.location_dest_id and move.location_dest_id.id or False
40 if location_id:
41 action_context.update({'default_destination_id': location_id})
42 break
43 action = {
44 'type': 'ir.actions.act_window',
45 'view_type': 'form',
46 'view_mode': 'form',
47 'res_model': 'acquisition.acquisition',
48 'view_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock_barcode_reader', 'view_stock_tracking_acquisition_form')[1],
49# 'menu_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'menu_stock_root')[1],
50 'context': action_context
51 }
52 return action
53
54stock_picking()
55
56# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
057
=== added file 'stock_barcode_reader/stock_view.xml'
--- stock_barcode_reader/stock_view.xml 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/stock_view.xml 2012-11-19 11:44:21 +0000
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="view_picking_form" model="ir.ui.view">
6 <field name="name">stock.picking.form</field>
7 <field name="model">stock.picking</field>
8 <field name="type">form</field>
9 <field eval="12" name="priority"/>
10 <field name="inherit_id" ref="stock.view_picking_form"/>
11 <field name="arch" type="xml">
12 <button name="action_process" position="before">
13 <button name="start_acquisition" string="Start Acquisition" states="assigned,confirmed,draft" type="object" icon="gtk-go-forward"/>
14 </button>
15 </field>
16 </record>
17
18 <record id="view_delivery_order_inherit_stock_barcode" model="ir.ui.view">
19 <field name="name">stock.picking.out.barcode.form</field>
20 <field name="type">form</field>
21 <field name="model">stock.picking</field>
22 <field name="inherit_id" ref="stock.view_picking_out_form"/>
23 <field name="arch" type="xml">
24 <button name="action_process" position="before">
25 <button name="start_acquisition" string="Start Acquisition" states="assigned,confirmed,draft" type="object" icon="gtk-go-forward"/>
26 </button>
27 </field>
28 </record>
29
30 </data>
31</openerp>
032
=== added directory 'stock_barcode_reader/wizard'
=== added file 'stock_barcode_reader/wizard/__init__.py'
--- stock_barcode_reader/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/wizard/__init__.py 2012-11-19 11:44:21 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2#################################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20#################################################################################
21
22import reference
23
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file25\ No newline at end of file
126
=== added file 'stock_barcode_reader/wizard/reference.py'
--- stock_barcode_reader/wizard/reference.py 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/wizard/reference.py 2012-11-19 11:44:21 +0000
@@ -0,0 +1,100 @@
1# -*- coding: utf-8 -*-
2#################################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Julius Network Solutions SARL <contact@julius.fr>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20#################################################################################
21
22from osv import osv,fields
23from tools.translate import _
24
25class stock_reference(osv.osv_memory):
26
27 _name = "stock.reference"
28 _description = 'Products Acquisition'
29
30# _rec_name = 'reference'
31
32 def _get_track_id(self, cr, uid, context=None):
33 if context == None:
34 context = {}
35 return context.get('active_id',False)
36
37 _columns = {
38# 'barcode_id': fields.many2one('tr.barcode', 'Reference', required=True),
39 'reference': fields.char('Reference', size=128, required=True),
40 'track_id': fields.many2one('acquisition.acquisition','Track id', required=True),
41 'text': fields.text('Barcode list',readonly=True),
42# 'bad_barcode': fields.text('Bad barcode list',readonly=True),
43 }
44
45 _defaults = {
46 'track_id': _get_track_id,
47 }
48
49 def onchange_reference(self, cr, uid, ids, reference, track_id, barcode_list=''):
50
51 res = {}
52 barcode_obj = self.pool.get('tr.barcode')
53 acquisition_list = self.pool.get('acquisition.list')
54 acquisition_setting = self.pool.get('acquisition.setting')
55
56 text = barcode_list or ''
57
58 if reference:
59 barcode_ids = barcode_obj.search(cr, uid, [('code', '=', reference)], limit=1)
60 if not barcode_ids:
61 reference2 = reference
62 while len(reference2.split('-')) > 1:
63 reference2 = reference2.replace('-','')
64 barcode_ids = barcode_obj.search(cr, uid, [('code2', '=', reference2)], limit=1)
65
66 if barcode_ids:
67 barcode_type = 'object'
68 line_ids = acquisition_list.search(cr, uid, [('barcode_id', '=', barcode_ids[0]), ('acquisition_id', '=', track_id)])
69 setting_ids = acquisition_setting.search(cr, uid, [('barcode_id', '=', barcode_ids[0])], limit=1)
70
71 if setting_ids:
72 setting_data = acquisition_setting.browse(cr, uid, setting_ids)
73 barcode_type = setting_data[0].action_type
74 create = True
75 if line_ids:
76 create = False
77 line_barcode = barcode_obj.read(cr, uid, barcode_ids[0], ['res_model'])
78 if line_barcode.get('res_model',False) == 'product.product' or setting_ids:
79 create = True
80 if create:
81 acquisition_list.create(cr, uid, {
82 'barcode_id': barcode_ids[0],
83 'acquisition_id': track_id,
84 'type': barcode_type,
85 })
86 text = reference + '\n' + text
87
88 else:
89 raise osv.except_osv(_('Warning!'),_('Barcode Not found!')) # Return of the wraning msg !!
90## bad_barcode = bad_barcode_list or ''
91# bad_barcode += reference
92# if bad_barcode:
93# bad_barcode += '\n'
94
95
96 return {'value': {'reference' : False, 'text' : text}}
97
98stock_reference()
99
100# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0101
=== added file 'stock_barcode_reader/wizard/reference_view.xml'
--- stock_barcode_reader/wizard/reference_view.xml 1970-01-01 00:00:00 +0000
+++ stock_barcode_reader/wizard/reference_view.xml 2012-11-19 11:44:21 +0000
@@ -0,0 +1,41 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="view_stock_reference" model="ir.ui.view" >
6 <field name="name">Acquisition.reference.view</field>
7 <field name="model">stock.reference</field>
8 <field name="type">form</field>
9 <field name="arch" type="xml">
10 <form string="Reference acquisistion">
11 <group width="400" height="100">
12 <group colspan="4">
13 <field name="reference" on_change="onchange_reference(reference,track_id,text)" colspan="4"/>
14 <field name="track_id" colspan="2" invisible="1"/>
15 <newline/>
16 <separator string="End of Acquisition" colspan="4"/>
17 <button special="cancel" string="Close" icon="gtk-ok"/>
18 <newline/>
19 <separator string="Barcode list" colspan="4"/>
20 <field name="text" colspan="4" nolabel="1"/>
21 <!--<newline/>
22 <separator string="Bad Barcode" colspan="4"/>
23 <field name="bad_barcode" colspan="2" nolabel="1"/>-->
24 </group>
25 </group>
26 </form>
27 </field>
28 </record>
29
30 <record id="action_stock_reference" model="ir.actions.act_window">
31 <field name="name">Reference</field>
32 <field name="type">ir.actions.act_window</field>
33 <field name="res_model">stock.reference</field>
34 <field name="view_type">form</field>
35 <field name="view_mode">form</field>
36 <field name="view_id" ref="view_stock_reference"/>
37 <field name="target">new</field>
38 </record>
39
40 </data>
41</openerp>

Subscribers

People subscribed via source and target branches