diff --git a/account_partner_aged_statement_webkit/__init__.py b/account_partner_aged_statement_webkit/__init__.py new file mode 100644 index 00000000..3057d1dc --- /dev/null +++ b/account_partner_aged_statement_webkit/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- + +############################################################################ +# +# 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 . +# +############################################################################## + +from . import ( + partner_aged_statement, + report, +) diff --git a/account_partner_aged_statement_webkit/__init__.pyc b/account_partner_aged_statement_webkit/__init__.pyc new file mode 100644 index 00000000..09ec56c4 Binary files /dev/null and b/account_partner_aged_statement_webkit/__init__.pyc differ diff --git a/account_partner_aged_statement_webkit/__openerp__.py b/account_partner_aged_statement_webkit/__openerp__.py new file mode 100644 index 00000000..59b0370b --- /dev/null +++ b/account_partner_aged_statement_webkit/__openerp__.py @@ -0,0 +1,59 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Savoir-faire Linux +# (). +# +# 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 . +# +############################################################################### + +{ + 'name': 'Partner Aged Statement', + "version": "1.0", + 'author': 'Savoir-faire Linux', + 'website': 'http://www.savoirfairelinux.com', + 'depends': [ + 'account_financial_report_webkit_xls', + 'report_webkit', + 'base_headers_webkit', + 'mail', + ], + 'category': 'Accounting', + 'description': """ +Print & Send Partner Aged Statement by email +============================================ + +This module adds in the system : + * a new mail template "Aged Statement Letter"; + * the abitlity to print the partner aged statement; + * a button "Send by email" in the pricelist form view which load the template + and attache the pricelist to the email. + +So far the module does not drill down through pricelist items that are +based on another pricelist or based on purchase pricelists. + +Contributors +------------ +* Marc Cassuto (marc.cassuto@savoirfairelinux.com) + """, + 'data': [ + 'partner_aged_statement_report.xml', + 'partner_aged_statement_view.xml', + 'partner_aged_statement_data.xml', + ], + 'active': False, + 'installable': True +} diff --git a/account_partner_aged_statement_webkit/partner_aged_statement.py b/account_partner_aged_statement_webkit/partner_aged_statement.py new file mode 100644 index 00000000..80ef5991 --- /dev/null +++ b/account_partner_aged_statement_webkit/partner_aged_statement.py @@ -0,0 +1,71 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (). +# +# 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 . +# +############################################################################### + +import time +from openerp.osv import orm + + +class PartnerAgedStatement(orm.Model): + _inherit = 'res.partner' + + def action_aged_statement_send(self, cr, uid, ids, context=None): + # This function opens a window to compose an email, + # with the partner aged statemen template message loaded by default + + # This option should only be used for a single id at a time. + assert len(ids) == 1 + + ir_model_data = self.pool.get('ir.model.data') + try: + template_id = ir_model_data.get_object_reference( + cr, uid, + 'account_partner_aged_statement_webkit', + 'email_template_aged_statement')[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 = dict(context) + ctx.update({ + 'default_model': 'res.partner', + 'default_res_id': ids[0], + 'default_use_template': bool(template_id), + 'default_template_id': template_id, + 'default_composition_mode': 'comment', + }) + # Full explanation of this return is here : + # http://stackoverflow.com/questions/12634031 + 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, + } diff --git a/account_partner_aged_statement_webkit/partner_aged_statement.pyc b/account_partner_aged_statement_webkit/partner_aged_statement.pyc new file mode 100644 index 00000000..7e81929e Binary files /dev/null and b/account_partner_aged_statement_webkit/partner_aged_statement.pyc differ diff --git a/account_partner_aged_statement_webkit/partner_aged_statement_data.xml b/account_partner_aged_statement_webkit/partner_aged_statement_data.xml new file mode 100644 index 00000000..75673424 --- /dev/null +++ b/account_partner_aged_statement_webkit/partner_aged_statement_data.xml @@ -0,0 +1,80 @@ + + + + + + + + Aged Statement Letter + ${(user.email or '')|safe} + ${object.company_id.name} - Your aged balance + ${object.id or ''|safe} + + + + + ${(object.name or '').replace('/','_')} + + + +

Dear Sir/Madam,

+ +

Our records indicate that some payments on your account are still due. +
+ Please find in the attached document your aged balance +
+ If the amount has already been paid, please disregard this notice. + Otherwise, please forward us the total amount stated below. +

+ +

+   REFERENCES
+   Total overdue amount: ${object.credit} ${user.company_id.currency_id.name}
+

+ +

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

+

Best Regards,

+
+
+
+

+ ${user.company_id.name}

+
+
+ + % if user.company_id.street: + ${user.company_id.street}
+ % endif + % if user.company_id.street2: + ${user.company_id.street2}
+ % endif + % if user.company_id.city or user.company_id.zip: + ${user.company_id.zip} ${user.company_id.city}
+ % endif + % if user.company_id.country_id: + ${user.company_id.state_id and ('%s, ' % user.company_id.state_id.name) or ''} ${user.company_id.country_id.name or ''}
+ % endif +
+ % if user.company_id.phone: +
+ Phone:  ${user.company_id.phone} +
+ % endif + % if user.company_id.website: + + %endif +

+
+ + ]]>
+
+
+
diff --git a/account_partner_aged_statement_webkit/partner_aged_statement_report.xml b/account_partner_aged_statement_webkit/partner_aged_statement_report.xml new file mode 100644 index 00000000..9e7762c0 --- /dev/null +++ b/account_partner_aged_statement_webkit/partner_aged_statement_report.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/account_partner_aged_statement_webkit/partner_aged_statement_view.xml b/account_partner_aged_statement_webkit/partner_aged_statement_view.xml new file mode 100644 index 00000000..4f2a7cd4 --- /dev/null +++ b/account_partner_aged_statement_webkit/partner_aged_statement_view.xml @@ -0,0 +1,21 @@ + + + + + + + res.partner + + +
+
+
+
+
+ +
+
diff --git a/account_partner_aged_statement_webkit/report/__init__.py b/account_partner_aged_statement_webkit/report/__init__.py new file mode 100644 index 00000000..9fe8d055 --- /dev/null +++ b/account_partner_aged_statement_webkit/report/__init__.py @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- + +############################################################################### +# +# 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 . +# +############################################################################### + +from . import partner_aged_statement_report diff --git a/account_partner_aged_statement_webkit/report/__init__.pyc b/account_partner_aged_statement_webkit/report/__init__.pyc new file mode 100644 index 00000000..4226b5bb Binary files /dev/null and b/account_partner_aged_statement_webkit/report/__init__.pyc differ diff --git a/account_partner_aged_statement_webkit/report/partner_aged_statement.mako b/account_partner_aged_statement_webkit/report/partner_aged_statement.mako new file mode 100644 index 00000000..7bc1cc1a --- /dev/null +++ b/account_partner_aged_statement_webkit/report/partner_aged_statement.mako @@ -0,0 +1,164 @@ +## -*- coding: utf-8 -*- + + + + + + + <%! + def amount(text): + # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers) + return text.replace('-', '‑') + %> + + <%setLang(user.lang)%> + +
+
+
${_('Chart of Account')}
+
${_('Fiscal Year')}
+ <%doc> +
+ %if filter_form(data) == 'filter_date': + ${_('Dates Filter')} + %else: + ${_('Periods Filter')} + %endif +
+ + +
${_('Clearance Date')}
+
${_('Accounts Filter')}
+
${_('Target Moves')}
+ +
+ + <%doc> +
+
${ chart_account.name }
+
${ fiscalyear.name if fiscalyear else '-' }
+
+ ${_('From:')} + %if filter_form(data) == 'filter_date': + ${formatLang(start_date, date=True) if start_date else u'' } + %else: + ${start_period.name if start_period else u''} + %endif + ${_('To:')} + %if filter_form(data) == 'filter_date': + ${ formatLang(stop_date, date=True) if stop_date else u'' } + %else: + ${stop_period.name if stop_period else u'' } + %endif +
+
${ formatLang(date_until, date=True) }
+
+ %if partner_ids: + ${_('Custom Filter')} + %else: + ${ display_partner_account(data) } + %endif +
+
${ display_target_move(data) }
+
+
+ %for acc in objects: + %if acc.aged_lines: + + + + +
+
+
+ ## partner +
${_('Partner')}
+ ## code +
${_('code')}
+ ## balance +
${_('balance')}
+ ## Classifications + %for title in ranges_titles: +
${title}
+ %endfor +
+
+
+ %for partner_name, p_id, p_ref, p_name in acc.partners_order: + %if acc.aged_lines.get(p_id): +
+ <%line = acc.aged_lines[p_id]%> + <%percents = acc.aged_percents%> + <%totals = acc.aged_totals%> +
${partner_name}
+
${p_ref or ''}
+ +
${formatLang(line.get('balance') or 0.0) | amount}
+ %for classif in ranges: +
+ ${formatLang(line['aged_lines'][classif] or 0.0) | amount} +
+ %endfor +
+ %endif + %endfor +
+
${_('Total')}
+
+
${formatLang(totals['balance']) | amount}
+ %for classif in ranges: +
${formatLang(totals[classif]) | amount}
+ %endfor +
+ +
+
${_('Percents')}
+
+
+ %for classif in ranges: +
${formatLang(percents[classif]) | amount}%
+ %endfor +
+
+
+ + %endif + %endfor + + + +
+ + diff --git a/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py new file mode 100644 index 00000000..f954697c --- /dev/null +++ b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- + +# ############################################################################## +# +# 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 . +# +############################################################################### + + +import time +import operator +import itertools + +from openerp import pooler +from openerp.osv import orm +from openerp.report import report_sxw +from openerp.tools.translate import _ + +from openerp.addons.account_financial_report_webkit.report.aged_partner_balance import ( # noqa + AccountAgedTrialBalanceWebkit +) + + +class PartnerAgedStatementReport(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(PartnerAgedStatementReport, self).__init__(cr, uid, name, + context=context) + self.localcontext.update({ + 'time': time, + }) + + +report_sxw.report_sxw( + 'report.webkit.partner_aged_statement_report', + 'account.account', + ('addons/' + 'account_partner_aged_statement_webkit/' + 'report/' + 'partner_aged_statement.mako'), + parser=PartnerAgedStatementReport) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_partner_aged_statement_webkit/report/partner_aged_statement_report.pyc b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.pyc new file mode 100644 index 00000000..717ac7e5 Binary files /dev/null and b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.pyc differ