diff --git a/contract/README.rst b/contract/README.rst index 496aa415..e2aa831e 100644 --- a/contract/README.rst +++ b/contract/README.rst @@ -7,8 +7,9 @@ Contracts for recurrent invoicing ================================= This module forward-port to v10 the contracts management with recurring -invoicing functions. In upstream Odoo, this functionality was moved into the -Enterprise edition. +invoicing functions. Also you can print and send by email contract report. + +In upstream Odoo, this functionality was moved into the Enterprise edition. Configuration ============= @@ -40,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 @@ -68,6 +71,7 @@ Contributors * Carlos Dauden * Angel Moya * Dave Lasley +* Vicent Cubells Maintainer ---------- diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 1b22ea13..97383127 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '10.0.1.0.1', + 'version': '10.0.1.1.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " @@ -16,7 +16,10 @@ 'depends': ['base', 'account', 'analytic'], 'data': [ 'security/ir.model.access.csv', + 'report/report_contract.xml', + 'report/contract_views.xml', 'data/contract_cron.xml', + 'data/mail_template.xml', 'views/account_analytic_account_view.xml', 'views/account_analytic_contract_view.xml', 'views/account_invoice_view.xml', diff --git a/contract/data/mail_template.xml b/contract/data/mail_template.xml new file mode 100644 index 00000000..9d3728b0 --- /dev/null +++ b/contract/data/mail_template.xml @@ -0,0 +1,64 @@ + + + + + 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}
+ % if object.date_start: +   Contract Date Start: ${object.date_start or ''}
+ % endif + + % if object.user_id: + % if object.user_id.email: +   Your Contact: ${object.user_id.name} + % else: +   Your Contact: ${object.user_id.name} + % endif + % endif +

+ +
+

If you have any questions, 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 23b7bfa5..cb842218 100644 --- a/contract/i18n/es.po +++ b/contract/i18n/es.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * contract -# +# # Translators: # OCA Transbot , 2016 msgid "" @@ -18,6 +18,103 @@ msgstr "" "Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\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" +" % if object.date_start:\n" +"   Contract Date Start: ${object.date_start or ''}
\n" +" % endif\n" +"\n" +" % if object.user_id:\n" +" % if object.user_id.email:\n" +"   Your Contact: ${object.user_id.name}\n" +" % else:\n" +"   Your Contact: ${object.user_id.name}\n" +" % endif\n" +" % endif\n" +"

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

If you have any questions, 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" +" % if object.user_id.email:\n" +"   Contacto: ${object.user_id.name}\n" +" % else:\n" +"   Contacto: ${object.user_id.name}\n" +" % endif\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 #: model:ir.ui.view,arch_db:contract.account_analytic_contract_view_form @@ -30,6 +127,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 "Recurring Items" +msgstr "Elementos recurrentes" + +#. 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 #: model:ir.ui.view,arch_db:contract.account_analytic_contract_view_form @@ -57,6 +189,12 @@ msgstr "Pinche para crear un contrato nuevo. " msgid "Contract" msgstr "Contrato" +#. module: contract +#: code:addons/contract/models/account_analytic_account.py:217 +#, python-format +msgid "Compose Email" +msgstr "Componer correo electrónico" + #. module: contract #: model:ir.model.fields,field_description:contract.field_account_analytic_account_contract_template_id #: model:ir.ui.view,arch_db:contract.account_analytic_contract_view_form @@ -95,6 +233,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" @@ -300,6 +443,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 #: model:ir.model.fields,help:contract.field_account_analytic_contract_recurring_rule_type @@ -328,6 +486,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 "NIF:" + #. module: contract #: selection:account.analytic.account,recurring_rule_type:0 #: selection:account.analytic.contract,recurring_rule_type:0 diff --git a/contract/models/account_analytic_account.py b/contract/models/account_analytic_account.py index 986effc8..27340cac 100644 --- a/contract/models/account_analytic_account.py +++ b/contract/models/account_analytic_account.py @@ -32,6 +32,12 @@ class AccountAnalyticAccount(models.Model): copy=False, string='Date of Next Invoice', ) + user_id = fields.Many2one( + comodel_name='res.users', + string='Responsible', + index=True, + default=lambda self: self.env.user, + ) @api.onchange('contract_template_id') def _onchange_contract_template_id(self): @@ -190,3 +196,30 @@ class AccountAnalyticAccount(models.Model): [('recurring_next_date', '<=', fields.date.today()), ('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') + 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..bcbb1459 --- /dev/null +++ b/contract/report/contract_views.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/contract/report/report_contract.xml b/contract/report/report_contract.xml new file mode 100644 index 00000000..16aed6c3 --- /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 8cef9512..a1acb758 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -155,3 +155,7 @@ class TestContract(TransactionCase): } del self.template_vals['name'] self.assertDictEqual(res, self.template_vals) + + def test_send_mail_contract(self): + result = self.contract.action_contract_send() + self.assertEqual(result['res_model'], 'mail.compose.message') diff --git a/contract/views/account_analytic_account_view.xml b/contract/views/account_analytic_account_view.xml index 0036388e..de2fbe86 100644 --- a/contract/views/account_analytic_account_view.xml +++ b/contract/views/account_analytic_account_view.xml @@ -7,6 +7,11 @@ primary + +
+
+