diff --git a/contract/README.rst b/contract/README.rst index 05713102..03ba9f71 100644 --- a/contract/README.rst +++ b/contract/README.rst @@ -9,6 +9,8 @@ Contracts for recurrent invoicing This module forward-port to v9 the contracts management with recurring invoicing functions. +Also you can print and send by email contract report. + Configuration ============= @@ -39,6 +41,8 @@ To use this module, you need to: click on *Create invoices* to force this action. #. Click *Show recurring invoices* link to show all invoices created by the contract. +#. Click on *Print > Contract* menu to print contract report. +#. Click on *Send by Email* button to send contract by email. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot @@ -66,6 +70,7 @@ Contributors * Pedro M. Baeza * Carlos Dauden * Angel Moya +* Vicent Cubells Maintainer ---------- diff --git a/contract/__openerp__.py b/contract/__openerp__.py index c64a0d98..118ac69b 100644 --- a/contract/__openerp__.py +++ b/contract/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'Contracts Management recurring', - 'version': '9.0.1.1.0', + 'version': '9.0.1.2.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA," @@ -15,7 +15,10 @@ 'depends': ['base', 'account', 'analytic'], 'data': [ 'security/ir.model.access.csv', + 'report/report_contract.xml', + 'report/contract_views.xml', 'data/contract_cron.xml', + 'data/contract_template.xml', 'views/contract.xml', 'views/account_invoice_view.xml', ], diff --git a/contract/data/contract_template.xml b/contract/data/contract_template.xml new file mode 100644 index 00000000..f75bc326 --- /dev/null +++ b/contract/data/contract_template.xml @@ -0,0 +1,58 @@ + + + + + Email Contract Template + ${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe} + ${object.company_id.name} Contract (Ref ${object.name or 'n/a'}) + ${object.partner_id.id} + + + + Contract + ${object.partner_id.lang} + +

Hello ${object.partner_id.name or ''},

+

A new contract has been created:

+ +

+   REFERENCES
+   Contract: ${object.name}
+   Contract date start: ${object.date_start or ''}
+ + % if object.user_id: +   Your contact: ${object.user_id.name} + % endif +

+ +
+

If you have any question, do not hesitate to contact us.

+

Thank you for choosing ${object.company_id.name or 'us'}!

+
+
+
+

+ ${object.company_id.name}

+
+
+ + ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe} + + % if object.company_id.phone: +
+ Phone:  ${object.company_id.phone} +
+ % endif + % if object.company_id.website: + + %endif +

+
+ + ]]>
+
+ +
diff --git a/contract/i18n/es.po b/contract/i18n/es.po index f1bf998b..eca44257 100644 --- a/contract/i18n/es.po +++ b/contract/i18n/es.po @@ -1,22 +1,106 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * contract -# -# Translators: -# Pedro M. Baeza , 2017 +# * contract +# msgid "" msgstr "" -"Project-Id-Version: contract (9.0)\n" +"Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-01 02:46+0000\n" -"PO-Revision-Date: 2017-04-28 09:21+0000\n" -"Last-Translator: Pedro M. Baeza \n" -"Language-Team: Spanish (http://www.transifex.com/oca/OCA-contract-9-0/language/es/)\n" +"POT-Creation-Date: 2017-08-02 17:47+0000\n" +"PO-Revision-Date: 2017-08-02 17:47+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" -"Language: es\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: \n" + +#. module: contract +#: model:mail.template,body_html:contract.email_contract_template +msgid "\n" +"
\n" +"

Hello ${object.partner_id.name or ''},

\n" +"

A new contract has been created:

\n" +"\n" +"

\n" +"   REFERENCES
\n" +"   Contract: ${object.name}
\n" +"   Contract date start: ${object.date_start or ''}
\n" +"\n" +" % if object.user_id:\n" +"   Your contact: ${object.user_id.name}\n" +" % endif\n" +"

\n" +"\n" +"
\n" +"

If you have any question, do not hesitate to contact us.

\n" +"

Thank you for choosing ${object.company_id.name or 'us'}!

\n" +"
\n" +"
\n" +"
\n" +"

\n" +" ${object.company_id.name}

\n" +"
\n" +"
\n" +" \n" +" ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe}\n" +" \n" +" % if object.company_id.phone:\n" +"
\n" +" Phone:  ${object.company_id.phone}\n" +"
\n" +" % endif\n" +" % if object.company_id.website:\n" +"
\n" +" Web : ${object.company_id.website}\n" +"
\n" +" %endif\n" +"

\n" +"
\n" +"
\n" +" " +msgstr "\n" +"
\n" +"

Hola ${object.partner_id.name or ''},

\n" +"

Se ha creado un nuevo contrato:

\n" +"\n" +"

\n" +"   REFERENCIAS
\n" +"   Contrato: ${object.name}
\n" +"   Fecha de inicio del contrato: ${object.date_start or ''}
\n" +"\n" +" % if object.user_id:\n" +"   Contacto: ${object.user_id.name}\n" +" % endif\n" +"

\n" +"\n" +"
\n" +"

Si tiene cualquier pregunta, no dude en contactarnos.

\n" +"

Gracias por elegir ${object.company_id.name or 'nos'}!

\n" +"
\n" +"
\n" +"
\n" +"

\n" +" ${object.company_id.name}

\n" +"
\n" +"
\n" +" \n" +" ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe}\n" +" \n" +" % if object.company_id.phone:\n" +"
\n" +" Teléfono :  ${object.company_id.phone}\n" +"
\n" +" % endif\n" +" % if object.company_id.website:\n" +"
\n" +" Web : ${object.company_id.website}\n" +"
\n" +" %endif\n" +"

\n" +"
\n" +"
\n" +" " #. module: contract #: model:ir.ui.view,arch_db:contract.account_analytic_account_recurring_form_form @@ -28,6 +112,41 @@ msgstr "#END#: Fecha fin del periodo facturado" msgid "#START#: Start date of the invoiced period" msgstr "#START#: Fecha inicio del periodo facturado" +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Description" +msgstr "Descripción" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Invoice Lines" +msgstr "Lineas de factura" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Partner:" +msgstr "Empresa:" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Price" +msgstr "Precio" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Quantity" +msgstr "Cantidad" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Total" +msgstr "Total" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Unit Price" +msgstr "Precio unidad" + #. module: contract #: model:ir.ui.view,arch_db:contract.account_analytic_account_recurring_form_form msgid "Account Analytic Lines" @@ -49,6 +168,12 @@ msgstr "Pinche para crear un contrato nuevo. " msgid "Contract" msgstr "Contrato" +#. module: contract +#: code:addons/contract/models/contract.py:318 +#, python-format +msgid "Compose Email" +msgstr "Componer correo electrónico" + #. module: contract #: model:ir.actions.act_window,name:contract.action_account_analytic_overdue_all #: model:ir.ui.menu,name:contract.menu_action_account_analytic_overdue_all @@ -71,6 +196,11 @@ msgstr "Creado por" msgid "Created on" msgstr "Creado en" +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Date Start:" +msgstr "Fecha de inicio:" + #. module: contract #: model:ir.model.fields,field_description:contract.field_account_analytic_account_recurring_next_date msgid "Date of Next Invoice" @@ -241,6 +371,21 @@ msgstr "Repetir cada" msgid "Repeat every (Days/Week/Month/Year)" msgstr "Repetir cada (días/semana/mes/año)" +#. module: contract +#: model:ir.model.fields,field_description:contract.field_account_analytic_account_user_id +msgid "Responsible" +msgstr "Responsable" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "Responsible:" +msgstr "Responsable:" + +#. module: contract +#: model:ir.ui.view,arch_db:contract.account_analytic_account_recurring_form_form +msgid "Send by Email" +msgstr "Enviar por correo electrónico" + #. module: contract #: model:ir.model.fields,help:contract.field_account_analytic_account_recurring_rule_type msgid "Specify Interval for automatic invoice generation." @@ -266,6 +411,11 @@ msgstr "Precio unidad" msgid "Unit of Measure" msgstr "Unidad de medida" +#. module: contract +#: model:ir.ui.view,arch_db:contract.report_contract_document +msgid "VAT:" +msgstr "CIF/NIF:" + #. module: contract #: selection:account.analytic.account,recurring_rule_type:0 msgid "Week(s)" diff --git a/contract/i18n/es_ES.po b/contract/i18n/es_ES.po index dfc5986b..2a24c32f 100644 --- a/contract/i18n/es_ES.po +++ b/contract/i18n/es_ES.po @@ -1,21 +1,106 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * contract -# -# Translators: +# * contract +# msgid "" msgstr "" -"Project-Id-Version: contract (9.0)\n" +"Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-01 02:46+0000\n" -"PO-Revision-Date: 2017-04-25 10:42+0000\n" -"Last-Translator: OCA Transbot \n" -"Language-Team: Spanish (Spain) (http://www.transifex.com/oca/OCA-contract-9-0/language/es_ES/)\n" +"POT-Creation-Date: 2017-08-02 17:47+0000\n" +"PO-Revision-Date: 2017-08-02 17:47+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" -"Language: es_ES\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: \n" + +#. module: contract +#: model:mail.template,body_html:contract.email_contract_template +msgid "\n" +"
\n" +"

Hello ${object.partner_id.name or ''},

\n" +"

A new contract has been created:

\n" +"\n" +"

\n" +"   REFERENCES
\n" +"   Contract: ${object.name}
\n" +"   Contract date start: ${object.date_start or ''}
\n" +"\n" +" % if object.user_id:\n" +"   Your contact: ${object.user_id.name}\n" +" % endif\n" +"

\n" +"\n" +"
\n" +"

If you have any question, do not hesitate to contact us.

\n" +"

Thank you for choosing ${object.company_id.name or 'us'}!

\n" +"
\n" +"
\n" +"
\n" +"

\n" +" ${object.company_id.name}

\n" +"
\n" +"
\n" +" \n" +" ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe}\n" +" \n" +" % if object.company_id.phone:\n" +"
\n" +" Phone:  ${object.company_id.phone}\n" +"
\n" +" % endif\n" +" % if object.company_id.website:\n" +"
\n" +" Web : ${object.company_id.website}\n" +"
\n" +" %endif\n" +"

\n" +"
\n" +"
\n" +" " +msgstr "\n" +"
\n" +"

Hola ${object.partner_id.name or ''},

\n" +"

Se ha creado un nuevo contrato:

\n" +"\n" +"

\n" +"   REFERENCIAS
\n" +"   Contrato: ${object.name}
\n" +"   Fecha de inicio del contrato: ${object.date_start or ''}
\n" +"\n" +" % if object.user_id:\n" +"   Contacto: ${object.user_id.name}\n" +" % endif\n" +"

\n" +"\n" +"
\n" +"

Si tiene cualquier pregunta, no dude en contactarnos.

\n" +"

Gracias por elegir ${object.company_id.name or 'nos'}!

\n" +"
\n" +"
\n" +"
\n" +"

\n" +" ${object.company_id.name}

\n" +"
\n" +"
\n" +" \n" +" ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe}\n" +" \n" +" % if object.company_id.phone:\n" +"
\n" +" Teléfono :  ${object.company_id.phone}\n" +"
\n" +" % endif\n" +" % if object.company_id.website:\n" +"
\n" +" Web : ${object.company_id.website}\n" +"
\n" +" %endif\n" +"

\n" +"
\n" +"
\n" +" " #. module: contract #: model:ir.ui.view,arch_db:contract.account_analytic_account_recurring_form_form diff --git a/contract/models/contract.py b/contract/models/contract.py index 9ef2e51d..f7bc7155 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -144,6 +144,12 @@ class AccountAnalyticAccount(models.Model): string='Journal', default=_default_journal, domain="[('type', '=', 'sale'),('company_id', '=', company_id)]") + user_id = fields.Many2one( + comodel_name='res.users', + string='Responsible', + index=True, + default=lambda self: self.env.user, + ) @api.onchange('partner_id') def _onchange_partner_id(self): @@ -291,3 +297,31 @@ class AccountAnalyticAccount(models.Model): ('account_type', '=', 'normal'), ('recurring_invoices', '=', True)]) return contracts.recurring_create_invoice() + + @api.multi + def action_contract_send(self): + self.ensure_one() + template = self.env.ref( + 'contract.email_contract_template', + False, + ) + compose_form = self.env.ref('mail.email_compose_message_wizard_form', + False) + ctx = dict( + default_model='account.analytic.account', + default_res_id=self.id, + default_use_template=bool(template), + default_template_id=template and template.id or False, + default_composition_mode='comment', + ) + return { + 'name': _('Compose Email'), + '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, + } diff --git a/contract/report/contract_views.xml b/contract/report/contract_views.xml new file mode 100644 index 00000000..bac76c57 --- /dev/null +++ b/contract/report/contract_views.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/contract/report/report_contract.xml b/contract/report/report_contract.xml new file mode 100644 index 00000000..8d37124c --- /dev/null +++ b/contract/report/report_contract.xml @@ -0,0 +1,74 @@ + + + + + + diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py index c0147a32..f2710433 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -134,3 +134,7 @@ class TestContract(SavepointCase): journal.write({'type': 'general'}) with self.assertRaises(ValidationError): contract_no_journal.recurring_create_invoice() + + def test_send_mail_contract(self): + result = self.contract.action_contract_send() + self.assertEqual(result['name'], 'Compose Email') diff --git a/contract/views/contract.xml b/contract/views/contract.xml index 5380a07a..50189f70 100644 --- a/contract/views/contract.xml +++ b/contract/views/contract.xml @@ -19,6 +19,11 @@ + +
+
+