Browse Source

Add Supplier Aged Statement report

pull/9/head
dufresnedavid 10 years ago
committed by Maxime Chambreuil
parent
commit
378bacea00
  1. 5
      account_partner_aged_statement_webkit/i18n/account_partner_aged_statement_webkit.pot
  2. 11
      account_partner_aged_statement_webkit/partner_aged_statement_report.xml
  3. 5
      account_partner_aged_statement_webkit/report/__init__.py
  4. 2
      account_partner_aged_statement_webkit/report/partner_aged_statement.mako
  5. 1
      account_partner_aged_statement_webkit/report/partner_aged_statement_report.py
  6. 103
      account_partner_aged_statement_webkit/report/supplier_aged_statement_report.py

5
account_partner_aged_statement_webkit/i18n/account_partner_aged_statement_webkit.pot

@ -25,6 +25,11 @@ msgstr ""
msgid "Partner Aged Statement"
msgstr ""
#. module: account_partner_aged_statement_webkit
#: model:ir.actions.report.xml,name:account_partner_aged_statement_webkit.supplier_aged_statement_report
msgid "Supplier Aged Statement"
msgstr ""
#. module: account_partner_aged_statement_webkit
#: report:addons/account_partner_aged_statement_webkit/report/partner_aged_statement.mako:60
msgid "Not Due"

11
account_partner_aged_statement_webkit/partner_aged_statement_report.xml

@ -17,5 +17,16 @@
file="account/report/account_aged_partner_balance.rml"
report_type="pdf"-->
<report
auto="False"
id="supplier_aged_statement_report"
model="res.partner"
string="Supplier Aged Statement (fournisseur)"
name="webkit.supplier_aged_statement_report"
file="account_partner_aged_statement_webkit/report/partner_aged_statement.mako"
report_type="webkit"
webkit_header="base_headers_webkit.base_reports_portrait_header"
/>
</data>
</openerp>

5
account_partner_aged_statement_webkit/report/__init__.py

@ -20,4 +20,7 @@
#
###############################################################################
from . import partner_aged_statement_report
from . import (
partner_aged_statement_report,
supplier_aged_statement_report,
)

2
account_partner_aged_statement_webkit/report/partner_aged_statement.mako

@ -39,11 +39,13 @@
${_('Subject')}: <b>${_('Overdue Statement')}</b>
<br/>
<br/>
%if show_message:
%for message_line in message(partner, company):
<p>
${message_line}
</p>
%endfor
%endif
<br>
${user.name}
<br>

1
account_partner_aged_statement_webkit/report/partner_aged_statement_report.py

@ -47,6 +47,7 @@ class PartnerAgedTrialReport(aged_trial_report):
'getLines30': self._lines_get30,
'getLines3060': self._lines_get_30_60,
'getLines60': self._lines_get60,
'show_message': True,
})
def _lines_get30(self, obj):

103
account_partner_aged_statement_webkit/report/supplier_aged_statement_report.py

@ -0,0 +1,103 @@
# -*- encoding: utf-8 -*-
###############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2010 - 2014 Savoir-faire Linux
# (<http://www.savoirfairelinux.com>).
#
# 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 <http://www.gnu.org/licenses/>.
#
###############################################################################
from .partner_aged_statement_report import PartnerAgedTrialReport
from openerp.report import report_sxw
from dateutil.relativedelta import relativedelta
from openerp import pooler
from datetime import datetime
class SupplierAgedTrialReport(PartnerAgedTrialReport):
"""
This report is like partner_aged_statement_report but it returns only
the amounts payable to the supplier
"""
def __init__(self, cr, uid, name, context):
super(SupplierAgedTrialReport, self).__init__(cr, uid, name, context)
self.localcontext.update({
'getLines30': self._lines_get30,
'getLines3060': self._lines_get_30_60,
'getLines60': self._lines_get60,
'show_message': False,
})
def _lines_get30(self, obj):
today = datetime.now()
stop = today - relativedelta(days=30)
moveline_obj = pooler.get_pool(self.cr.dbname)['account.move.line']
movelines = moveline_obj.search(
self.cr, self.uid,
[('partner_id', '=', obj.id),
('account_id.type', 'in', ['payable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False),
'|',
'&', ('date_maturity', '<=', today), ('date_maturity', '>', stop),
'&', ('date_maturity', '=', False),
'&', ('date', '<=', today), ('date', '>', stop)],
context=self.localcontext)
movelines = moveline_obj.browse(self.cr, self.uid, movelines)
return movelines
def _lines_get_30_60(self, obj):
start = datetime.now() - relativedelta(days=30)
stop = start - relativedelta(days=30)
moveline_obj = pooler.get_pool(self.cr.dbname)['account.move.line']
movelines = moveline_obj.search(
self.cr, self.uid,
[('partner_id', '=', obj.id),
('account_id.type', 'in', ['payable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False),
'|',
'&', ('date_maturity', '<=', start), ('date_maturity', '>', stop),
'&', ('date_maturity', '=', False),
'&', ('date', '<=', start), ('date', '>', stop)],
context=self.localcontext)
movelines = moveline_obj.browse(self.cr, self.uid, movelines)
return movelines
def _lines_get60(self, obj):
start = datetime.now() - relativedelta(days=60)
moveline_obj = pooler.get_pool(self.cr.dbname)['account.move.line']
movelines = moveline_obj.search(
self.cr, self.uid,
[('partner_id', '=', obj.id),
('account_id.type', 'in', ['payable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False),
'|', ('date_maturity', '<=', start),
('date_maturity', '=', False), ('date', '<=', start)],
context=self.localcontext)
movelines = moveline_obj.browse(self.cr, self.uid, movelines)
return movelines
report_sxw.report_sxw(
'report.webkit.supplier_aged_statement_report',
'res.partner',
('addons/'
'account_partner_aged_statement_webkit/'
'report/'
'partner_aged_statement.mako'),
parser=SupplierAgedTrialReport,
)
Loading…
Cancel
Save