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
=== added file '__init__.py'
--- __init__.py 1970-01-01 00:00:00 +0000
+++ __init__.py 2012-09-25 23:32:22 +0000
@@ -0,0 +1,27 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6# All Rights Reserved.
7# info@vauxoo.com
8############################################################################
9# Coded by: fernandoL (fernando_ld@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (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 Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26import wizard
27import stock
0\ No newline at end of file28\ No newline at end of file
129
=== added file '__openerp__.py'
--- __openerp__.py 1970-01-01 00:00:00 +0000
+++ __openerp__.py 2012-09-25 23:32:22 +0000
@@ -0,0 +1,45 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6# All Rights Reserved.
7# info@vauxoo.com
8############################################################################
9# Coded by: fernandoL (fernando_ld@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (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 Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26
27{
28 "name": "Stock dumb wizard export csv",
29 "version": "1.0",
30 "author" : "Vauxoo",
31 "category": "Generic Modules/Production",
32 "website" : "http://www.vauxoo.com/",
33 "description": """ Add wizard to export to a csv the stock_move lines
34 from the stock_picking model
35 """,
36 'depends': ['stock'],
37 'init_xml': [],
38 'update_xml': [
39 'stock_view.xml',
40 ],
41 'demo_xml': [],
42 'test': [],
43 'installable': True,
44 'active': False,
45}
0\ No newline at end of file46\ No newline at end of file
147
=== added directory 'i18n'
=== added file 'i18n/es_MX.mo'
2Binary files i18n/es_MX.mo 1970-01-01 00:00:00 +0000 and i18n/es_MX.mo 2012-09-25 23:32:22 +0000 differ48Binary 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
=== added file 'i18n/es_MX.po'
--- i18n/es_MX.po 1970-01-01 00:00:00 +0000
+++ i18n/es_MX.po 2012-09-25 23:32:22 +0000
@@ -0,0 +1,93 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * stock_dumb_wizard_export_csv
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2012-09-24 23:15+0000\n"
10"PO-Revision-Date: 2012-09-24 18:23-0600\n"
11"Last-Translator: Kyon <fernando_ld@vauxoo.com>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"
17
18#. module: stock_dumb_wizard_export_csv
19#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_dumb_wizard_export_csv
20msgid "stock.dumb.wizard.export.csv"
21msgstr "stock.dumb.wizard.export.csv"
22
23#. module: stock_dumb_wizard_export_csv
24#: view:stock.dumb.wizard.export.csv:0
25#: view:stock.dumb.wizard.export.stk.move:0
26msgid "Exportar to CSV"
27msgstr "Exportar a csv"
28
29#. module: stock_dumb_wizard_export_csv
30#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_dumb_wizard_export_stk_move
31msgid "stock.dumb.wizard.export.stk.move"
32msgstr "stock.dumb.wizard.export.stk.move"
33
34#. module: stock_dumb_wizard_export_csv
35#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_move
36msgid "Stock Move"
37msgstr "Stock Move"
38
39#. module: stock_dumb_wizard_export_csv
40#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_stock_move
41#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_stock_picking
42msgid "Export to csv"
43msgstr "Exportar a csv"
44
45#. module: stock_dumb_wizard_export_csv
46#: constraint:stock.move:0
47msgid "You can not move products from or to a location of the type view."
48msgstr "No puedes mover productos desde o a una locación del tipo vista"
49
50#. module: stock_dumb_wizard_export_csv
51#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_export_csv_action
52#: model:ir.actions.act_window,name:stock_dumb_wizard_export_csv.stock_dumb_wizard_stock_move_action
53msgid "Wizard"
54msgstr "Asistente"
55
56#. module: stock_dumb_wizard_export_csv
57#: constraint:stock.move:0
58msgid "You must assign a production lot for this product"
59msgstr "Debe asignar un lote de producción para este producto"
60
61#. module: stock_dumb_wizard_export_csv
62#: field:stock.dumb.wizard.export.csv,file.csv:0
63#: field:stock.dumb.wizard.export.stk.move,file.csv:0
64msgid "File CSV"
65msgstr "Archivo CSV"
66
67#. module: stock_dumb_wizard_export_csv
68#: constraint:stock.move:0
69msgid "You try to assign a lot which is not from the same product"
70msgstr "Está intentando asignar un lote que no es del mismo producto"
71
72#. module: stock_dumb_wizard_export_csv
73#: view:stock.dumb.wizard.export.csv:0
74#: view:stock.dumb.wizard.export.stk.move:0
75msgid "Get data to export"
76msgstr "Obtener datos a exportar"
77
78#. module: stock_dumb_wizard_export_csv
79#: sql_constraint:stock.picking:0
80msgid "Reference must be unique per Company!"
81msgstr "¡La referencia debe ser única por compañía!"
82
83#. module: stock_dumb_wizard_export_csv
84#: model:ir.model,name:stock_dumb_wizard_export_csv.model_stock_picking
85msgid "Picking List"
86msgstr "Albarán (lista de remisiones)"
87
88#. module: stock_dumb_wizard_export_csv
89#: view:stock.dumb.wizard.export.csv:0
90#: view:stock.dumb.wizard.export.stk.move:0
91msgid "Cancel"
92msgstr "Cancelar"
93
094
=== added file 'stock.py'
--- stock.py 1970-01-01 00:00:00 +0000
+++ stock.py 2012-09-25 23:32:22 +0000
@@ -0,0 +1,122 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6# All Rights Reserved.
7# info@vauxoo.com
8############################################################################
9# Coded by: fernandoL (fernando_ld@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (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 Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26
27import pooler
28import wizard
29import base64
30import cStringIO
31import netsvc
32from tools.translate import _
33import tools
34import os
35from osv import osv, fields
36import base64
37import csv
38import StringIO
39import time
40
41class stock_picking(osv.osv):
42 _inherit = "stock.picking"
43
44 """equivalent query to this export ---
45 select sm.date, sm.name, sm.product_qty, pp.default_code
46 from stock_move as sm, product_product as pp
47 where sm.product_id=pp.id
48 """
49
50 def create_export_stk_moves(self,cr,uid,picking_ids,context=None):
51 if not context:
52 context={}
53
54 stock_picking = self.browse(cr, uid, picking_ids, context=context)
55 val=[]
56 diction={}
57
58 for picking in stock_picking:
59 for line in picking.move_lines:
60 my_date = time.strptime(line.date, "%Y-%m-%d %H:%M:%S")
61 diction['date'] = time.strftime("%d/%m/%Y", my_date)
62 diction['1'] = ""
63 diction['reference'] = picking.name
64 diction['name'] = line.name
65 diction['product_qty'] = line.product_qty
66 diction['default_code'] = line.product_id.default_code
67 val.append(diction.copy())
68
69 buf = StringIO.StringIO()
70
71 csv.register_dialect('dialect_1', lineterminator = '\n', delimiter=',', quoting=csv.QUOTE_ALL)
72
73 writer = csv.DictWriter(buf, ['date','1','reference','name','product_qty','default_code',], dialect='dialect_1')
74
75 writer.writerows(val)
76 values = base64.encodestring( buf.getvalue() )
77 buf.close()
78 return values
79
80stock_picking()
81
82class stock_move(osv.osv):
83 _inherit = "stock.move"
84
85 """equivalent query to this export ---
86 select sm.date, sm.name, sm.product_qty, pp.default_code
87 from stock_move as sm, product_product as pp
88 where sm.product_id=pp.id
89 """
90
91 def create_export_stk_moves(self,cr,uid,move_ids,context=None):
92 if not context:
93 context={}
94
95 stock_move = self.browse(cr, uid, move_ids, context=context)
96 val=[]
97 diction={}
98
99 for move in stock_move:
100 my_date = time.strptime(move.date, "%Y-%m-%d %H:%M:%S")
101 diction['date'] = time.strftime("%d/%m/%Y", my_date)
102 diction['1'] = ""
103 diction['reference'] = move.picking_id.name
104 diction['name'] = move.name
105 diction['product_qty'] = move.product_qty
106 diction['default_code'] = move.product_id.default_code
107 val.append(diction.copy())
108
109 contx=context.copy()
110
111 buf = StringIO.StringIO()
112
113 csv.register_dialect('dialect_1', lineterminator = '\n', delimiter=',', quoting=csv.QUOTE_ALL)
114
115 writer = csv.DictWriter(buf, ['date','1','reference','name','product_qty','default_code',], dialect='dialect_1')
116
117 writer.writerows(val)
118 values = base64.encodestring( buf.getvalue() )
119 buf.close()
120 return values
121
122stock_move()
0\ No newline at end of file123\ No newline at end of file
1124
=== added file 'stock_view.xml'
--- stock_view.xml 1970-01-01 00:00:00 +0000
+++ stock_view.xml 2012-09-25 23:32:22 +0000
@@ -0,0 +1,75 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4<!--
5 View of wizard on stock.picking
6-->
7 <record id="stock_dumb_wizard_export_csv_form" model="ir.ui.view">
8 <field name="name">stock.dumb.wizard.export.csv.form</field>
9 <field name="model">stock.dumb.wizard.export.csv</field>
10 <field name="type">form</field>
11 <field name="arch" type="xml">
12 <form string="Exportar to CSV">
13 <field name="file.csv" colspan="4" nolabel="1" filename="PT OpenERP - PWST.csv"/>
14 <group colspan="4">
15 <button string="Cancel" icon="gtk-cancel" type="object" special="cancel"/>
16 <button string="Get data to export" icon="gtk-ok" name="action_export2" type="object"/>
17 </group>
18 </form>
19 </field>
20 </record>
21
22 <act_window id="stock_dumb_wizard_stock_picking"
23 name="Export to csv"
24 src_model="stock.picking"
25 res_model="stock.dumb.wizard.export.csv"
26 view_mode="form"
27 target="new"
28 key2="client_action_multi"
29 />
30
31 <record id="stock_dumb_wizard_export_csv_action" model="ir.actions.act_window">
32 <field name="name">Wizard</field>
33 <field name="res_model">stock.dumb.wizard.export.csv</field>
34 <field name="view_type">form</field>
35 <field name="view_mode">form</field>
36 <field name="target">new</field>
37 </record>
38<!--
39 View of wizard on stock.picking
40-->
41 <record id="stock_dumb_wizard_export_stk_move_form" model="ir.ui.view">
42 <field name="name">stock.dumb.wizard.export.stk.move.form</field>
43 <field name="model">stock.dumb.wizard.export.stk.move</field>
44 <field name="type">form</field>
45 <field name="arch" type="xml">
46 <form string="Exportar to CSV">
47 <field name="file.csv" colspan="4" nolabel="1" filename="PT OpenERP - PWST.csv"/>
48 <group colspan="4">
49 <button string="Cancel" icon="gtk-cancel" type="object" special="cancel"/>
50 <button string="Get data to export" icon="gtk-ok" name="action_export3" type="object"/>
51 </group>
52 </form>
53 </field>
54 </record>
55
56 <act_window id="stock_dumb_wizard_stock_move"
57 name="Export to csv"
58 src_model="stock.move"
59 res_model="stock.dumb.wizard.export.stk.move"
60 view_mode="form"
61 target="new"
62 key2="client_action_multi"
63 />
64
65
66 <record id="stock_dumb_wizard_stock_move_action" model="ir.actions.act_window">
67 <field name="name">Wizard</field>
68 <field name="res_model">stock.dumb.wizard.export.stk.move</field>
69 <field name="view_type">form</field>
70 <field name="view_mode">form</field>
71 <field name="target">new</field>
72 </record>
73
74 </data>
75</openerp>
076
=== added directory 'wizard'
=== added file 'wizard/__init__.py'
--- wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ wizard/__init__.py 2012-09-25 23:32:22 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6# All Rights Reserved.
7# info@vauxoo.com
8############################################################################
9# Coded by: fernandoL (fernando_ld@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (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 Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26import wizard
0\ No newline at end of file27\ No newline at end of file
128
=== added file 'wizard/wizard.py'
--- wizard/wizard.py 1970-01-01 00:00:00 +0000
+++ wizard/wizard.py 2012-09-25 23:32:22 +0000
@@ -0,0 +1,61 @@
1# -*- encoding: utf-8 -*-
2###########################################################################
3# Module Writen to OpenERP, Open Source Management Solution
4#
5# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6# All Rights Reserved.
7# info@vauxoo.com
8############################################################################
9# Coded by: fernandoL (fernando_ld@vauxoo.com)
10############################################################################
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (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 Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26import time
27from osv import osv, fields
28import decimal_precision as dp
29from tools.translate import _
30
31class stock_dumb_wizard_export_csv(osv.osv_memory):
32 _name='stock.dumb.wizard.export.csv'
33 _columns={
34 'file.csv' : fields.binary('File CSV'),
35 }
36
37 def action_export2(self,cr,uid,ids,context={}):
38 if not context:
39 context={}
40 picking_ids = context.get('active_ids', [])
41 stock_picking_obj = self.pool.get('stock.picking')
42 val = stock_picking_obj.create_export_stk_moves(cr,uid,picking_ids,context=context)
43 self.write(cr,uid,ids,{'file.csv' : val})
44 return True
45stock_dumb_wizard_export_csv()
46
47class stock_dumb_wizard_export_stk_move(osv.osv_memory):
48 _name='stock.dumb.wizard.export.stk.move'
49 _columns={
50 'file.csv' : fields.binary('File CSV'),
51 }
52
53 def action_export3(self,cr,uid,ids,context={}):
54 if not context:
55 context={}
56 move_ids = context.get('active_ids', [])
57 stock_move_obj = self.pool.get('stock.move')
58 val = stock_move_obj.create_export_stk_moves(cr,uid,move_ids,context=context)
59 self.write(cr,uid,ids,{'file.csv' : val})
60 return True
61stock_dumb_wizard_export_stk_move()
0\ No newline at end of file62\ No newline at end of file