[IMP] review odo, marc, fp

bzr revid: jco@openerp.com-20121205144147-ii9hwp3omvet68t0
This commit is contained in:
Josse Colpaert 2012-12-05 15:41:47 +01:00
parent 060c576acc
commit b838e677dd
6 changed files with 244 additions and 223 deletions

View File

@ -21,6 +21,7 @@
from osv import fields, osv
from lxml import etree
from operator import itemgetter
from tools.translate import _
@ -118,13 +119,54 @@ class account_move_line(osv.osv):
class email_template(osv.osv):
_inherit = 'email.template'
def _get_followup_table_html(self, cr, uid, res_id, context = None):
#res_id -> res.partner
partner = self.pool.get('res.partner').browse(cr, uid, res_id, context=context)
followup_table = ''
if partner.unreconciled_aml_ids:
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
current_date = fields.date.context_today(cr, uid, context)
from report import account_followup_print
rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser")
final_res = rml_parse._lines_get_with_partner(partner, company.id)
for currency_dict in final_res:
currency_symbol = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'].symbol
followup_table += '''
<table border="2" width=100%%>
<tr>
<td>Invoice date</td>
<td>Reference</td>
<td>Due date</td>
<td>Amount (%s)</td>
<td>Lit.</td>
</tr>
''' % (currency_symbol)
total = 0
for aml in currency_dict['line']:
block = aml['blocked'] and 'X' or ' '
total += aml['balance']
strbegin = "<TD>"
strend = "</TD>"
date = aml['date_maturity'] or aml['date']
if date <= current_date and aml['balance'] > 0:
strbegin = "<TD><B>"
strend = "</B></TD>"
followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
total = rml_parse.formatLang(total, dp='Account', currency_obj=partner.company_id.currency_id)
followup_table += '''<tr> </tr>
</table>
<center>Amount due: %s </center>''' % (total)
return followup_table
# Adds current_date to the context. That way it can be used to put
# the account move lines in bold that are overdue in the email
def render_template(self, cr, uid, template, model, res_id, context=None):
context['current_date'] = fields.date.context_today(cr, uid, context)
if model == 'res.partner': # and 'followup' in context.keys() and context['followup']:
context['followup_table'] = self._get_followup_table_html(cr, uid, res_id, context=context)
return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context)
class res_partner(osv.osv):
def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False):
@ -138,7 +180,11 @@ class res_partner(osv.osv):
root.insert(0, first_node[0])
res['arch'] = etree.tostring(doc, encoding="utf-8")
return res
# def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
# if order and order[0] == '':
# pass
def _get_latest(self, cr, uid, ids, names, arg, context=None, company_id=None):
res={}
if company_id == None:
@ -172,6 +218,7 @@ class res_partner(osv.osv):
for partner in self.browse(cr, uid, partner_ids, context=context):
#Check action: check if the action was not empty, if not add
action_text= ""
context['followup'] = True
if partner.payment_next_action:
action_text = (partner.payment_next_action or '') + "\n" + (partner.latest_followup_level_id_without_lit.manual_action_note or '')
else:
@ -256,6 +303,95 @@ class res_partner(osv.osv):
}
def _get_amounts_and_date(self, cr, uid, ids, name, arg, context=None, company_id=None):
res = {}
if company_id == None:
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
else:
company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
current_date = fields.date.context_today(cr, uid, context)
for partner in self.browse(cr, uid, ids, context=context):
res[partner.id] = [0.0, 0.0, False]
calc_date = False
amount_due = 0.0
amount_overdue = 0.0
for aml in partner.unreconciled_aml_ids:
if (aml.company_id == company):
date_maturity = (not aml.date_maturity) and aml.date or aml.date_maturity
if (not calc_date or calc_date > date_maturity):
calc_date = date_maturity
amount_due += aml.result
if (date_maturity <= current_date):
amount_overdue += aml.result
res[partner.id] = {'payment_amount_due': amount_due,
'payment_amount_overdue': amount_overdue,
'payment_earliest_due_date': calc_date}
return res
def _search_unreconciled(self, cr, uid, obj, name, args, field, context=None):
pass
def _payment_overdue_search(self, cr, uid, obj, name, args, context=None):
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
if not args:
return []
having_values = tuple(map(itemgetter(2), args))
where = ' AND '.join(
map(lambda x: '(SUM(bal2) %(operator)s %%s)' % {
'operator':x[1]},args))
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
cr.execute(('SELECT pid AS partner_id, SUM(bal2) FROM ' \
'(SELECT CASE WHEN bal IS NOT NULL THEN bal ' \
'ELSE 0.0 END AS bal2, p.id as pid ' \
' FROM ' \
'(SELECT (debit-credit) AS bal, partner_id ' \
'FROM account_move_line l ' \
'WHERE account_id IN ' \
'(SELECT id FROM account_account '\
'WHERE type=\'receivable\' AND active) ' \
'AND date_maturity <= NOW() ' \
'AND l.company_id = %s '
'AND reconcile_id IS NULL ' \
'AND '+query+') AS l ' \
'RIGHT JOIN res_partner p ' \
'ON p.id = partner_id ) AS pl ' \
'GROUP BY pid HAVING ' + where),
(str(company),) + having_values)
res = cr.fetchall()
if not res:
return [('id','=','0')]
return [('id','in',map(itemgetter(0), res))]
def _payment_due_search(self, cr, uid, obj, name, args, context=None):
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
if not args:
return []
having_values = tuple(map(itemgetter(2), args))
where = ' AND '.join(
map(lambda x: '(SUM(bal2) %(operator)s %%s)' % {
'operator':x[1]},args))
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
cr.execute(('SELECT pid AS partner_id, SUM(bal2) FROM ' \
'(SELECT CASE WHEN bal IS NOT NULL THEN bal ' \
'ELSE 0.0 END AS bal2, p.id as pid FROM ' \
'(SELECT (debit-credit) AS bal, partner_id ' \
'FROM account_move_line l ' \
'WHERE account_id IN ' \
'(SELECT id FROM account_account '\
'WHERE type=\'receivable\' AND active) ' \
'AND reconcile_id IS NULL ' \
'AND company_id = %s'
'AND '+query+') AS l ' \
'RIGHT JOIN res_partner p ' \
'ON p.id = partner_id ) AS pl ' \
'GROUP BY pid HAVING ' + where), (str(company),) + having_values)
res = cr.fetchall()
if not res:
return [('id','=','0')]
return [('id','in',map(itemgetter(0), res))]
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Follow-up Responsible',
@ -281,7 +417,19 @@ class res_partner(osv.osv):
help="The maximum follow-up level without taking into account the account move lines with litigation",
store=False,
multi="latest"),
'payment_amount_due':fields.related('credit', type='float', string="Total amount due", readonly=True),
'payment_amount_due':fields.function(_get_amounts_and_date, method = True,
type='float', string="Amount due",
store = False, multi="amountsdate",
fnct_search=_payment_due_search),
'payment_amount_overdue':fields.function(_get_amounts_and_date, method = True,
type='float', string="Amount overdue",
store = False, multi="amountsdate",
fnct_search = _payment_overdue_search),
'payment_earliest_due_date':fields.function(_get_amounts_and_date, method=True,
type='date',
string = "Most overdue date",
multi="amountsdate",
),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -16,7 +16,9 @@
<field name="user_id" invisible="1"/>
<field name="parent_id" invisible="1"/>
<field name="payment_responsible_id"/>
<field name="credit"/>
<field name="payment_earliest_due_date"/>
<field name="payment_amount_overdue"/>
<field name="payment_amount_due"/>
</tree>
</field>
</record>
@ -28,7 +30,7 @@
<field name="arch" type="xml">
<search string="Search Partner" position="inside">
<group string="Follow-up">
<filter string="Partners with Credits" domain="[('credit', '>', 0.0)]" name="credits"/>
<filter string="Partners with Overdue Credits" domain="[('payment_amount_overdue', '>', 0.0)]" name="credits"/>
<separator/>
<filter string="Follow-ups To Do" domain="[('payment_next_action_date', '&lt;=', time.strftime('%%Y-%%m-%%d')), ('credit', '>', 0.0)]" name="todo"/>
<filter string="Future Follow-ups" domain="[('payment_next_action_date', '&gt;', time.strftime('%%Y-%%m-%%d')), ('credit', '>', 0.0)]"/>
@ -43,29 +45,7 @@
</field>
</record>
<record id="customer_followup_search_view2" model="ir.ui.view">
<field name="name">Search</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<search string="Search view">
<field name="name"/>
<field name="payment_next_action"/>
<!--<filter string="Actions to be taken with overdue amount" domain="['&amp;', ('payment_amount_outstanding', '>', 0.0), ('payment_next_action_date', '&lt;=', time.strftime('%%Y-%%m-%%d'))]"/>
<separator/>-->
<filter string="Overdue amount" domain="[('credit', '>', 0.0)]"/>
<separator/>
<filter string="Follow-ups to do" domain="[('payment_next_action_date', '&lt;=', time.strftime('%%Y-%%m-%%d'))]"/>
<separator/>
<!--filter string="Future follow-ups" domain="['&', ('payment_next_action', '!=', ''), ('payment_next_action_date', '>', time.strftime('%%Y-%%m-%%d'))]"/>-->
<separator/>
<filter string="Without responsible" domain="[('payment_responsible_id', '=', False)]"/>
<filter string="I am responsible" domain="[('payment_responsible_id','=', uid)]"/>
<group expand="1" string="Group by">
<filter string="Responsible" context="{'group_by':'payment_responsible_id'}"/>
</group>
</search>
</field>
</record>
<record id="action_customer_followup" model="ir.actions.act_window">
<field name="name">Manual Follow-Ups</field>
@ -73,7 +53,7 @@
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{} </field>
<field name="domain">[('credit', '>', 0.0)]</field>
<field name="context">{'Followupfirst':True, 'search_default_todo': True} </field>
<field name="search_view_id" ref="customer_followup_search_view"/>
</record>
@ -105,11 +85,11 @@
help="Click to mark the action as done." class="oe_link"
attrs="{'invisible':[('payment_next_action_date','=', False)]}"
groups="base.group_partner_manager"/>
<field name="payment_next_action" placeholder="e.g. Give a phonecall, Check if it's paid, ..."/>
<field name="payment_next_action" placeholder="Action to be taken e.g. Give a phonecall, Check if it's paid, ..."/>
</div>
</group>
<label for="payment_note" class="oe_edit_only"/>
<field name="payment_note" placeholder="e.g. 50%% before 15th of May, balance before 1st of July."/>
<field name="payment_note" placeholder="Comments of the user: he promised to 50%% before 15th of May, balance before 1st of July."/>
<p class="oe_grey">
Below is the history of the transactions of this
customer. You can set an invoice in litigation in
@ -119,12 +99,14 @@
<field name="unreconciled_aml_ids">
<tree string="Account Move line" editable="bottom" create="false" delete="false" colors="red:(not date_maturity or date_maturity&lt;=current_date) and result&gt;0">
<field name="date" readonly="True"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="move_id" readonly="True"/>
<field name="blocked" string="Litigation"/>
<field name="date_maturity" readonly="True"/>
<field name="reconcile_partial_id" readonly="True"/>
<field name="result" readonly="True"/>
<field name="followup_line_id" invisible='1'/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">

View File

@ -6,68 +6,40 @@
<!--Mail template level 0-->
<record id="email_template_account_followup_level0" model="email.template">
<field name="name">Follow-up of overdue invoices level 0</field>
<field name="email_from">${user.email or ''}</field>
<field name="subject">${user.company_id.name} Payment Follow-up</field>
<field name="email_to">${object.email}</field>
<field name="lang">${object.lang}</field>
<field name="email_from">${user.email or '' | h}</field>
<field name="subject">${user.company_id.name | h} Payment Reminder</field>
<field name="email_to">${object.email | h}</field>
<field name="lang">${object.lang | h}</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
<p>Dear ${object.name},</p>
<p>Dear ${object.name | h},</p>
<p>
Exception made if there was a mistake of ours, it seems that the following amount stays unpaid. Please, take
appropriate measures in order to carry out this payment in the next 8 days.
Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to
contact our accounting department at (+32).10.68.94.39.
contact our accounting department.
</p>
<br/>
Best Regards,
<br/>
${user.name}
${user.name | h}
<br/>
<br/>
<%
from openerp.addons.account_followup.report import account_followup_print
rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
final_res = rml_parse._lines_get_with_partner(object, user.company_id.id)
followup_table = ''
for currency_dict in final_res:
currency_symbol = currency_dict.get('line', [{'currency_id': user.company_id.currency_id}])[0]['currency_id'].symbol
followup_table += '''
<table border="2" width=100%%>
<tr>
<td>Invoice date</td>
<td>Reference</td>
<td>Due date</td>
<td>Amount (%s)</td>
<td>Lit.</td>
</tr>
''' % (currency_symbol)
total = 0
for aml in currency_dict['line']:
block = aml['blocked'] and 'X' or ' '
total += aml['balance']
strbegin = "<TD> "
strend = "</TD> "
date = aml['date_maturity'] or aml['date']
if date <= ctx['current_date'] and aml['balance'] > 0:
strbegin = "<TD><B>"
strend = "</B></TD>"
followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
total = rml_parse.formatLang(total, dp='Account', currency_obj=object.company_id.currency_id)
followup_table += '''<tr> </tr>
</table>
<center>Amount due: %s </center>''' % (total)
followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
%>
${followup_table}
${followup_table | h}
<br/>
@ -80,71 +52,41 @@ ${followup_table}
<!--Mail template level 1 -->
<record id="email_template_account_followup_level1" model="email.template">
<field name="name">Follow-up of overdue invoices level 1</field>
<field name="email_from">${user.email or ''}</field>
<field name="subject">${user.company_id.name} Payment Follow-up</field>
<field name="email_to">${object.email}</field>
<field name="lang">${object.lang}</field>
<field name="email_from">${user.email or '' | h}</field>
<field name="subject">${user.company_id.name | h} Payment Reminder</field>
<field name="email_to">${object.email | h}</field>
<field name="lang">${object.lang | h}</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
<p>Dear ${object.name},</p>
<p>Dear ${object.name | h},</p>
<p>
We are disappointed to see that despite sending a reminder, that your account is now seriously overdue.
It is essential that immediate payment is made, otherwise we will have to consider placing a stop on your account
which means that we will no longer be able to supply your company with (goods/services).
Please, take appropriate measures in order to carry out this payment in the next 8 days.
If there is a problem with paying invoice that we are not aware of, do not hesitate to contact our accounting
department at (+32).10.68.94.39. so that we can resolve the matter quickly.
department. so that we can resolve the matter quickly.
Details of due payments is printed below.
</p>
<br/>
Best Regards,
<br/>
${user.name}
${user.name | h}
<br/>
<br/>
<%
from openerp.addons.account_followup.report import account_followup_print
rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
final_res = rml_parse._lines_get_with_partner(object, user.company_id.id)
followup_table = ''
for currency_dict in final_res:
currency_symbol = currency_dict.get('line', [{'currency_id': user.company_id.currency_id}])[0]['currency_id'].symbol
followup_table += '''
<table border="2" width=100%%>
<tr>
<td>Invoice date</td>
<td>Reference</td>
<td>Due date</td>
<td>Amount (%s)</td>
<td>Lit.</td>
</tr>
''' % (currency_symbol)
total = 0
for aml in currency_dict['line']:
block = aml['blocked'] and 'X' or ' '
total += aml['balance']
strbegin = "<TD> "
strend = "</TD> "
date = aml['date_maturity'] or aml['date']
if date <= ctx['current_date'] and aml['balance'] > 0:
strbegin = "<TD><B>"
strend = "</B></TD>"
followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
total = rml_parse.formatLang(total, dp='Account', currency_obj=object.company_id.currency_id)
followup_table += '''<tr> </tr>
</table>
<center>Amount due: %s </center>''' % (total)
followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
%>
${followup_table}
${followup_table | h}
<br/>
@ -154,70 +96,38 @@ ${followup_table}
<!--Email template -->
<record id="email_template_account_followup_level2" model="email.template">
<field name="name">Follow-up of overdue invoices level 2</field>
<field name="email_from">${user.email or ''}</field>
<field name="subject">${user.company_id.name} Payment Follow-up</field>
<field name="email_to">${object.email}</field>
<field name="lang">${object.lang}</field>
<field name="email_from">${user.email or '' | h}</field>
<field name="subject">${user.company_id.name | h} Payment Reminder</field>
<field name="email_to">${object.email | h}</field>
<field name="lang">${object.lang | h}</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
<p>Dear ${object.name},</p>
<p>Dear ${object.name | h},</p>
<p>
Despite several reminders, your account is still not settled.
Unless full payment is made in next 8 days, legal action for the recovery of the debt will be taken without
further notice.
I trust that this action will prove unnecessary and details of due payments is printed below.
In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
In case of any queries concerning this matter, do not hesitate to contact our accounting department.
</p>
<br/>
Best Regards,
<br/>
${user.name}
${user.name | h}
<br/>
<br/>
<%
from openerp.addons.account_followup.report import account_followup_print
rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
final_res = rml_parse._lines_get_with_partner(object, user.company_id.id)
followup_table = ''
for currency_dict in final_res:
currency_symbol = currency_dict.get('line', [{'currency_id': user.company_id.currency_id}])[0]['currency_id'].symbol
followup_table += '''
<table border="2" width=100%%>
<tr>
<td>Invoice date</td>
<td>Reference</td>
<td>Due date</td>
<td>Amount (%s)</td>
<td>Lit.</td>
</tr>
''' % (currency_symbol)
total = 0
for aml in currency_dict['line']:
block = aml['blocked'] and 'X' or ' '
total += aml['balance']
strbegin = "<TD> "
strend = "</TD> "
date = aml['date_maturity'] or aml['date']
if date <= ctx['current_date'] and aml['balance'] > 0:
strbegin = "<TD><B>"
strend = "</B></TD>"
followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
total = rml_parse.formatLang(total, dp='Account', currency_obj=object.company_id.currency_id)
followup_table += '''<tr> </tr>
</table>
<center>Amount due: %s </center>''' % (total)
followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
%>
${followup_table}
${object.followup_table(object, user) | h}
<br/>
@ -229,80 +139,43 @@ ${followup_table}
<record id="email_template_account_followup_default" model="email.template">
<field name="name">Default follow-up of overdue invoices</field>
<field name="email_from">${user.email or ''}</field>
<field name="subject">${user.company_id.name} Payment Follow-up</field>
<field name="email_to">${object.email}</field>
<field name="lang">${object.lang}</field>
<field name="email_from">${user.email or '' | h}</field>
<field name="subject">${user.company_id.name | h} Payment Reminder</field>
<field name="email_to">${object.email | h}</field>
<field name="lang">${object.lang | h}</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
<p>Dear ${object.name},</p>
<p>Dear ${object.name | h},</p>
<p>
Exception made if there was a mistake of ours, it seems that the following amount stays unpaid. Please, take
appropriate measures in order to carry out this payment in the next 8 days.
Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to
contact our accounting department at (+32).10.68.94.39.
contact our accounting department.
</p>
<br/>
Best Regards,
</br>
</br>
<br/>
${user.name}
${user.name | h}
<br/>
<br/>
<%
from openerp.addons.account_followup.report import account_followup_print
rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
final_res = rml_parse._lines_get_with_partner(object, user.company_id.id)
followup_table = ''
for currency_dict in final_res:
currency_symbol = currency_dict.get('line', [{'currency_id': user.company_id.currency_id}])[0]['currency_id'].symbol
followup_table += '''
<table border="2" width=100%%>
<tr>
<td>Invoice date</td>
<td>Reference</td>
<td>Due date</td>
<td>Amount (%s)</td>
<td>Lit.</td>
</tr>
''' % (currency_symbol)
total = 0
for aml in currency_dict['line']:
block = aml['blocked'] and 'X' or ' '
total += aml['balance']
strbegin = "<TD> "
strend = "</TD> "
date = aml['date_maturity'] or aml['date']
if date <= ctx['current_date'] and aml['balance'] > 0:
strbegin = "<TD><B>"
strend = "</B></TD>"
followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
total = rml_parse.formatLang(total, dp='Account', currency_obj=object.company_id.currency_id)
followup_table += '''<tr> </tr>
</table>
<center>Amount due: %s </center>''' % (total)
followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
%>
${followup_table}
<br/>
${followup_table | h}
<br/>
</div>
]]></field>
</record>
<record id="demo_followup1" model="account_followup.followup">
<field name="company_id" ref="base.main_company"/>
@ -319,7 +192,7 @@ Dear %(partner_name)s,
Exception made if there was a mistake of ours, it seems that the following amount stays unpaid. Please, take appropriate measures in order to carry out this payment in the next 8 days.
Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to contact our accounting department at (+32).10.68.94.39.
Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to contact our accounting department.
Best Regards,
</field>
@ -342,15 +215,13 @@ We are disappointed to see that despite sending a reminder, that your account is
It is essential that immediate payment is made, otherwise we will have to consider placing a stop on your account which means that we will no longer be able to supply your company with (goods/services).
Please, take appropriate measures in order to carry out this payment in the next 8 days.
If there is a problem with paying invoice that we are not aware of, do not hesitate to contact our accounting department at (+32).10.68.94.39. so that we can resolve the matter quickly.
If there is a problem with paying invoice that we are not aware of, do not hesitate to contact our accounting department, so that we can resolve the matter quickly.
Details of due payments is printed below.
Best Regards,
</field>
</record>
<record id="demo_followup_line3" model="account_followup.followup.line">
<field name="name">Call the customer on the phone</field>
<field name="sequence">3</field>
@ -369,7 +240,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
In case of any queries concerning this matter, do not hesitate to contact our accounting department.
Best Regards,
</field>

View File

@ -17,7 +17,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
In case of any queries concerning this matter, do not hesitate to contact our accounting department at [TEL NUMBER].
Best Regards,
</field>
@ -39,7 +39,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
In case of any queries concerning this matter, do not hesitate to contact our accounting department at [TEL NUMBER].
Best Regards,
</field>

View File

@ -69,7 +69,6 @@
<record id="view_account_followup_followup_form" model="ir.ui.view">
<field name="name">account_followup.followup.form</field>
<field name="model">account_followup.followup</field>
<!-- <field name="group_ids" groups="base.group_multi_company"/>-->
<field name="arch" type="xml">
<form string="Follow-up" version="7.0">
<h1><field name="company_id" widget="selection" class="oe_inline"/></h1>
@ -79,7 +78,7 @@
overdue the customer is. These actions are bundled
into folow-up levels that are triggered when the due
date of the most overdue invoice has passed a certain
amount of days.
number of days.
</p>
<field name="followup_line"/>
</form>
@ -91,7 +90,7 @@
<field name="model">account_followup.followup</field>
<field name="arch" type="xml">
<tree string="Follow-up">
<field name="company_id" /> <!--groups="base.group_multi_company"-->
<field name="company_id" />
</tree>
</field>
</record>
@ -168,7 +167,7 @@
</tree>
</field>
</record>
<!--
<record id="view_move_line_form" model="ir.ui.view">
<field name="name">account.move.line.form.followup</field>
<field name="model">account.move.line</field>
@ -179,19 +178,6 @@
<field name="followup_date"/>
</field>
</field>
</record>
<!-- <record id="view_move_line_tree" model="ir.ui.view">
<field name="name">account.move.line.tree.followup</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree"/>
<field name="arch" type="xml">
<field name="state" position="before">
<field name="followup_date"/>
<field name="followup_line_id"/>
</field>
</field>
</record> -->
</record>-->
</data>
</openerp>

View File

@ -23,8 +23,10 @@ import time
import pooler
from report import report_sxw
from osv import fields
class report_rappel(report_sxw.rml_parse):
_name = "account_followup.report.rappel"
def __init__(self, cr, uid, name, context=None):
super(report_rappel, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
@ -79,7 +81,40 @@ class report_rappel(report_sxw.rml_parse):
final_res.append({'line': line_cur[cur]['line']})
return final_res
def get_unreconciled_table(self, partner, company, context = None):
final_res = self._lines_get_with_partner(partner, company.id)
followup_table = ''
for currency_dict in final_res:
currency_symbol = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'].symbol
followup_table += '''
<table border="2" width=100%%>
<tr>
<td>Invoice date</td>
<td>Reference</td>
<td>Due date</td>
<td>Amount (%s)</td>
<td>Lit.</td>
</tr>
''' % (currency_symbol)
total = 0
ctx = context
for aml in currency_dict['line']:
block = aml['blocked'] and 'X' or ' '
total += aml['balance']
strbegin = "<TD>"
strend = "</TD>"
date = aml['date_maturity'] or aml['date']
if date <= ctx['current_date'] and aml['balance'] > 0:
strbegin = "<TD><B>"
strend = "</B></TD>"
followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
total = self.formatLang(total, dp='Account', currency_obj=partner.company_id.currency_id)
followup_table += '''<tr> </tr>
</table>
<center>Amount due: %s </center>''' % (total)
return followup_table
def _get_text(self, stat_line, followup_id, context=None):
if context is None:
context = {}
@ -108,7 +143,6 @@ class report_rappel(report_sxw.rml_parse):
'company_name': stat_line.company_id.name,
'user_signature': pooler.get_pool(self.cr.dbname).get('res.users').browse(self.cr, self.uid, self.uid, context).signature or '',
}
return text
report_sxw.report_sxw('report.account_followup.followup.print',