Browse Source

update licence. update documentation. add export_data. clean docstring

pull/115/head
Laetitia Gangloff 10 years ago
parent
commit
3999f37308
  1. 8
      base_export_email/__init__.py
  2. 19
      base_export_email/__openerp__.py
  3. 27
      base_export_email/ir_actions.py
  4. 1
      base_export_email/ir_actions.xml

8
base_export_email/__init__.py

@ -3,14 +3,6 @@
#
# Authors: Laetitia Gangloff
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs.
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contact a Free Software
# Service Company.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as

19
base_export_email/__openerp__.py

@ -3,14 +3,6 @@
#
# Authors: Laetitia Gangloff
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs.
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contact a Free Software
# Service Company.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -40,7 +32,16 @@
Base export email addon
=========================
- Add server action type to send by email a data export
Add server action type to send by email a data export
For this new action type you need to fill the following fields :
- Filter : it defines the filter to use on the data.
- Template : it is the mail template to send the email.
- Saved export : it is a saved export list.
- Fields to export : it is the list of field to export. It can be used alone
or to complete the saved export list.
Example of use : in a cron for a periodic export of some data
to see the evolution.
""",
"data": ["ir_actions.xml"],

27
base_export_email/ir_actions.py

@ -3,14 +3,6 @@
#
# Authors: Laetitia Gangloff
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs.
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contact a Free Software
# Service Company.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -56,10 +48,14 @@ class actions_server(orm.Model):
'fields_to_export': fields.text(
'Fields to export',
help="The list of fields to export. \
The format is ['name', 'seller_ids/product_name']")
The format is ['name', 'seller_ids/product_name']"),
'export_format': fields.selection([('csv', 'CSV'),
('xls', 'Excel')],
'Export Formats'),
}
_defaults = {'fields_to_export': '[]'}
_defaults = {'fields_to_export': '[]',
'export_format': 'csv'}
def onchange_model_id(self, cr, uid, ids, model_id, context=None):
"""
@ -76,9 +72,6 @@ class actions_server(orm.Model):
return {'value': data}
def _search_data(self, cr, uid, action, context=None):
"""
search data to export
"""
obj_pool = self.pool[action.model]
domain = action.filter_id and safe_eval(
action.filter_id.domain, {'time': time}) or []
@ -89,9 +82,6 @@ class actions_server(orm.Model):
context=ctx)
def _export_data(self, cr, uid, obj_ids, action, context=None):
"""
export data
"""
obj_pool = self.pool[action.model]
export_fields = []
if action.fields_to_export:
@ -119,7 +109,10 @@ class actions_server(orm.Model):
(4, partner_id) for partner_id in values.pop('partner_ids',
[])
]
export = main.CSVExport()
if action.export_format == 'csv':
export = main.CSVExport()
else:
export = main.ExcelExport()
filename = export.filename(action.model)
content = export.from_data(export_fields, export_data)
if isinstance(content, unicode):

1
base_export_email/ir_actions.xml

@ -28,6 +28,7 @@
<notebook position="inside">
<page string="Export data by email configuration" attrs="{'invisible':[('state','!=','export_email')]}">
<group>
<field name="export_format" attrs="{'required':[('state','=','export_email')]}"/>
<field name="filter_id" domain="[('model_id','=',model)]"/>
<field name="email_template_id" attrs="{'required':[('state','=','export_email')]}"
domain="[('model_id', '=', model_id)]"/>

Loading…
Cancel
Save