avanzosc team mailing list archive
-
avanzosc team
-
Mailing list archive
-
Message #00545
[Merge] lp:~mikelarregi/avanzosc/nayar_account_invoice_csv into lp:~avanzosc-security-team/avanzosc/72horas
mikel arregi has proposed merging lp:~mikelarregi/avanzosc/nayar_account_invoice_csv into lp:~avanzosc-security-team/avanzosc/72horas.
Requested reviews:
Avanzosc_security (avanzosc-security-team)
For more details, see:
https://code.launchpad.net/~mikelarregi/avanzosc/nayar_account_invoice_csv/+merge/225489
nayar_account_invoice_csv
--
https://code.launchpad.net/~mikelarregi/avanzosc/nayar_account_invoice_csv/+merge/225489
Your team Avanzosc_security is requested to review the proposed merge of lp:~mikelarregi/avanzosc/nayar_account_invoice_csv into lp:~avanzosc-security-team/avanzosc/72horas.
=== modified file 'nayar_account_invoice_csv/__init__.py'
--- nayar_account_invoice_csv/__init__.py 2014-06-11 10:23:47 +0000
+++ nayar_account_invoice_csv/__init__.py 2014-07-03 14:29:20 +0000
@@ -18,5 +18,4 @@
#
##############################################################################
-import invoice
import wizard
=== modified file 'nayar_account_invoice_csv/__openerp__.py'
--- nayar_account_invoice_csv/__openerp__.py 2014-06-11 10:23:47 +0000
+++ nayar_account_invoice_csv/__openerp__.py 2014-07-03 14:29:20 +0000
@@ -25,11 +25,8 @@
"category": "Enterprise Specific Modules",
"description": "Module to export account invoice to a csv format file.",
"depends": ["account"],
- "init_xml": [],
- "demo_xml": [],
- "update_xml": ["account_invoice_csv_wizard.xml"],
+ "data": ["wizard/account_invoice_csv_wizard.xml"],
"website": 'http://www.72horas.net',
- "active": False,
"installable": True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added directory 'nayar_account_invoice_csv/models'
=== added file 'nayar_account_invoice_csv/models/__init__.py'
--- nayar_account_invoice_csv/models/__init__.py 1970-01-01 00:00:00 +0000
+++ nayar_account_invoice_csv/models/__init__.py 2014-07-03 14:29:20 +0000
@@ -0,0 +1,21 @@
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2012 Nayar Systems (<http://www.72horas.net>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import invoice
=== renamed file 'nayar_account_invoice_csv/invoice.py' => 'nayar_account_invoice_csv/models/invoice.py'
--- nayar_account_invoice_csv/invoice.py 2014-06-11 10:23:47 +0000
+++ nayar_account_invoice_csv/models/invoice.py 2014-07-03 14:29:20 +0000
@@ -19,34 +19,34 @@
#
##############################################################################
-from osv import osv
-
-
-class account_invoice(osv.osv):
+from openerp.osv import orm, fields
+
+
+class account_invoice(orm.Model):
_inherit = 'account.invoice'
def get_phones_csv(self, cr, uid, ids, context=None):
- line_obj = self.pool.get('account.invoice.line')
-
+ line_obj = self.pool['account.invoice.line']
if not(type(ids)) is [list]:
ids = [ids]
-
- line_ids = line_obj.search(cr, uid, [('invoice_id', 'in', ids), ('product_id.categ_id', '=', 2)], order='product_identifier')
- csv = u"Línea;Enlace;Inicio cto;n cab;Fac. Desde;Fac. Hasta;Meses;€/mes;Referencia;Total;Imei\n"
- for line in line_obj.browse(cr, uid, line_ids):
- csv += u"%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n" % (line.product_identifier,
- line.contract_annexe_id.production_lot_2_id and line.contract_annexe_id.production_lot_2_id.product_id.name or '',
- line.contract_annexe_id.annexe_date,
- line.num_cabins,
- line.start_date,
- line.end_date,
- "%.2f" % line.months,
- "%.2f" % (line.price_subtotal / line.months),
- (line.customer_ref or '').encode('ascii', 'replace'),
- "%.2f" % line.price_subtotal,
- line.contract_annexe_id.production_lot_2_id and line.contract_annexe_id.production_lot_2_id.imei or '')
-
+ line_ids = line_obj.search(cr, uid, [('invoice_id', 'in', ids),
+ ('product_id.categ_id', '=', 2)],
+ order='product_identifier', context=context)
+ csv = (u"Línea;Enlace;Inicio cto;n cab;Fac. Desde;Fac. Hasta;Meses;€/"
+ "mes;Referencia;Total;Imei\n")
+ for line in line_obj.browse(cr, uid, line_ids, context=context):
+ lot_2_id = line.contract_annexe_id.production_lot_2_id
+ csv += (
+ u"%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n" % (
+ line.product_identifier,
+ lot_2_id and lot_2_id.product_id.name or '',
+ line.contract_annexe_id.annexe_date,
+ line.num_cabins,
+ line.start_date,
+ line.end_date,
+ "%.2f" % line.months,
+ "%.2f" % (line.price_subtotal / line.months),
+ (line.customer_ref or '').encode('ascii', 'replace'),
+ "%.2f" % line.price_subtotal,
+ lot_2_id and lot_2_id.imei or ''))
return csv
-
-
-account_invoice()
=== renamed file 'nayar_account_invoice_csv/account_invoice_csv_wizard.xml' => 'nayar_account_invoice_csv/wizard/account_invoice_csv_wizard.xml'
--- nayar_account_invoice_csv/account_invoice_csv_wizard.xml 2014-06-11 10:23:47 +0000
+++ nayar_account_invoice_csv/wizard/account_invoice_csv_wizard.xml 2014-07-03 14:29:20 +0000
@@ -1,6 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
- <data>
- <wizard string="Create CSV" model="account.invoice" name="account.invoice.create_csv" id="account_invoice_csv_wizard"/>
- </data>
+ <data>
+ <record model="ir.ui.view" id="invoice_csv_wizard_form_view">
+ <field name="name">invoice csv wizard</field>
+ <field name="model">create.csv.wizard</field>
+ <field name="arch" type="xml">
+ <form string="Invoice CSV File">
+ <field name="data" />
+ <footer>
+ <button class="oe_link" special="cancel" string="Cancel" />
+ <button name="create_csv" string="Create csv" type="object"
+ icon="gtk-ok" />
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <act_window name="string" res_model="create.csv.wizard"
+ src_model="account.invoice" id="act_create_csv_wizard" key2="client_action_multi"
+ view_id="invoice_csv_wizard_form_view" target="new" />
+
+ </data>
</openerp>
=== modified file 'nayar_account_invoice_csv/wizard/wizard_create_csv.py'
--- nayar_account_invoice_csv/wizard/wizard_create_csv.py 2014-06-11 10:23:47 +0000
+++ nayar_account_invoice_csv/wizard/wizard_create_csv.py 2014-07-03 14:29:20 +0000
@@ -19,33 +19,21 @@
#
##############################################################################
-import wizard
-import pooler
+from openerp.osv import fields, orm
import base64
-csv_form = '''<?xml version="1.0" encoding="utf-8"?>
-<form string="Invoice CSV File">
- <field name="data"/>
-</form>'''
-
-csv_fields = {
- 'data': {'string': 'CSV file', 'type': 'binary', 'readonly': True},
- 'name': {'string': 'File Name', 'type': 'char', 'size': 32, 'readonly': True}
- }
-
-def _create_csv(self, cr, uid, data, context):
- p = pooler.get_pool(cr.dbname)
- invoice_obj = p.get('account.invoice')
- csv = invoice_obj.get_phones_csv(cr, uid, data['ids'])
- return {'name': (p.get('account.invoice').browse(cr, uid, data['ids'][0]).number or 'invoice') + '.csv',
+
+class CreateCsvWizard(orm.TransientModel):
+ _name = 'create.csv.wizard'
+ _columns = {
+ 'data': fields.binary('CSV file', readonly=True),
+ 'name': fields.char('File Name', size=32, readonly=True)
+ }
+
+ def create_csv(self, cr, uid, data, context):
+ invoice_obj = self.pool['account.invoice']
+ csv = invoice_obj.get_phones_csv(cr, uid, data['ids'])
+ return {'name': (
+ invoice_obj.browse(cr, uid, data['ids'][0]).number or
+ 'invoice') + '.csv',
'data': base64.encodestring(csv.encode('utf8'))}
-
-class create_csv(wizard.interface):
- states = {
- 'init': {
- 'actions': [_create_csv],
- 'result': {'type': 'form', 'arch': csv_form, 'fields': csv_fields, 'state': [('end', 'End')]}
- }
- }
-
-create_csv('account.invoice.create_csv')
Follow ups