Merge lp:~vauxoo/openerp-mexico-localization/rate_update_tax_dev_juan_carlos into lp:openerp-mexico-localization

Proposed by Juan Carlos Hernandez
Status: Needs review
Proposed branch: lp:~vauxoo/openerp-mexico-localization/rate_update_tax_dev_juan_carlos
Merge into: lp:openerp-mexico-localization
Diff against target: 194 lines (+174/-0)
4 files modified
l10n_mx_rate_update/__init__.py (+23/-0)
l10n_mx_rate_update/__openerp__.py (+41/-0)
l10n_mx_rate_update/rate_update.py (+91/-0)
l10n_mx_rate_update/rate_update.xml (+19/-0)
To merge this branch: bzr merge lp:~vauxoo/openerp-mexico-localization/rate_update_tax_dev_juan_carlos
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Needs Fixing
Juan Carlos Hernandez (community) Needs Resubmitting
Isaac López Zúñiga Pending
Review via email: mp+121303@code.launchpad.net

Description of the change

add module rate update

To post a comment you must log in.
194. By Juan Carlos Hernandez

[IMP][rate_update]add validation

195. By Juan Carlos Hernandez

[DEL][rate_update]delete webserv.py

196. By Juan Carlos Hernandez

[IMP][rate_update]add validation for MXN and USD

197. By Juan Carlos Hernandez

[IMP][rate_update]add validation for division for zero

198. By Juan Carlos Hernandez

[IMP][rate_update]add validation error division for zero

Revision history for this message
Juan Carlos Hernandez (openerp1) wrote :

1.-borre archivo inútil
3.-se agrego de tipo flotante el rate para que no marque error
2.validación para la base con MXN y USD
3.-validación para la división con cero
4.-se agrego función solo para extraer el valor del webservices
5.-se agrego función para agregar el rate, esta manda llamar la funcion anterior
6.-se agrego función para la acción planificada,esta manda llamar la función anterior

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

Cambia el nombre del módulo de rate_update a
l10n_mx_rate_update

Y también agrega un wizard en el modelo res.currency, donde se pueda mandar a llamar a esta función en cierta fecha ingresada desde el mismo wizard, y que mande un texto el cual diga que fue lo que modifico y en que moneda.

review: Needs Fixing
199. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]change module name rate_update to l10n_mx_rate_update

200. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add wizard

201. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add wizard_rate_update

202. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]del create_attendee_view.xml

203. By Juan Carlos Hernandez

[IMP][view_rate_update]change id a view

204. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add function query_rate

205. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]quit print and add traduction

206. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update] quit attrs de xml

207. By Juan Carlos Hernandez

[IMP][wizard]add required

208. By Juan Carlos Hernandez

[IMP][wizard]add default

209. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add update with date

210. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add function

211. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add msg

212. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]depuration wizard

213. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]del import wizard

Unmerged revisions

213. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]del import wizard

212. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]depuration wizard

211. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add msg

210. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add function

209. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add update with date

208. By Juan Carlos Hernandez

[IMP][wizard]add default

207. By Juan Carlos Hernandez

[IMP][wizard]add required

206. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update] quit attrs de xml

205. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]quit print and add traduction

204. By Juan Carlos Hernandez

[IMP][l10n_mx_rate_update]add function query_rate

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'l10n_mx_rate_update'
2=== added file 'l10n_mx_rate_update/__init__.py'
3--- l10n_mx_rate_update/__init__.py 1970-01-01 00:00:00 +0000
4+++ l10n_mx_rate_update/__init__.py 2014-01-18 01:05:28 +0000
5@@ -0,0 +1,23 @@
6+#!/usr/bin/python
7+# -*- encoding: utf-8 -*-
8+###########################################################################
9+# Module Writen to OpenERP, Open Source Management Solution
10+# Copyright (C) Vauxoo (<http://vauxoo.com>).
11+# All Rights Reserved
12+###############Credits######################################################
13+# Coded by: Juan Carlos Funes(juan@vauxoo.com)
14+#############################################################################
15+# This program is free software: you can redistribute it and/or modify
16+# it under the terms of the GNU Affero General Public License as published by
17+# the Free Software Foundation, either version 3 of the License, or
18+# (at your option) any later version.
19+#
20+# This program is distributed in the hope that it will be useful,
21+# but WITHOUT ANY WARRANTY; without even the implied warranty of
22+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+# GNU Affero General Public License for more details.
24+#
25+# You should have received a copy of the GNU Affero General Public License
26+# along with this program. If not, see <http://www.gnu.org/licenses/>.
27+################################################################################
28+import rate_update
29
30=== added file 'l10n_mx_rate_update/__openerp__.py'
31--- l10n_mx_rate_update/__openerp__.py 1970-01-01 00:00:00 +0000
32+++ l10n_mx_rate_update/__openerp__.py 2014-01-18 01:05:28 +0000
33@@ -0,0 +1,41 @@
34+#!/usr/bin/python
35+# -*- encoding: utf-8 -*-
36+###########################################################################
37+# Module Writen to OpenERP, Open Source Management Solution
38+# Copyright (C) Vauxoo (<http://vauxoo.com>).
39+# All Rights Reserved
40+###############Credits######################################################
41+# Coded by: Juan Carlos Funes(juan@vauxoo.com)
42+#############################################################################
43+# This program is free software: you can redistribute it and/or modify
44+# it under the terms of the GNU Affero General Public License as published by
45+# the Free Software Foundation, either version 3 of the License, or
46+# (at your option) any later version.
47+#
48+# This program is distributed in the hope that it will be useful,
49+# but WITHOUT ANY WARRANTY; without even the implied warranty of
50+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51+# GNU Affero General Public License for more details.
52+#
53+# You should have received a copy of the GNU Affero General Public License
54+# along with this program. If not, see <http://www.gnu.org/licenses/>.
55+################################################################################
56+{
57+ "name" : "Update rate",
58+ "version" : "1.0",
59+ "depends" : ['base'],
60+ "author" : "Vauxoo",
61+ #"license" : "AGPL-3",
62+ "description" : """This module update field rate
63+ """,
64+ "website" : "http://vauxoo.com",
65+ "category" : "Generic Modules",
66+ "init_xml" : [],
67+ "demo_xml" : [],
68+ "test": [],
69+ "update_xml" : ['rate_update.xml',
70+ ],
71+ "active": False,
72+ "installable": True,
73+}
74+
75
76=== added file 'l10n_mx_rate_update/rate_update.py'
77--- l10n_mx_rate_update/rate_update.py 1970-01-01 00:00:00 +0000
78+++ l10n_mx_rate_update/rate_update.py 2014-01-18 01:05:28 +0000
79@@ -0,0 +1,91 @@
80+#!/usr/bin/python
81+# -*- encoding: utf-8 -*-
82+###########################################################################
83+# Module Writen to OpenERP, Open Source Management Solution
84+# Copyright (C) Vauxoo (<http://vauxoo.com>).
85+# All Rights Reserved
86+###############Credits######################################################
87+# Coded by: Carlos Funes(juan@vauxoo.com)
88+#############################################################################
89+# This program is free software: you can redistribute it and/or modify
90+# it under the terms of the GNU Affero General Public License as published by
91+# the Free Software Foundation, either version 3 of the License, or
92+# (at your option) any later version.
93+#
94+# This program is distributed in the hope that it will be useful,
95+# but WITHOUT ANY WARRANTY; without even the implied warranty of
96+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+# GNU Affero General Public License for more details.
98+#
99+# You should have received a copy of the GNU Affero General Public License
100+# along with this program. If not, see <http://www.gnu.org/licenses/>.
101+################################################################################
102+from osv import fields, osv, orm
103+from xml.dom import minidom
104+import urllib
105+import pooler
106+from tools.translate import _
107+
108+class res_currency_rate(osv.osv):
109+ _inherit = 'res.currency.rate'
110+
111+ _order = "name desc,id desc"
112+res_currency_rate()
113+
114+class res_currency(osv.osv):
115+ _inherit = 'res.currency'
116+
117+ def accion_update_rate(self,cr,uid):
118+ self.create_currency_rate(cr,uid)
119+ return True
120+
121+ def create_currency_rate(self,cr,uid):
122+ rate=self.currency_update(cr,uid)
123+ currency=self.pool.get('res.company').browse(cr,uid,[uid])[0].currency_id.name
124+ currency_obj = self.pool.get('res.currency')
125+ if not rate==0:
126+ if currency=='MXN':
127+ rate=1.0/rate or 0
128+ rate_ids = currency_obj.search(cr, uid, [('name','=','USD')])
129+ id=rate_ids and rate_ids[0] or ''
130+ data = {'currency_id':id,'rate':rate}
131+ self.pool.get('res.currency.rate').create(cr, uid, data)
132+ elif currency=='USD':
133+ rate_ids = currency_obj.search(cr, uid, [('name','=','MXN')])
134+ id=rate_ids and rate_ids[0] or ''
135+ data = {'currency_id':id,'rate':rate}
136+ self.pool.get('res.currency.rate').create(cr, uid, data)
137+ return True
138+
139+ def currency_update(self, cr, uid):
140+ try:
141+ xml_documento = minidom.parse(urllib.urlopen('http://www.dof.gob.mx/indicadores.xml'))
142+ except:
143+ print 'Could not read the url'
144+ nodos = xml_documento.childNodes
145+ lista_aux=[]
146+ moneda=[]
147+ res={}
148+ rate=0
149+ lista = nodos[0].getElementsByTagName("item")
150+ if lista:
151+ for i in lista:
152+ moneda = i.getElementsByTagName("title")
153+ if moneda:
154+ for m in moneda:
155+ if m.childNodes[0].nodeValue=="DOLAR":
156+ lista_aux = i.getElementsByTagName("description")
157+ for x in lista_aux:
158+ rate=float(x.childNodes[0].nodeValue)
159+ break
160+ else:
161+ print 'No items in the XML file tag DOLAR'
162+ break
163+ else:
164+ print 'No items in the XML file with the tag title'
165+ else:
166+ print 'No items in the XML file tag item'
167+ return rate
168+
169+
170+res_currency()
171
172=== added file 'l10n_mx_rate_update/rate_update.xml'
173--- l10n_mx_rate_update/rate_update.xml 1970-01-01 00:00:00 +0000
174+++ l10n_mx_rate_update/rate_update.xml 2014-01-18 01:05:28 +0000
175@@ -0,0 +1,19 @@
176+<?xml version="1.0"?>
177+<openerp>
178+ <data>
179+
180+ <record id="cron_import_rates" model="ir.cron">
181+ <field name="name">Update Rates Cron</field>
182+ <field name="user_id" ref="base.user_root"/>
183+ <field name="interval_type">days</field>
184+ <field name="interval_number" eval="1"/>
185+ <field name="numbercall" eval="-1"/>
186+ <field name="nextcall" eval="(DateTime.today().replace(hour=07, minute=00,second=00) - timedelta(days=0)).strftime('%Y-%m-%d %H:%M:%S')"/>
187+ <field name="doall" eval="True"/> <!-- Repeat missed calls?!-->
188+ <field name="model" eval="'res.currency'"/>
189+ <field name="function" eval="'accion_update_rate'"/>
190+ <field name="priority" eval="1"/>
191+ </record>
192+
193+ </data>
194+</openerp>