From 6773a6d61074961f2d7a95e03a6cdef433797e91 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Wed, 8 Jan 2014 12:55:30 +0100 Subject: [PATCH 1/3] [imp] add mail thread with report attached to hours block --- analytic_hours_block/__openerp__.py | 1 + analytic_hours_block/hours_block.py | 42 ++++++++++++ analytic_hours_block/hours_block_data.xml | 24 +++++++ analytic_hours_block/hours_block_view.xml | 83 ++++++++++++----------- 4 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 analytic_hours_block/hours_block_data.xml diff --git a/analytic_hours_block/__openerp__.py b/analytic_hours_block/__openerp__.py index 09c78ad7..d6ae9142 100644 --- a/analytic_hours_block/__openerp__.py +++ b/analytic_hours_block/__openerp__.py @@ -44,6 +44,7 @@ you can track and follow how much has been used. ], "data": [ "hours_block_view.xml", + "hours_block_data.xml", "hours_block_menu.xml", "report.xml", "security/hours_block_security.xml", diff --git a/analytic_hours_block/hours_block.py b/analytic_hours_block/hours_block.py index b341702a..064edca5 100644 --- a/analytic_hours_block/hours_block.py +++ b/analytic_hours_block/hours_block.py @@ -24,6 +24,7 @@ from openerp.osv import orm, fields class AccountHoursBlock(orm.Model): _name = "account.hours.block" + _inherit = ['mail.thread'] def _get_last_action(self, cr, uid, ids, name, arg, context=None): """ Return the last analytic line date for an invoice""" @@ -163,6 +164,47 @@ class AccountHoursBlock(orm.Model): block_ids.update([inv.id for inv in invoice.account_hours_block_ids]) return list(block_ids) + def action_send_block(self, cr, uid, ids, context=None): + """Open a form to send by email. Return an action dict.""" + + assert len(ids) == 1, '''\ + This option should only be used for a single ID at a time.''' + + ir_model_data = self.pool.get('ir.model.data') + + try: + template_id = ir_model_data.get_object_reference( + cr, uid, 'analytic_hours_block', 'email_template_hours_block' + )[1] + except ValueError: + template_id = False + + try: + compose_form_id = ir_model_data.get_object_reference( + cr, uid, 'mail', 'email_compose_message_wizard_form' + )[1] + except ValueError: + compose_form_id = False + + ctx = context.copy() + ctx.update({ + 'default_model': self._name, + 'default_res_id': ids[0], + 'default_use_template': bool(template_id), + 'default_template_id': template_id, + 'default_composition_mode': 'comment', + }) + return { + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(compose_form_id, 'form')], + 'view_id': compose_form_id, + 'target': 'new', + 'context': ctx, + } + _recompute_triggers = { 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, ['invoice_id', 'type'], 10), diff --git a/analytic_hours_block/hours_block_data.xml b/analytic_hours_block/hours_block_data.xml new file mode 100644 index 00000000..dc5f9eaa --- /dev/null +++ b/analytic_hours_block/hours_block_data.xml @@ -0,0 +1,24 @@ + + + + + + Hours Block - Send by Email + ${(object.user_id.email or object.company_id.email or 'noreply@localhost')|safe} + ${object.company_id.name} Hours Block (Ref ${object.number or 'n/a'}) + ${object.partner_id.id} + + + + Hours_Block_${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''} + ${object.partner_id.lang} + Hello ${object.partner_id.name},

+ +

Please find attached your Hours Block Report.

+

Best regards.

+ ]]>
+
+
+
diff --git a/analytic_hours_block/hours_block_view.xml b/analytic_hours_block/hours_block_view.xml index a81bc136..3c6da3a5 100644 --- a/analytic_hours_block/hours_block_view.xml +++ b/analytic_hours_block/hours_block_view.xml @@ -41,44 +41,51 @@ account.hours.block
- -

- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
From 94ab7ada3e74172415489b8b314166839bc7b1f1 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Wed, 8 Jan 2014 13:51:39 +0100 Subject: [PATCH 2/3] [add] analytic_hours_block: pot file --- .../i18n/analytic_hours_block.pot | 460 ++++++++++++++++++ 1 file changed, 460 insertions(+) create mode 100644 analytic_hours_block/i18n/analytic_hours_block.pot diff --git a/analytic_hours_block/i18n/analytic_hours_block.pot b/analytic_hours_block/i18n/analytic_hours_block.pot new file mode 100644 index 00000000..c90e8166 --- /dev/null +++ b/analytic_hours_block/i18n/analytic_hours_block.pot @@ -0,0 +1,460 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * analytic_hours_block +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-01-08 12:49+0000\n" +"PO-Revision-Date: 2014-01-08 12:49+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Maintenance And Support Summary" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Invoice Date:" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Group By..." +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Bought" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,close_date:0 +msgid "Closed Date" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,message_unread:0 +msgid "Unread Messages" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,company_id:0 +msgid "Company" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,date_invoice:0 +msgid "Invoice Date" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,residual:0 +msgid "Residual" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,amount_hours_block:0 +msgid "Amount bought by the customer. This amount is expressed in the base Unit of Measure (factor=1.0)" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Based on:" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,message_ids:0 +msgid "Messages" +msgstr "" + +#. module: analytic_hours_block +#: selection:account.hours.block,type:0 +msgid "Amount" +msgstr "" + +#. module: analytic_hours_block +#: selection:account.hours.block,state:0 +msgid "Cancelled" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,message_unread:0 +msgid "If checked new messages require your attention." +msgstr "" + +#. module: analytic_hours_block +#: model:email.template,body_html:analytic_hours_block.email_template_hours_block +msgid "\n" +" Here is your Hours Block Report\n" +" " +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Hours Quantity / Amount" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Remaining hours:" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Quantity of hours bought:" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,message_summary:0 +msgid "Holds the Chatter summary (number of messages, ...). This summary is directly in html format in order to be inserted in kanban views." +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Quantity of hours bought" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +#: field:account.hours.block,partner_id:0 +msgid "Partner" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Quantity of hours difference" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,period_id:0 +msgid "Period" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,state:0 +msgid "State" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,message_follower_ids:0 +msgid "Followers" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Send by Email" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "All Running Hours Block" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,last_action_date:0 +msgid "Last action date" +msgstr "" + +#. module: analytic_hours_block +#: selection:account.hours.block,type:0 +msgid "Hours" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Description:" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,type:0 +msgid "The block is based on the quantity of hours or on the amount." +msgstr "" + +#. module: analytic_hours_block +#: model:email.template,report_name:analytic_hours_block.email_template_hours_block +msgid "Hours_Block_${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Remaining amount:" +msgstr "" + +#. module: analytic_hours_block +#: model:ir.model,name:analytic_hours_block.model_account_hours_block +msgid "account.hours.block" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,amount_hours_block:0 +msgid "Quantity / Amount bought" +msgstr "" + +#. module: analytic_hours_block +#: model:ir.actions.report.xml,name:analytic_hours_block.block_hours_report +msgid "Block Hours State" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Choose an invoice..." +msgstr "" + +#. module: analytic_hours_block +#: selection:account.hours.block,state:0 +msgid "Open" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "My invoices" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Draft Hours Blocks" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,currency_id:0 +msgid "Currency" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +#: field:account.hours.block,user_id:0 +msgid "Salesman" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Quantity of hours used" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +#: selection:account.hours.block,state:0 +msgid "Draft" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +#: model:ir.actions.act_window,name:analytic_hours_block.action_all_block_hour +msgid "Hours Blocks" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,type:0 +msgid "Type of Block" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Used" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Total Amount" +msgstr "" + +#. module: analytic_hours_block +#: selection:account.hours.block,state:0 +msgid "Paid" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Page" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,message_is_follower:0 +msgid "Is a Follower" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Date" +msgstr "" + +#. module: analytic_hours_block +#: field:account.invoice,account_hours_block_ids:0 +#: model:ir.actions.act_window,name:analytic_hours_block.act_hours_block_from_invoice +#: model:ir.ui.menu,name:analytic_hours_block.action_all_block_hour_account +msgid "Hours Block" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,last_action_date:0 +msgid "Date of the last analytic line linked to the invoice related to this block hours." +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Report Date:" +msgstr "" + +#. module: analytic_hours_block +#: model:email.template,subject:analytic_hours_block.email_template_hours_block +msgid "${object.company_id.name} Hours Block (Ref ${object.number or 'n/a'})" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Invoice's related information" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Search Invoice" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Quantity" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,amount_hours_block_delta:0 +msgid "Difference between bought and used. This amount is expressed in the base Unit of Measure (factor=1.0)" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "0.6cm 27.9cm 20.3cm 27.9cm" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Residual Amount" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Overdue Hours Block" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Amount used:" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,number:0 +msgid "Number" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +#: field:account.hours.block,invoice_id:0 +#: model:ir.actions.act_window,name:analytic_hours_block.act_invoice_from_hours_block +#: model:ir.model,name:analytic_hours_block.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: analytic_hours_block +#: selection:account.hours.block,state:0 +msgid "Pro-forma" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Responsible" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +#: field:account.hours.block,name:0 +msgid "Description" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Amount bought:" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,amount_hours_block_done:0 +msgid "Amount done by the staff. This amount is expressed in the base Unit of Measure (factor=1.0)" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Quantity of hours used:" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Invoicing" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,amount_hours_block_done:0 +msgid "Quantity / Amount used" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,journal_id:0 +msgid "Journal" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Running" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +#: field:account.hours.block,amount_hours_block_delta:0 +msgid "Difference" +msgstr "" + +#. module: analytic_hours_block +#: model:ir.actions.act_window,name:analytic_hours_block.act_block_hour_from_partner +msgid "All blocks hours" +msgstr "" + +#. module: analytic_hours_block +#: report:account.hours.block:0 +msgid "Deduced" +msgstr "" + +#. module: analytic_hours_block +#: model:ir.actions.act_window,name:analytic_hours_block.act_analytic_lines_from_hours_block +msgid "Analytic Lines" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Invoice State" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,message_summary:0 +msgid "Summary" +msgstr "" + +#. module: analytic_hours_block +#: help:account.hours.block,message_ids:0 +msgid "Messages and communication history" +msgstr "" + +#. module: analytic_hours_block +#: view:account.hours.block:0 +msgid "Overdue" +msgstr "" + +#. module: analytic_hours_block +#: field:account.hours.block,amount_total:0 +msgid "Total" +msgstr "" + From dfead5d132c75536472d82c82963d5c127f2b479 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 31 Jan 2014 15:45:54 +0100 Subject: [PATCH 3/3] [imp] create a new context, as suggested by Guewen --- analytic_hours_block/hours_block.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/analytic_hours_block/hours_block.py b/analytic_hours_block/hours_block.py index 064edca5..85415a25 100644 --- a/analytic_hours_block/hours_block.py +++ b/analytic_hours_block/hours_block.py @@ -186,14 +186,13 @@ class AccountHoursBlock(orm.Model): except ValueError: compose_form_id = False - ctx = context.copy() - ctx.update({ + ctx = { 'default_model': self._name, 'default_res_id': ids[0], 'default_use_template': bool(template_id), 'default_template_id': template_id, 'default_composition_mode': 'comment', - }) + } return { 'type': 'ir.actions.act_window', 'view_type': 'form',