Merge lp:~vauxoo/addons-vauxoo/addons-vauxoo-stock_dumb_wizard_export_csv-dev-fernando into lp:addons-vauxoo

Proposed by Fernando Lopez
Status: Merged
Merge reported by: Ulises Lopez
Merged at revision: not available
Proposed branch: lp:~vauxoo/addons-vauxoo/addons-vauxoo-stock_dumb_wizard_export_csv-dev-fernando
Merge into: lp:addons-vauxoo
Diff against target: 492 lines (+449/-0)
7 files modified
__init__.py (+27/-0)
__openerp__.py (+45/-0)
i18n/es_MX.po (+93/-0)
stock.py (+122/-0)
stock_view.xml (+75/-0)
wizard/__init__.py (+26/-0)
wizard/wizard.py (+61/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/addons-vauxoo-stock_dumb_wizard_export_csv-dev-fernando
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Needs Fixing
Ulises Lopez Pending
Review via email: mp+126351@code.launchpad.net

This proposal supersedes a proposal from 2012-09-24.

Description of the change

Se modificó el manejo del diccionario ya que se estaban sobre escribiendo los datos y por eso repetía las líneas.
Se movió la columna name de la columna 3 a la 4.
La columna 3 se le asignó al campo 'reference'
El nombre del csv por default se cambio a "PT OpenERP - PWST.csv"

To post a comment you must log in.
Revision history for this message
Fernando Lopez (kyon) wrote : Posted in a previous version of this proposal

Funcionalidad migrada a stock.move

Revision history for this message
Ulises Lopez (ulcalderon) wrote : Posted in a previous version of this proposal

- Cuando selecciono varios pickings solo toma los datos del último picking seleccionado, envío evidencia:
"2012-09-25 19:01:05","","[09878] Producto terminado 4","","167.0","09878"
"2012-09-25 19:01:05","","[09878] Producto terminado 4","","167.0","09878"
"2012-09-25 19:01:05","","[09878] Producto terminado 4","","167.0","09878"

- El formato de la columna 1, que es la fecha del movimiento aparece "2012-09-25 19:01:05", debe de ser con el siguiente formato "DD/MM/AAAA" sin hora.

- En la columna 3, debe de contener la referencia del documento ejemplo "OUT/00001"

- Colocar el nombre del producto en la columna 4 ejemplo "[09878] Producto terminado 4"

review: Needs Fixing
Revision history for this message
Ulises Lopez (ulcalderon) wrote : Posted in a previous version of this proposal

- Colocar el siguiente nombre de archivo al momento de exportar: "PT OpenERP - PWST AAMMDD HH:MM.csv"

review: Needs Fixing
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote : Posted in a previous version of this proposal

Equipo,
En la solicitud:
- En la columna 3, debe de contener la referencia del documento ejemplo "OUT/00001"

Creo que lo vamos a dejar tal cual está ahora + lo que pide Ulises, debido a que va a haber exportaciones de stock.move que no tengan stock.picking y esto podría causar error.

Es decir,
stock_move.picking_id and stock_move.picking_id.name or stock_move.name

¿Me explico?

review: Needs Fixing
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

Acorde a las guidelines
2.5 Factor out the code
Del documento
http://doc.openerp.com/v6.0/contribute/15_guidelines/coding_guidelines_framework.html

Se detecta que la función de stock_picking llamada "create_export_stk_moves" se está haciendo más de 1 vez exactamente la misma funcionalidad.

Dejar esta funcionalidad en stock_move (tal cual como está ahora), pero en la función del picking, hacer un ciclo para acumular move_ids donde al final, mande a llamar a stock_move.create_export_stk_moves(move_ids)

Y cuando termines esto, no darle en "Resubmit proposal merge", más bien darle en en comentario
Review: resumit y escribir tu comentario largo (que faltó en este nuevo feature)

review: Needs Fixing
Revision history for this message
Ulises Lopez (ulcalderon) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '__init__.py'
2--- __init__.py 1970-01-01 00:00:00 +0000
3+++ __init__.py 2012-09-25 23:32:22 +0000
4@@ -0,0 +1,27 @@
5+# -*- encoding: utf-8 -*-
6+###########################################################################
7+# Module Writen to OpenERP, Open Source Management Solution
8+#
9+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
10+# All Rights Reserved.
11+# info@vauxoo.com
12+############################################################################
13+# Coded by: fernandoL (fernando_ld@vauxoo.com)
14+############################################################################
15+#
16+# This program is free software: you can redistribute it and/or modify
17+# it under the terms of the GNU Affero General Public License as
18+# published by the Free Software Foundation, either version 3 of the
19+# License, or (at your option) any later version.
20+#
21+# This program is distributed in the hope that it will be useful,
22+# but WITHOUT ANY WARRANTY; without even the implied warranty of
23+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+# GNU Affero General Public License for more details.
25+#
26+# You should have received a copy of the GNU Affero General Public License
27+# along with this program. If not, see <http://www.gnu.org/licenses/>.
28+#
29+##############################################################################
30+import wizard
31+import stock
32\ No newline at end of file
33
34=== added file '__openerp__.py'
35--- __openerp__.py 1970-01-01 00:00:00 +0000
36+++ __openerp__.py 2012-09-25 23:32:22 +0000
37@@ -0,0 +1,45 @@
38+# -*- encoding: utf-8 -*-
39+###########################################################################
40+# Module Writen to OpenERP, Open Source Management Solution
41+#
42+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
43+# All Rights Reserved.
44+# info@vauxoo.com
45+############################################################################
46+# Coded by: fernandoL (fernando_ld@vauxoo.com)
47+############################################################################
48+#
49+# This program is free software: you can redistribute it and/or modify
50+# it under the terms of the GNU Affero General Public License as
51+# published by the Free Software Foundation, either version 3 of the
52+# License, or (at your option) any later version.
53+#
54+# This program is distributed in the hope that it will be useful,
55+# but WITHOUT ANY WARRANTY; without even the implied warranty of
56+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57+# GNU Affero General Public License for more details.
58+#
59+# You should have received a copy of the GNU Affero General Public License
60+# along with this program. If not, see <http://www.gnu.org/licenses/>.
61+#
62+##############################################################################
63+
64+{
65+ "name": "Stock dumb wizard export csv",
66+ "version": "1.0",
67+ "author" : "Vauxoo",
68+ "category": "Generic Modules/Production",
69+ "website" : "http://www.vauxoo.com/",
70+ "description": """ Add wizard to export to a csv the stock_move lines
71+ from the stock_picking model
72+ """,
73+ 'depends': ['stock'],
74+ 'init_xml': [],
75+ 'update_xml': [
76+ 'stock_view.xml',
77+ ],
78+ 'demo_xml': [],
79+ 'test': [],
80+ 'installable': True,
81+ 'active': False,
82+}
83\ No newline at end of file
84
85=== added directory 'i18n'
86=== added file 'i18n/es_MX.mo'
87Binary files i18n/es_MX.mo 1970-01-01 00:00:00 +0000 and i18n/es_MX.mo 2012-09-25 23:32:22 +0000 differ
88=== added file 'i18n/es_MX.po'
89--- i18n/es_MX.po 1970-01-01 00:00:00 +0000
90+++ i18n/es_MX.po 2012-09-25 23:32:22 +0000
91@@ -0,0 +1,93 @@
92+# Translation of OpenERP Server.
93+# This file contains the translation of the following modules:
94+# * stock_dumb_wizard_export_csv
95+#
96+msgid ""
97+msgstr ""
98+"Project-Id-Version: OpenERP Server 6.1\n"
99+"Report-Msgid-Bugs-To: \n"
100+"POT-Creation-Date: 2012-09-24 23:15+0000\n"
101+"PO-Revision-Date: 2012-09-24 18:23-0600\n"
102+"Last-Translator: Kyon <fernando_ld@vauxoo.com>\n"
103+"Language-Team: \n"
104+"MIME-Version: 1.0\n"
105+"Content-Type: text/plain; charset=UTF-8\n"
106+"Content-Transfer-Encoding: 8bit\n"
107+"Plural-Forms: \n"
108+
109+#. module: stock_dumb_wizard_export_csv
110+#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_dumb_wizard_export_csv
111+msgid "stock.dumb.wizard.export.csv"
112+msgstr "stock.dumb.wizard.export.csv"
113+
114+#. module: stock_dumb_wizard_export_csv
115+#: view:stock.dumb.wizard.export.csv:0
116+#: view:stock.dumb.wizard.export.stk.move:0
117+msgid "Exportar to CSV"
118+msgstr "Exportar a csv"
119+
120+#. module: stock_dumb_wizard_export_csv
121+#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_dumb_wizard_export_stk_move
122+msgid "stock.dumb.wizard.export.stk.move"
123+msgstr "stock.dumb.wizard.export.stk.move"
124+
125+#. module: stock_dumb_wizard_export_csv
126+#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_move
127+msgid "Stock Move"
128+msgstr "Stock Move"
129+
130+#. module: stock_dumb_wizard_export_csv
131+#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_stock_move
132+#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_stock_picking
133+msgid "Export to csv"
134+msgstr "Exportar a csv"
135+
136+#. module: stock_dumb_wizard_export_csv
137+#: constraint:stock.move:0
138+msgid "You can not move products from or to a location of the type view."
139+msgstr "No puedes mover productos desde o a una locación del tipo vista"
140+
141+#. module: stock_dumb_wizard_export_csv
142+#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_export_csv_action
143+#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_stock_move_action
144+msgid "Wizard"
145+msgstr "Asistente"
146+
147+#. module: stock_dumb_wizard_export_csv
148+#: constraint:stock.move:0
149+msgid "You must assign a production lot for this product"
150+msgstr "Debe asignar un lote de producción para este producto"
151+
152+#. module: stock_dumb_wizard_export_csv
153+#: field:stock.dumb.wizard.export.csv,file.csv:0
154+#: field:stock.dumb.wizard.export.stk.move,file.csv:0
155+msgid "File CSV"
156+msgstr "Archivo CSV"
157+
158+#. module: stock_dumb_wizard_export_csv
159+#: constraint:stock.move:0
160+msgid "You try to assign a lot which is not from the same product"
161+msgstr "Está intentando asignar un lote que no es del mismo producto"
162+
163+#. module: stock_dumb_wizard_export_csv
164+#: view:stock.dumb.wizard.export.csv:0
165+#: view:stock.dumb.wizard.export.stk.move:0
166+msgid "Get data to export"
167+msgstr "Obtener datos a exportar"
168+
169+#. module: stock_dumb_wizard_export_csv
170+#: sql_constraint:stock.picking:0
171+msgid "Reference must be unique per Company!"
172+msgstr "¡La referencia debe ser única por compañía!"
173+
174+#. module: stock_dumb_wizard_export_csv
175+#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_picking
176+msgid "Picking List"
177+msgstr "Albarán (lista de remisiones)"
178+
179+#. module: stock_dumb_wizard_export_csv
180+#: view:stock.dumb.wizard.export.csv:0
181+#: view:stock.dumb.wizard.export.stk.move:0
182+msgid "Cancel"
183+msgstr "Cancelar"
184+
185
186=== added file 'stock.py'
187--- stock.py 1970-01-01 00:00:00 +0000
188+++ stock.py 2012-09-25 23:32:22 +0000
189@@ -0,0 +1,122 @@
190+# -*- encoding: utf-8 -*-
191+###########################################################################
192+# Module Writen to OpenERP, Open Source Management Solution
193+#
194+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
195+# All Rights Reserved.
196+# info@vauxoo.com
197+############################################################################
198+# Coded by: fernandoL (fernando_ld@vauxoo.com)
199+############################################################################
200+#
201+# This program is free software: you can redistribute it and/or modify
202+# it under the terms of the GNU Affero General Public License as
203+# published by the Free Software Foundation, either version 3 of the
204+# License, or (at your option) any later version.
205+#
206+# This program is distributed in the hope that it will be useful,
207+# but WITHOUT ANY WARRANTY; without even the implied warranty of
208+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
209+# GNU Affero General Public License for more details.
210+#
211+# You should have received a copy of the GNU Affero General Public License
212+# along with this program. If not, see <http://www.gnu.org/licenses/>.
213+#
214+##############################################################################
215+
216+import pooler
217+import wizard
218+import base64
219+import cStringIO
220+import netsvc
221+from tools.translate import _
222+import tools
223+import os
224+from osv import osv, fields
225+import base64
226+import csv
227+import StringIO
228+import time
229+
230+class stock_picking(osv.osv):
231+ _inherit = "stock.picking"
232+
233+ """equivalent query to this export ---
234+ select sm.date, sm.name, sm.product_qty, pp.default_code
235+ from stock_move as sm, product_product as pp
236+ where sm.product_id=pp.id
237+ """
238+
239+ def create_export_stk_moves(self,cr,uid,picking_ids,context=None):
240+ if not context:
241+ context={}
242+
243+ stock_picking = self.browse(cr, uid, picking_ids, context=context)
244+ val=[]
245+ diction={}
246+
247+ for picking in stock_picking:
248+ for line in picking.move_lines:
249+ my_date = time.strptime(line.date, "%Y-%m-%d %H:%M:%S")
250+ diction['date'] = time.strftime("%d/%m/%Y", my_date)
251+ diction['1'] = ""
252+ diction['reference'] = picking.name
253+ diction['name'] = line.name
254+ diction['product_qty'] = line.product_qty
255+ diction['default_code'] = line.product_id.default_code
256+ val.append(diction.copy())
257+
258+ buf = StringIO.StringIO()
259+
260+ csv.register_dialect('dialect_1', lineterminator = '\n', delimiter=',', quoting=csv.QUOTE_ALL)
261+
262+ writer = csv.DictWriter(buf, ['date','1','reference','name','product_qty','default_code',], dialect='dialect_1')
263+
264+ writer.writerows(val)
265+ values = base64.encodestring( buf.getvalue() )
266+ buf.close()
267+ return values
268+
269+stock_picking()
270+
271+class stock_move(osv.osv):
272+ _inherit = "stock.move"
273+
274+ """equivalent query to this export ---
275+ select sm.date, sm.name, sm.product_qty, pp.default_code
276+ from stock_move as sm, product_product as pp
277+ where sm.product_id=pp.id
278+ """
279+
280+ def create_export_stk_moves(self,cr,uid,move_ids,context=None):
281+ if not context:
282+ context={}
283+
284+ stock_move = self.browse(cr, uid, move_ids, context=context)
285+ val=[]
286+ diction={}
287+
288+ for move in stock_move:
289+ my_date = time.strptime(move.date, "%Y-%m-%d %H:%M:%S")
290+ diction['date'] = time.strftime("%d/%m/%Y", my_date)
291+ diction['1'] = ""
292+ diction['reference'] = move.picking_id.name
293+ diction['name'] = move.name
294+ diction['product_qty'] = move.product_qty
295+ diction['default_code'] = move.product_id.default_code
296+ val.append(diction.copy())
297+
298+ contx=context.copy()
299+
300+ buf = StringIO.StringIO()
301+
302+ csv.register_dialect('dialect_1', lineterminator = '\n', delimiter=',', quoting=csv.QUOTE_ALL)
303+
304+ writer = csv.DictWriter(buf, ['date','1','reference','name','product_qty','default_code',], dialect='dialect_1')
305+
306+ writer.writerows(val)
307+ values = base64.encodestring( buf.getvalue() )
308+ buf.close()
309+ return values
310+
311+stock_move()
312\ No newline at end of file
313
314=== added file 'stock_view.xml'
315--- stock_view.xml 1970-01-01 00:00:00 +0000
316+++ stock_view.xml 2012-09-25 23:32:22 +0000
317@@ -0,0 +1,75 @@
318+<?xml version="1.0" encoding="utf-8"?>
319+<openerp>
320+ <data>
321+<!--
322+ View of wizard on stock.picking
323+-->
324+ <record id="stock_dumb_wizard_export_csv_form" model="ir.ui.view">
325+ <field name="name">stock.dumb.wizard.export.csv.form</field>
326+ <field name="model">stock.dumb.wizard.export.csv</field>
327+ <field name="type">form</field>
328+ <field name="arch" type="xml">
329+ <form string="Exportar to CSV">
330+ <field name="file.csv" colspan="4" nolabel="1" filename="PT OpenERP - PWST.csv"/>
331+ <group colspan="4">
332+ <button string="Cancel" icon="gtk-cancel" type="object" special="cancel"/>
333+ <button string="Get data to export" icon="gtk-ok" name="action_export2" type="object"/>
334+ </group>
335+ </form>
336+ </field>
337+ </record>
338+
339+ <act_window id="stock_dumb_wizard_stock_picking"
340+ name="Export to csv"
341+ src_model="stock.picking"
342+ res_model="stock.dumb.wizard.export.csv"
343+ view_mode="form"
344+ target="new"
345+ key2="client_action_multi"
346+ />
347+
348+ <record id="stock_dumb_wizard_export_csv_action" model="ir.actions.act_window">
349+ <field name="name">Wizard</field>
350+ <field name="res_model">stock.dumb.wizard.export.csv</field>
351+ <field name="view_type">form</field>
352+ <field name="view_mode">form</field>
353+ <field name="target">new</field>
354+ </record>
355+<!--
356+ View of wizard on stock.picking
357+-->
358+ <record id="stock_dumb_wizard_export_stk_move_form" model="ir.ui.view">
359+ <field name="name">stock.dumb.wizard.export.stk.move.form</field>
360+ <field name="model">stock.dumb.wizard.export.stk.move</field>
361+ <field name="type">form</field>
362+ <field name="arch" type="xml">
363+ <form string="Exportar to CSV">
364+ <field name="file.csv" colspan="4" nolabel="1" filename="PT OpenERP - PWST.csv"/>
365+ <group colspan="4">
366+ <button string="Cancel" icon="gtk-cancel" type="object" special="cancel"/>
367+ <button string="Get data to export" icon="gtk-ok" name="action_export3" type="object"/>
368+ </group>
369+ </form>
370+ </field>
371+ </record>
372+
373+ <act_window id="stock_dumb_wizard_stock_move"
374+ name="Export to csv"
375+ src_model="stock.move"
376+ res_model="stock.dumb.wizard.export.stk.move"
377+ view_mode="form"
378+ target="new"
379+ key2="client_action_multi"
380+ />
381+
382+
383+ <record id="stock_dumb_wizard_stock_move_action" model="ir.actions.act_window">
384+ <field name="name">Wizard</field>
385+ <field name="res_model">stock.dumb.wizard.export.stk.move</field>
386+ <field name="view_type">form</field>
387+ <field name="view_mode">form</field>
388+ <field name="target">new</field>
389+ </record>
390+
391+ </data>
392+</openerp>
393
394=== added directory 'wizard'
395=== added file 'wizard/__init__.py'
396--- wizard/__init__.py 1970-01-01 00:00:00 +0000
397+++ wizard/__init__.py 2012-09-25 23:32:22 +0000
398@@ -0,0 +1,26 @@
399+# -*- encoding: utf-8 -*-
400+###########################################################################
401+# Module Writen to OpenERP, Open Source Management Solution
402+#
403+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
404+# All Rights Reserved.
405+# info@vauxoo.com
406+############################################################################
407+# Coded by: fernandoL (fernando_ld@vauxoo.com)
408+############################################################################
409+#
410+# This program is free software: you can redistribute it and/or modify
411+# it under the terms of the GNU Affero General Public License as
412+# published by the Free Software Foundation, either version 3 of the
413+# License, or (at your option) any later version.
414+#
415+# This program is distributed in the hope that it will be useful,
416+# but WITHOUT ANY WARRANTY; without even the implied warranty of
417+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
418+# GNU Affero General Public License for more details.
419+#
420+# You should have received a copy of the GNU Affero General Public License
421+# along with this program. If not, see <http://www.gnu.org/licenses/>.
422+#
423+##############################################################################
424+import wizard
425\ No newline at end of file
426
427=== added file 'wizard/wizard.py'
428--- wizard/wizard.py 1970-01-01 00:00:00 +0000
429+++ wizard/wizard.py 2012-09-25 23:32:22 +0000
430@@ -0,0 +1,61 @@
431+# -*- encoding: utf-8 -*-
432+###########################################################################
433+# Module Writen to OpenERP, Open Source Management Solution
434+#
435+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
436+# All Rights Reserved.
437+# info@vauxoo.com
438+############################################################################
439+# Coded by: fernandoL (fernando_ld@vauxoo.com)
440+############################################################################
441+#
442+# This program is free software: you can redistribute it and/or modify
443+# it under the terms of the GNU Affero General Public License as
444+# published by the Free Software Foundation, either version 3 of the
445+# License, or (at your option) any later version.
446+#
447+# This program is distributed in the hope that it will be useful,
448+# but WITHOUT ANY WARRANTY; without even the implied warranty of
449+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
450+# GNU Affero General Public License for more details.
451+#
452+# You should have received a copy of the GNU Affero General Public License
453+# along with this program. If not, see <http://www.gnu.org/licenses/>.
454+#
455+##############################################################################
456+import time
457+from osv import osv, fields
458+import decimal_precision as dp
459+from tools.translate import _
460+
461+class stock_dumb_wizard_export_csv(osv.osv_memory):
462+ _name='stock.dumb.wizard.export.csv'
463+ _columns={
464+ 'file.csv' : fields.binary('File CSV'),
465+ }
466+
467+ def action_export2(self,cr,uid,ids,context={}):
468+ if not context:
469+ context={}
470+ picking_ids = context.get('active_ids', [])
471+ stock_picking_obj = self.pool.get('stock.picking')
472+ val = stock_picking_obj.create_export_stk_moves(cr,uid,picking_ids,context=context)
473+ self.write(cr,uid,ids,{'file.csv' : val})
474+ return True
475+stock_dumb_wizard_export_csv()
476+
477+class stock_dumb_wizard_export_stk_move(osv.osv_memory):
478+ _name='stock.dumb.wizard.export.stk.move'
479+ _columns={
480+ 'file.csv' : fields.binary('File CSV'),
481+ }
482+
483+ def action_export3(self,cr,uid,ids,context={}):
484+ if not context:
485+ context={}
486+ move_ids = context.get('active_ids', [])
487+ stock_move_obj = self.pool.get('stock.move')
488+ val = stock_move_obj.create_export_stk_moves(cr,uid,move_ids,context=context)
489+ self.write(cr,uid,ids,{'file.csv' : val})
490+ return True
491+stock_dumb_wizard_export_stk_move()
492\ No newline at end of file