From f02c5a23ad3b623d1f7f2532b7bf7fde5b703ac3 Mon Sep 17 00:00:00 2001
From: dufresnedavid
Date: Thu, 5 Feb 2015 10:26:30 -0500
Subject: [PATCH] Remove unused methods, add timezone to the reference date and
fix translation
---
.../i18n/fr.po | 54 +++++++++++++++++-
.../report/partner_aged_statement.mako | 18 +++---
.../report/partner_aged_statement_report.py | 57 ++++---------------
3 files changed, 72 insertions(+), 57 deletions(-)
diff --git a/account_partner_aged_statement_webkit/i18n/fr.po b/account_partner_aged_statement_webkit/i18n/fr.po
index bff78e7a..656a44d8 100644
--- a/account_partner_aged_statement_webkit/i18n/fr.po
+++ b/account_partner_aged_statement_webkit/i18n/fr.po
@@ -106,6 +106,59 @@ msgid "\n"
"
\n"
"\n"
" \n"
+" REFERENCES
\n"
+" Total overdue amount: ${object.credit} ${user.company_id.currency_id.name}
\n"
+"
\n"
+"\n"
+"
\n"
+"
\n"
+" \n"
+"
\n"
+" ${user.company_id.name}
\n"
+"
\n"
+" \n"
+"
\n"
+" % if user.company_id.street:\n"
+" ${user.company_id.street}
\n"
+" % endif\n"
+" % if user.company_id.street2:\n"
+" ${user.company_id.street2}
\n"
+" % endif\n"
+" % if user.company_id.city or user.company_id.zip:\n"
+" ${user.company_id.zip} ${user.company_id.city}
\n"
+" % endif\n"
+" % if user.company_id.country_id:\n"
+" ${user.company_id.state_id and ('%s, ' % user.company_id.state_id.name) or ''} ${user.company_id.country_id.name or ''}
\n"
+" % endif\n"
+" \n"
+" % if user.company_id.phone:\n"
+"
\n"
+" Phone: ${user.company_id.phone}\n"
+"
\n"
+" % endif\n"
+" % if user.company_id.website:\n"
+"
\n"
+" %endif\n"
+"
\n"
+"
\n"
+"\n"
+" "
+msgstr "\n"
+"\n"
+"\n"
+" \n"
+" % for line in user.company_id.overdue_msg.split('\\n'):\n"
+"
${line}
\n"
+" % endfor\n"
+"\n"
+"
\n"
+" ${user.name}\n"
+"
\n"
+"
\n"
+"\n"
+"
\n"
" RÉFÉRENCES
\n"
" Total du montant en retard: ${object.credit} ${user.company_id.currency_id.name}
\n"
"
\n"
@@ -145,7 +198,6 @@ msgid "\n"
"
\n"
"\n"
" "
-msgstr ""
#. module: account_partner_aged_statement_webkit
#: report:addons/account_partner_aged_statement_webkit/report/partner_aged_statement.mako:63
diff --git a/account_partner_aged_statement_webkit/report/partner_aged_statement.mako b/account_partner_aged_statement_webkit/report/partner_aged_statement.mako
index 08780055..b3a580e9 100644
--- a/account_partner_aged_statement_webkit/report/partner_aged_statement.mako
+++ b/account_partner_aged_statement_webkit/report/partner_aged_statement.mako
@@ -33,9 +33,9 @@
<%from datetime import date %>
${_('Date')}: ${formatLang(str(date.today()), date=True)}
-
+
${_('Partner')}: ${partner.name}
-
+
${_('Subject')}: ${_('Overdue Statement')}
@@ -46,15 +46,15 @@
%endfor
%endif
-
+
${user.name}
-
-
+
+
%if (partner.credit + partner.debit == 0) :
${_('Nothing due for this partner')}
%else:
${_('Aged Balance')}
-
+
%if get_balance(partner, company):
@@ -81,11 +81,11 @@
%endfor
%endif
-
-
+
+
${_('List of Due Invoices')}
%if getLines30(partner, company):
-
+
${_('0-30')}
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
index 6a01a3bd..7c9f9aa5 100644
--- a/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py
+++ b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py
@@ -21,7 +21,7 @@
###############################################################################
import time
-
+import pytz
from datetime import datetime
from dateutil.relativedelta import relativedelta
@@ -56,12 +56,15 @@ class PartnerAgedTrialReport(aged_trial_report):
})
self.partner_invoices_dict = {}
self.ttype = 'receipt'
+ tz = self.localcontext.get('tz', False)
+ tz = tz and pytz.timezone(tz) or pytz.utc
+ self.today = datetime.now(tz)
def _get_balance(self, partner, company):
"""
Get the lines of balance to display in the report
"""
- today = datetime.now()
+ today = self.today
date_30 = today - relativedelta(days=30)
date_60 = today - relativedelta(days=60)
date_90 = today - relativedelta(days=90)
@@ -257,7 +260,7 @@ class PartnerAgedTrialReport(aged_trial_report):
return self.partner_invoices_dict[partner.id]
def _lines_get_30(self, partner, company):
- today = datetime.now()
+ today = self.today
stop = today - relativedelta(days=30)
today = today.strftime(DEFAULT_SERVER_DATE_FORMAT)
@@ -271,7 +274,7 @@ class PartnerAgedTrialReport(aged_trial_report):
return movelines
def _lines_get_30_60(self, partner, company):
- today = datetime.now()
+ today = self.today
start = today - relativedelta(days=30)
stop = start - relativedelta(days=30)
@@ -282,12 +285,12 @@ class PartnerAgedTrialReport(aged_trial_report):
movelines = self._get_current_invoice_lines(partner, company, today)
movelines = [
line for line in movelines
- if stop < line['date_due'] <= start
+ if line['date_due'] and stop < line['date_due'] <= start
]
return movelines
def _lines_get60(self, partner, company):
- today = datetime.now()
+ today = self.today
start = today - relativedelta(days=60)
today = today.strftime(DEFAULT_SERVER_DATE_FORMAT)
@@ -304,51 +307,11 @@ class PartnerAgedTrialReport(aged_trial_report):
company_pool = pooler.get_pool(self.cr.dbname)['res.company']
message = company_pool.browse(
self.cr, self.uid, company.id, {'lang': obj.lang}).overdue_msg
- return message.split('\n')
-
- def _get_fiscalyear(self, data):
- now = data['fInvoicesorm']['date_from']
- domain = [
- ('company_id', '=', self._company.id),
- ('date_start', '<', now),
- ('date_stop', '>', now),
- ]
- fiscalyears_obj = pooler.get_pool(self.cr.dbname)['account.fiscalyear']
- fiscalyears = fiscalyears_obj.search(
- self.cr, self.uid, domain, limit=1, context=self.localcontext)
- if fiscalyears:
- return fiscalyears_obj.browse(
- self.cr, self.uid, fiscalyears[0], context=self.localcontext
- ).name
- else:
- return ''
-
- def _get_account(self, data):
- account_obj = pooler.get_pool(self.cr.dbname).get('account.account')
- accounts = account_obj.search(
- self.cr, self.uid,
- [('parent_id', '=', False), ('company_id', '=', self._company.id)],
- limit=1, context=self.localcontext)
- if accounts:
- return account_obj.browse(
- self.cr, self.uid, accounts[0],
- context=self.localcontext).name
- else:
- return ''
+ return message and message.split('\n') or ''
def _get_company(self, data):
return self._company.name
- def _get_journal(self, data):
- codes = []
- if data.get('form', False) and data['form'].get('journal_ids', False):
- self.cr.execute(
- 'select code from account_journal where id IN %s',
- (tuple(data['form']['journal_ids']),)
- )
- codes = [x for x, in self.cr.fetchall()]
- return codes
-
def _get_currency(self, data):
return self._company.currency_id.symbol