Browse Source

Fix supplier and partner reports so that supplier report has only payable amounts and partner has only receivable amounts. Both reports have now all amounts in the correct column with the correct sign

pull/9/head
dufresnedavid 10 years ago
committed by Maxime Chambreuil
parent
commit
ebcf344c2f
  1. 2
      account_partner_aged_statement_webkit/i18n/fr.po
  2. 32
      account_partner_aged_statement_webkit/report/partner_aged_statement.mako
  3. 53
      account_partner_aged_statement_webkit/report/partner_aged_statement_report.py
  4. 11
      account_partner_aged_statement_webkit/report/supplier_aged_statement_report.py

2
account_partner_aged_statement_webkit/i18n/fr.po

@ -229,4 +229,4 @@ msgstr "Courriel:"
#. 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 "Relevé de balance âgée"
msgstr "Relevé de balance âgée FRS"

32
account_partner_aged_statement_webkit/report/partner_aged_statement.mako

@ -68,13 +68,13 @@
<th>${_('Total')}</th>
</tr>
<tr>
<td>${ formatLang(l['direction'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(l['4'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(l['3'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(l['2'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(l['1'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(l['0'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(l['total'], currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['direction']), currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['4']), currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['3']), currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['2']), currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['1']), currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['0']), currency_obj=company.currency_id) }</td>
<td>${ formatLang(balance_amount(l['total']), currency_obj=company.currency_id) }</td>
</tr>
</table>
%endif ## if l
@ -102,9 +102,9 @@
<td>${ line.move_id.name }</td>
<td>${ line.ref }</td>
<td>${ line.date_maturity and formatLang(line.date_maturity,date=True) or '' }</td>
<td style="text-align: right;">${ formatLang(line.debit) or 0.0 }</td>
<td style="text-align: right;">${ formatLang(line.credit) or 0.0 }</td>
<td style="text-align: right;">${ formatLang(line.debit - line.credit, currency_obj = company.currency_id) }</td>
<td style="text-align: right;">${ formatLang(line_amount(line))}</td>
<td style="text-align: right;">${ formatLang(line_paid(line))}</td>
<td style="text-align: right;">${ formatLang(line_amount(line) - line_paid(line), currency_obj = company.currency_id) }</td>
<td style="text-align: right;">${ line.amount_currency and formatLang(line.amount_currency, currency_obj = line.currency_id) or '' }</td>
</tr>
%endfor ## for line in getLines30(partner)
@ -130,9 +130,9 @@
<td>${ line.move_id.name }</td>
<td>${ line.ref }</td>
<td>${ line.date_maturity and formatLang(line.date_maturity,date=True) or '' }</td>
<td style="text-align: right;">${ formatLang(line.debit) or 0 }</td>
<td style="text-align: right;">${ formatLang(line.credit) or 0 }</td>
<td style="text-align: right;">${ formatLang(line.debit - line.credit, currency_obj = company.currency_id) }</td>
<td style="text-align: right;">${ formatLang(line_amount(line))}</td>
<td style="text-align: right;">${ formatLang(line_paid(line))}</td>
<td style="text-align: right;">${ formatLang(line_amount(line) - line_paid(line), currency_obj = company.currency_id) }</td>
<td style="text-align: right;">${ line.amount_currency and formatLang(line.amount_currency, currency_obj = line.currency_id) or '' }</td>
</tr>
%endfor ## for line in getLines3060(partner)
@ -158,9 +158,9 @@
<td>${ line.move_id.name }</td>
<td>${ line.ref }</td>
<td>${ line.date_maturity and formatLang(line.date_maturity,date=True) or '' }</td>
<td style="text-align: right;">${ formatLang(line.debit) or 0 }</td>
<td style="text-align: right;">${ formatLang(line.credit) or 0 }</td>
<td style="text-align: right;">${ formatLang(line.debit - line.credit, currency_obj = company.currency_id) }</td>
<td style="text-align: right;">${ formatLang(line_amount(line))}</td>
<td style="text-align: right;">${ formatLang(line_paid(line))}</td>
<td style="text-align: right;">${ formatLang(line_amount(line) - line_paid(line), currency_obj = company.currency_id) }</td>
<td style="text-align: right;">${ line.amount_currency and formatLang(line.amount_currency, currency_obj = line.currency_id) or '' }</td>
</tr>
%endfor ## for line in getLines60(partner)

53
account_partner_aged_statement_webkit/report/partner_aged_statement_report.py

@ -48,6 +48,9 @@ class PartnerAgedTrialReport(aged_trial_report):
'getLines3060': self._lines_get_30_60,
'getLines60': self._lines_get60,
'show_message': True,
'line_amount': self._line_amount,
'line_paid': self._line_paid,
'balance_amount': lambda amount: amount,
})
def _lines_get30(self, obj):
@ -58,7 +61,7 @@ class PartnerAgedTrialReport(aged_trial_report):
movelines = moveline_obj.search(
self.cr, self.uid,
[('partner_id', '=', obj.id),
('account_id.type', 'in', ['receivable', 'payable']),
('account_id.type', 'in', ['receivable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False),
'|',
'&', ('date_maturity', '<=', today), ('date_maturity', '>', stop),
@ -76,7 +79,7 @@ class PartnerAgedTrialReport(aged_trial_report):
movelines = moveline_obj.search(
self.cr, self.uid,
[('partner_id', '=', obj.id),
('account_id.type', 'in', ['receivable', 'payable']),
('account_id.type', 'in', ['receivable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False),
'|',
'&', ('date_maturity', '<=', start), ('date_maturity', '>', stop),
@ -93,7 +96,7 @@ class PartnerAgedTrialReport(aged_trial_report):
movelines = moveline_obj.search(
self.cr, self.uid,
[('partner_id', '=', obj.id),
('account_id.type', 'in', ['receivable', 'payable']),
('account_id.type', 'in', ['receivable']),
('state', '<>', 'draft'), ('reconcile_id', '=', False),
'|', ('date_maturity', '<=', start),
('date_maturity', '=', False), ('date', '<=', start)],
@ -185,6 +188,7 @@ class PartnerAgedTrialReport(aged_trial_report):
", ".join(str(int(i)) for i in self._partners),
)
self.ACCOUNT_TYPE = ['receivable']
return res
def _get_lines(self, form, partner):
@ -196,6 +200,49 @@ class PartnerAgedTrialReport(aged_trial_report):
self.query = self.orig_query
return res
def _line_amount(self, line):
invoice = line.invoice
invoice_type = invoice and invoice.type or False
print invoice_type, line.debit, line.account_id.type
if invoice_type == 'in_invoice':
return line.credit or 0.0
if invoice_type == 'in_refund':
return -line.debit or 0.0
if invoice_type == 'out_invoice':
return line.debit or 0.0
if invoice_type == 'out_refund':
return -line.credit or 0.0
if line.account_id.type == 'payable':
return line.credit or 0.0
return line.debit or 0.0
def _line_paid(self, line):
invoice = line.invoice
invoice_type = invoice and invoice.type or False
if invoice_type == 'in_invoice':
return line.debit or 0.0
if invoice_type == 'in_refund':
return -line.credit or 0.0
if invoice_type == 'out_invoice':
return line.credit or 0.0
if invoice_type == 'out_refund':
return -line.debit or 0.0
if line.account_id.type == 'payable':
return line.debit or 0.0
return line.credit or 0.0
report_sxw.report_sxw(
'report.webkit.partner_aged_statement_report',

11
account_partner_aged_statement_webkit/report/supplier_aged_statement_report.py

@ -39,8 +39,18 @@ class SupplierAgedTrialReport(PartnerAgedTrialReport):
'getLines3060': self._lines_get_30_60,
'getLines60': self._lines_get60,
'show_message': False,
'get_lines': self._get_lines,
'balance_amount': lambda amount: -amount,
})
def set_context(self, objects, data, ids, report_type=None):
res = super(SupplierAgedTrialReport, self).set_context(
objects, data, ids, report_type=report_type)
self.ACCOUNT_TYPE = ['payable']
return res
def _lines_get30(self, obj):
today = datetime.now()
stop = today - relativedelta(days=30)
@ -92,6 +102,7 @@ class SupplierAgedTrialReport(PartnerAgedTrialReport):
movelines = moveline_obj.browse(self.cr, self.uid, movelines)
return movelines
report_sxw.report_sxw(
'report.webkit.supplier_aged_statement_report',
'res.partner',

Loading…
Cancel
Save