[IMP] Changed names, constraints per company
bzr revid: jco@openerp.com-20121108141457-2y81skjhq0ewaz3i
This commit is contained in:
@@ -23,6 +23,8 @@ from osv import fields, osv
|
||||
from datetime import date
|
||||
import time
|
||||
|
||||
from tools.translate import _
|
||||
|
||||
class followup(osv.osv):
|
||||
_name = 'account_followup.followup'
|
||||
_description = 'Account Follow-up'
|
||||
@@ -35,6 +37,7 @@ class followup(osv.osv):
|
||||
_defaults = {
|
||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account_followup.followup', context=c),
|
||||
}
|
||||
_sql_constraints = [('company_uniq', 'unique(company_id)', 'Only one follow-up for every company allowed')]
|
||||
|
||||
followup()
|
||||
|
||||
@@ -53,22 +56,21 @@ class followup_line(osv.osv):
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of follow-up lines."),
|
||||
'delay': fields.integer('Days of delay'),
|
||||
'start': fields.selection([('days','Net Days'),('end_of_month','End of Month')], 'Type of Term', size=64, required=True),
|
||||
'delay': fields.integer('Days of delay', help="The number of days after the due date of the invoice. Could be negative if you want to send a polite alert beforehand. "),
|
||||
#'start': fields.selection([('days','Net Days'),('end_of_month','End of Month')], 'Type of Term', size=64, required=True),
|
||||
'followup_id': fields.many2one('account_followup.followup', 'Follow Ups', required=True, ondelete="cascade"),
|
||||
'description': fields.text('Printed Message', translate=True),
|
||||
'send_email':fields.boolean('Send email', help="When processing, it will send an email"),
|
||||
'send_letter':fields.boolean('Send letter', help="When processing, it will print a letter"),
|
||||
'phonecall':fields.boolean('Manual action'),
|
||||
'manual_action':fields.text('Action text'),
|
||||
'action_responsible':fields.many2one('res.users', 'Responsible', ondelete='set null'),
|
||||
'manual_action':fields.boolean('Manual action', help="When processing, it will set the manual action to be taken for that customer. "),
|
||||
'manual_action_note':fields.text('Action text', placeholder="e.g. Give a phonecall, check with others , ..."),
|
||||
'manual_action_responsible_id':fields.many2one('res.users', 'Responsible', ondelete='set null'),
|
||||
'email_template_id':fields.many2one('email.template', 'Email template', ondelete='set null'),
|
||||
'email_body':fields.related('email_template_id', 'body_html', type='text', string="Email Message", relation="email.template", translate="True"),
|
||||
}
|
||||
_order = 'delay'
|
||||
_sql_constraints = [('days_uniq', 'unique(delay)', 'Days of the follow-up levels must be different')] #ADD FOR multi-company!
|
||||
_sql_constraints = [('days_uniq', 'unique(followup_id, delay)', 'Days of the follow-up levels must be different')] #ADD FOR multi-company!
|
||||
_defaults = {
|
||||
'start': 'days',
|
||||
'send_email': True,
|
||||
'send_letter': False,
|
||||
'description': """
|
||||
@@ -135,7 +137,15 @@ class account_move_line(osv.osv):
|
||||
|
||||
account_move_line()
|
||||
|
||||
class email_template(osv.osv):
|
||||
_inherit = 'email.template'
|
||||
|
||||
#Adds current_date to the context. That way it can be used in the email templates
|
||||
def render_template(self, cr, uid, template, model, res_id, context=None):
|
||||
context['current_date'] = fields.date.context_today(cr, uid, context) #change by inheritance
|
||||
return super(email_template, self).render_template(cr, uid, template, model, res_id, context)
|
||||
|
||||
email_template()
|
||||
|
||||
|
||||
class res_partner(osv.osv):
|
||||
@@ -144,20 +154,8 @@ class res_partner(osv.osv):
|
||||
def _get_latest_followup_date(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for partner in self.browse(cr, uid, ids):
|
||||
|
||||
|
||||
amls = partner.accountmoveline_ids
|
||||
#max(x.followup_date for x in accountmovelines)
|
||||
#latest_date = lambda a: date(2011, 1, 1)
|
||||
#for accountmoveline in accountmovelines:
|
||||
# if (accountmoveline.followup_date != False) and (latest_date < accountmoveline.followup_date):
|
||||
# latest_date = accountmoveline.followup_date
|
||||
#if accountmovelines:
|
||||
amls = partner.accountmoveline_ids
|
||||
res[partner.id] = max([x.followup_date for x in amls]) if len(amls) else False
|
||||
#else:
|
||||
# res[partner.id] = False
|
||||
|
||||
#res[partner.id] = max(x.followup_date for x in accountmovelines) if len(accountmovelines) else False
|
||||
return res
|
||||
|
||||
|
||||
@@ -168,13 +166,11 @@ class res_partner(osv.osv):
|
||||
for partner in self.browse(cr, uid, ids):
|
||||
amls = partner.accountmoveline_ids
|
||||
level_id = 0
|
||||
level_days = False #TO BE IMPROVED with boolean checking first time or by using MAX
|
||||
level_days = False
|
||||
latest_level = False
|
||||
res[partner.id] = False
|
||||
for accountmoveline in amls:
|
||||
if (accountmoveline.followup_line_id != False) and (not level_days or level_days < accountmoveline.followup_line_id.delay):
|
||||
# and (accountmoveline.debit > 0): (accountmoveline.state != "draft") and
|
||||
#and (accountmoveline.reconcile_id == None)
|
||||
level_days = accountmoveline.followup_line_id.delay
|
||||
latest_level = accountmoveline.followup_line_id.id
|
||||
res[partner.id] = latest_level
|
||||
@@ -186,53 +182,50 @@ class res_partner(osv.osv):
|
||||
for partner in self.browse(cr, uid, ids):
|
||||
amls = partner.accountmoveline_ids
|
||||
level_id = 0
|
||||
level_days = False #TO BE IMPROVED with boolean checking first time or by using MAX
|
||||
level_days = False
|
||||
latest_level = False
|
||||
res[partner.id] = False
|
||||
for accountmoveline in amls:
|
||||
if (not accountmoveline.blocked) and (accountmoveline.followup_line_id != False) and (not level_days or level_days < accountmoveline.followup_line_id.delay):
|
||||
# and (accountmoveline.debit > 0): (accountmoveline.state != "draft") and
|
||||
#and (accountmoveline.reconcile_id == None)
|
||||
level_days = accountmoveline.followup_line_id.delay
|
||||
latest_level = accountmoveline.followup_line_id.id
|
||||
res[partner.id] = latest_level
|
||||
#res[partner.id] = max(x.followup_line_id.delay for x in amls) if len(amls) else False
|
||||
return res
|
||||
|
||||
def get_latest_followup_level(self):
|
||||
amls = self.accountmoveline_ids
|
||||
|
||||
def _get_next_followup_level_id_optimized(self, cr, uid, ids, name, arg, context=None):
|
||||
#Apparently there is still an error in this function
|
||||
res = {}
|
||||
for partner in self.browse(cr, uid, ids):
|
||||
latest_id = partner.latest_followup_level_id
|
||||
if latest_id:
|
||||
latest = latest_id
|
||||
else:
|
||||
latest = False
|
||||
delay = False
|
||||
newlevel = False
|
||||
if latest: #if latest exists
|
||||
newlevel = latest.id
|
||||
old_delay = latest.delay
|
||||
else:
|
||||
old_delay = False
|
||||
fl_ar = self.pool.get('account_followup.followup.line').search(cr, uid, [('followup_id.company_id.id','=', partner.company_id.id)])
|
||||
for fl_obj in self.pool.get('account_followup.followup.line').browse(cr, uid, fl_ar):
|
||||
if not old_delay:
|
||||
if not delay or fl_obj.delay < delay:
|
||||
delay = fl_obj.delay
|
||||
newlevel = fl_obj.id
|
||||
else:
|
||||
if (not delay and (fl_obj.delay > old_delay)) or ((fl_obj.delay < delay) and (fl_obj.delay > old_delay)):
|
||||
delay = fl_obj.delay
|
||||
newlevel = fl_obj.id
|
||||
res[partner.id] = newlevel
|
||||
#Now search one level higher
|
||||
return res
|
||||
|
||||
# def _get_next_followup_level_id_optimized(self, cr, uid, ids, name, arg, context=None):
|
||||
# #Apparently there is still an error in this function
|
||||
# res = {}
|
||||
# for partner in self.browse(cr, uid, ids):
|
||||
# latest_id = partner.latest_followup_level_id
|
||||
# if latest_id:
|
||||
# latest = latest_id
|
||||
# else:
|
||||
# latest = False
|
||||
# delay = False
|
||||
# newlevel = False
|
||||
# if latest: #if latest exists
|
||||
# newlevel = latest.id
|
||||
# old_delay = latest.delay
|
||||
# else:
|
||||
# old_delay = False
|
||||
# fl_ar = self.pool.get('account_followup.followup.line').search(cr, uid, [('followup_id.company_id.id','=', partner.company_id.id)])
|
||||
# for fl_obj in self.pool.get('account_followup.followup.line').browse(cr, uid, fl_ar):
|
||||
# if not old_delay:
|
||||
# if not delay or fl_obj.delay < delay:
|
||||
# delay = fl_obj.delay
|
||||
# newlevel = fl_obj.id
|
||||
# else:
|
||||
# if (not delay and (fl_obj.delay > old_delay)) or ((fl_obj.delay < delay) and (fl_obj.delay > old_delay)):
|
||||
# delay = fl_obj.delay
|
||||
# newlevel = fl_obj.id
|
||||
# res[partner.id] = newlevel
|
||||
# #Now search one level higher
|
||||
# return res
|
||||
|
||||
|
||||
def _get_next_followup_level_id(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for partner in self.browse(cr, uid, ids):
|
||||
@@ -241,16 +234,13 @@ class res_partner(osv.osv):
|
||||
latest = self.pool.get('account_followup.followup.line').browse(cr, uid, [latest_id], context)[0]
|
||||
else:
|
||||
latest = False
|
||||
|
||||
delay = False
|
||||
newlevel = False
|
||||
if latest: #if latest exists
|
||||
old_delay = False
|
||||
if latest: #if latest exists
|
||||
newlevel = latest.id
|
||||
old_delay = latest.delay
|
||||
else:
|
||||
old_delay = False
|
||||
fl_ar = self.pool.get('account_followup.followup.line').search(cr, uid, [('followup_id.company_id.id','=', partner.company_id.id)])
|
||||
|
||||
fl_ar = self.pool.get('account_followup.followup.line').search(cr, uid, [('followup_id.company_id.id','=', partner.company_id.id)])
|
||||
for fl_obj in self.pool.get('account_followup.followup.line').browse(cr, uid, fl_ar):
|
||||
if not old_delay:
|
||||
if not delay or fl_obj.delay < delay:
|
||||
@@ -261,15 +251,11 @@ class res_partner(osv.osv):
|
||||
delay = fl_obj.delay
|
||||
newlevel = fl_obj.id
|
||||
res[partner.id] = newlevel
|
||||
#Now search one level higher
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def _get_amount_overdue(self, cr, uid, ids, name, arg, context=None):
|
||||
'''
|
||||
Get the total amount in the account move lines that is overdue (passed due date)
|
||||
'''
|
||||
#Get the total amount in the account move lines that is overdue (passed or equal to due date)
|
||||
res={}
|
||||
for partner in self.browse(cr, uid, ids, context):
|
||||
res[partner.id] = 0.0
|
||||
@@ -279,21 +265,17 @@ class res_partner(osv.osv):
|
||||
return res
|
||||
|
||||
|
||||
def do_partner_phonecall(self, cr, uid, partner_ids, context=None):
|
||||
#partners = self.browse(cr, uid, partner_ids, context)
|
||||
#print partner_ids
|
||||
#print "Testing: " , fields.date.context_today(cr, uid, context)
|
||||
# partners = self.browse(cr, uid, partner_ids, context)
|
||||
# partners2 = filter(lambda x: x.payment_action_date == False and x.payment_next_action == "" , partners)
|
||||
# partners2_ids = [x.id for x in partners2]
|
||||
# self.write(cr, uid, partner2_ids, {'payment_next_action_date': fields.date.context_today(cr, uid, context),}, context)
|
||||
def do_partner_manual_action(self, cr, uid, partner_ids, context=None):
|
||||
#partner_ids are res.partner ids
|
||||
for partner in self.browse(cr, uid, partner_ids, context):
|
||||
if (not partner.payment_next_action_date) and (not partner.payment_next_action) and (not partner.payment_responsible_id) :
|
||||
self.write(cr, uid, [partner.id], {'payment_next_action_date': fields.date.context_today(cr, uid, context),
|
||||
'payment_next_action': partner.latest_followup_level_id_without_lit.manual_action_note,
|
||||
'payment_responsible_id': partner.latest_followup_level_id_without_lit.action_responsible.id})
|
||||
'payment_responsible_id': partner.latest_followup_level_id_without_lit.manual_action_responsible_id.id})
|
||||
|
||||
def do_partner_print(self, cr, uid, partner_ids, data, context=None):
|
||||
#partner_ids are ids from special view, not from res.partner
|
||||
|
||||
#data.update({'date': context['date']})
|
||||
if not partner_ids:
|
||||
return {}
|
||||
@@ -310,29 +292,23 @@ class res_partner(osv.osv):
|
||||
}
|
||||
|
||||
def do_partner_mail(self, cr, uid, partner_ids, context=None):
|
||||
#get the mail template to use
|
||||
#mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup')
|
||||
#partner_ids are res.partner ids
|
||||
# If not defined by latest level, it will the default template if it can find it
|
||||
mtp = self.pool.get('email.template')
|
||||
#mtp.subject = "Invoices overdue"
|
||||
#user_obj = self.pool.get('res.users')
|
||||
#mtp.email_from = user_obj.browse(cr, uid, uid, context=context)
|
||||
for partner in self.browse(cr, uid, partner_ids, context):
|
||||
#Get max level of ids
|
||||
print partner.id
|
||||
if partner.latest_followup_level_id_without_lit and partner.latest_followup_level_id_without_lit.email_template_id.id != False :
|
||||
#print "From latest followup level", partner.latest_followup_level_id.email_template_id.id
|
||||
#print partner.id, "done"
|
||||
|
||||
if partner.latest_followup_level_id_without_lit and partner.latest_followup_level_id_without_lit.send_email and partner.latest_followup_level_id_without_lit.email_template_id.id != False :
|
||||
mtp.send_mail(cr, uid, partner.latest_followup_level_id_without_lit.email_template_id.id, partner.id, context=context)
|
||||
else:
|
||||
pass
|
||||
#print "From mail template", mail_template_id.id
|
||||
#mtp.send_mail(cr, uid, mail_template_id.id, partner.id, context=context)
|
||||
else :
|
||||
mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup_default')
|
||||
mtp.send_mail(cr, uid, mail_template_id[1], partner.id, context=context)
|
||||
|
||||
|
||||
def action_done(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'payment_next_action_date': False, 'payment_next_action':'', 'payment_responsible_id': False}, context)
|
||||
|
||||
def do_button_print(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, [ids[0]], body="Printed overdue payments report", context=context)
|
||||
def do_button_print(self, cr, uid, ids, context=None):
|
||||
self.message_post(cr, uid, [ids[0]], body=_('Printed overdue payments report'), context=context)
|
||||
datas = {
|
||||
'ids': ids,
|
||||
'model': 'res.partner',
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<field name="payment_next_action"/>
|
||||
<!--<field name="payment_note"/>
|
||||
<field name="phone"/>-->
|
||||
<field name="payment_amount_outstanding"/>
|
||||
<field name="payment_amount_overdue"/>
|
||||
<field name="payment_responsible_id"/>
|
||||
<!--<field name="email"/>-->
|
||||
<field name="next_followup_level_id"/>
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
<!--<filter string="Actions to be taken with overdue amount" domain="['&', ('payment_amount_outstanding', '>', 0.0), ('payment_next_action_date', '<=', time.strftime('%%Y-%%m-%%d'))]"/>
|
||||
<separator/>-->
|
||||
<filter string="Overdue amount" domain="[('payment_amount_outstanding', '>', 0.0)]"/>
|
||||
<filter string="Overdue amount" domain="[('payment_amount_overdue', '>', 0.0)]"/>
|
||||
<separator/>
|
||||
<filter string="Action to be taken now" domain="[('payment_next_action_date', '<=', time.strftime('%%Y-%%m-%%d'))]"/>
|
||||
<separator/>
|
||||
@@ -141,20 +141,17 @@
|
||||
<field name="name">res.partner.followup.form.inherit</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
|
||||
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/><!-- or user? -->
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<div name="buttons" position="inside">
|
||||
<button name="do_button_print" type="object" string="Print Overdue Payments Report"/>
|
||||
<button name="do_button_mail" type="object" string="Send Overdue Email"/>
|
||||
<button name="do_button_print" type="object" string="Print Overdue Payments Report" help="Print overdue payments report independent of follow-up line" attrs="{'invisible':[('payment_amount_overdue', '<=', 0.0)]}"/>
|
||||
<button name="do_button_mail" type="object" string="Send Overdue Email" help="If not specified by the latest follow-up level, it will send from the default follow-up of overdue invoices template" attrs="{'invisible':[('payment_amount_overdue', '<=', 0.0)]}"/>
|
||||
</div>
|
||||
|
||||
|
||||
<page string="Accounting" position="before" version="7.0">
|
||||
<page string="Payments Follow-up" position="inside">
|
||||
<group>
|
||||
<group>
|
||||
<field name="payment_amount_outstanding"/>
|
||||
<field name="payment_amount_overdue"/>
|
||||
</group>
|
||||
<group>
|
||||
<label for="payment_next_action"/>
|
||||
@@ -163,19 +160,21 @@
|
||||
<field name="payment_next_action" class="oe_inline" nolabel="1" placeholder="e.g. Give a phonecall, Check if he paid, ..."/>
|
||||
</div>
|
||||
</group>
|
||||
|
||||
|
||||
<group>
|
||||
<field name="latest_followup_level_id"/>
|
||||
<field name="latest_followup_date"/>
|
||||
<field name="next_followup_level_id"/>
|
||||
<field name="payment_note"/>
|
||||
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<!--<field name="payment_next_action_date" help="This is when further follow-up is needed. The date will have been set to the current date when processing the follow-ups asks for a phone call"/>-->
|
||||
<field name="payment_responsible_id" help="The user who takes responsibility to follow it up. "/>
|
||||
<button name="action_done" type="object" string="Follow-up Action Done" help="This button will clear the action and the action date. "/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="payment_note"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="accountmoveline_ids" nolabel="1" > <!--domain="[('reconcile_id', '=', False)]" not necessary-->
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<record id="email_template_account_followup_level0" model="email.template">
|
||||
<field name="name">Followup of overdue invoices level 0</field>
|
||||
<field name="email_from">${user.email or ''}</field>
|
||||
<field name="subject">${object.company_id.name} Followup</field>
|
||||
<field name="subject">${object.company_id.name} Payments Follow-up</field>
|
||||
<field name="email_to">${object.email}</field>
|
||||
<field name="lang">${object.lang}</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
@@ -27,43 +27,58 @@ Best Regards,
|
||||
<br/>
|
||||
Best Regards,
|
||||
|
||||
<br/>
|
||||
${user.name}
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<table width=80%>
|
||||
|
||||
<tr>
|
||||
<td>Invoice date</td>
|
||||
<td>Reference</td>
|
||||
<td>Maturity date</td>
|
||||
<td>Due date</td>
|
||||
<td>Amount</td>
|
||||
<td>Lit.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
% for aml in object.accountmoveline_ids :
|
||||
|
||||
<%
|
||||
amls = object.accountmoveline_ids
|
||||
mel = {}
|
||||
for aml in amls:
|
||||
strbegin = "<TD> "
|
||||
strend = "</TD> "
|
||||
date = False
|
||||
if aml.date_maturity:
|
||||
date = aml.date_maturity
|
||||
if aml.date_maturity <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
if aml.date <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
strbegin = "<TD>"
|
||||
strend = "</TD>"
|
||||
date = aml.date
|
||||
block = " "
|
||||
if aml.blocked:
|
||||
block = "X"
|
||||
mel[aml.id] = strbegin + str(aml.date) + strend + strbegin + aml.ref + strend + strbegin + str(date) + strend + strbegin + str(aml.result) + strend + strbegin + block + strend
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
${aml.date}
|
||||
</td>
|
||||
<td>
|
||||
${aml.ref}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.date_maturity:
|
||||
${aml.date_maturity}
|
||||
% else:
|
||||
${aml.date}
|
||||
% endif
|
||||
</td>
|
||||
<td>
|
||||
${aml.debit}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.blocked:
|
||||
X
|
||||
% endif
|
||||
</td>
|
||||
</tr>
|
||||
% for aml in amls:
|
||||
<tr>
|
||||
${mel[aml.id]}
|
||||
</tr>
|
||||
% endfor
|
||||
</table>
|
||||
|
||||
|
||||
</table>
|
||||
<center>Total overdue amount: ${object.payment_amount_overdue} </center>
|
||||
<br/>
|
||||
</div>
|
||||
]]></field>
|
||||
@@ -75,7 +90,7 @@ ${aml.debit}
|
||||
<record id="email_template_account_followup_level1" model="email.template">
|
||||
<field name="name">Followup of overdue invoices level 1</field>
|
||||
<field name="email_from">${user.email or ''}</field>
|
||||
<field name="subject">${object.company_id.name} Followup</field>
|
||||
<field name="subject">${object.company_id.name} Payments Follow-up</field>
|
||||
<field name="email_to">${object.email}</field>
|
||||
<field name="lang">${object.lang}</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
@@ -96,44 +111,58 @@ Details of due payments is printed below.
|
||||
<br/>
|
||||
Best Regards,
|
||||
|
||||
<br/>
|
||||
${user.name}
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<table width=80%>
|
||||
|
||||
<tr>
|
||||
<td>Invoice date</td>
|
||||
<td>Reference</td>
|
||||
<td>Maturity date</td>
|
||||
<td>Due date</td>
|
||||
<td>Amount</td>
|
||||
<td>Lit.</td>
|
||||
</tr>
|
||||
|
||||
% for aml in object.accountmoveline_ids :
|
||||
|
||||
<%
|
||||
amls = object.accountmoveline_ids
|
||||
mel = {}
|
||||
for aml in amls:
|
||||
strbegin = "<TD> "
|
||||
strend = "</TD> "
|
||||
date = False
|
||||
if aml.date_maturity:
|
||||
date = aml.date_maturity
|
||||
if aml.date_maturity <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
if aml.date <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
strbegin = "<TD>"
|
||||
strend = "</TD>"
|
||||
date = aml.date
|
||||
block = " "
|
||||
if aml.blocked:
|
||||
block = "X"
|
||||
mel[aml.id] = strbegin + str(aml.date) + strend + strbegin + aml.ref + strend + strbegin + str(date) + strend + strbegin + str(aml.result) + strend + strbegin + block + strend
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
${aml.date}
|
||||
</td>
|
||||
<td>
|
||||
${aml.ref}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.date_maturity:
|
||||
${aml.date_maturity}
|
||||
% else:
|
||||
${aml.date}
|
||||
% endif
|
||||
</td>
|
||||
<td>
|
||||
${aml.debit}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.blocked:
|
||||
X
|
||||
% endif
|
||||
</td>
|
||||
</tr>
|
||||
% for aml in amls:
|
||||
<tr>
|
||||
${mel[aml.id]}
|
||||
</tr>
|
||||
% endfor
|
||||
</table>
|
||||
|
||||
|
||||
</table>
|
||||
<center>Total overdue amount: ${object.payment_amount_overdue} </center>
|
||||
<br/>
|
||||
</div>
|
||||
]]></field>
|
||||
@@ -142,7 +171,7 @@ ${aml.debit}
|
||||
<record id="email_template_account_followup_level2" model="email.template">
|
||||
<field name="name">Followup of overdue invoices level 2</field>
|
||||
<field name="email_from">${user.email or ''}</field>
|
||||
<field name="subject">${object.company_id.name} Followup</field>
|
||||
<field name="subject">${object.company_id.name} Payments Follow-up</field>
|
||||
<field name="email_to">${object.email}</field>
|
||||
<field name="lang">${object.lang}</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
@@ -161,44 +190,59 @@ In case of any queries concerning this matter, do not hesitate to contact our ac
|
||||
<br/>
|
||||
Best Regards,
|
||||
|
||||
<br/>
|
||||
${user.name}
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<table width=80%>
|
||||
|
||||
<tr>
|
||||
<td>Invoice date</td>
|
||||
<td>Reference</td>
|
||||
<td>Maturity date</td>
|
||||
<td>Due date</td>
|
||||
<td>Amount</td>
|
||||
<td>Lit.</td>
|
||||
</tr>
|
||||
|
||||
% for aml in object.accountmoveline_ids :
|
||||
|
||||
<%
|
||||
amls = object.accountmoveline_ids
|
||||
mel = {}
|
||||
for aml in amls:
|
||||
strbegin = "<TD> "
|
||||
strend = "</TD> "
|
||||
date = False
|
||||
if aml.date_maturity:
|
||||
date = aml.date_maturity
|
||||
if aml.date_maturity <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
if aml.date <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
strbegin = "<TD>"
|
||||
strend = "</TD>"
|
||||
date = aml.date
|
||||
block = " "
|
||||
if aml.blocked:
|
||||
block = "X"
|
||||
mel[aml.id] = strbegin + str(aml.date) + strend + strbegin + aml.ref + strend + strbegin + str(date) + strend + strbegin + str(aml.result) + strend + strbegin + block + strend
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
${aml.date}
|
||||
</td>
|
||||
<td>
|
||||
${aml.ref}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.date_maturity:
|
||||
${aml.date_maturity}
|
||||
% else:
|
||||
${aml.date}
|
||||
% endif
|
||||
</td>
|
||||
<td>
|
||||
${aml.debit}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.blocked:
|
||||
X
|
||||
% endif
|
||||
</td>
|
||||
</tr>
|
||||
% for aml in amls:
|
||||
<tr>
|
||||
${mel[aml.id]}
|
||||
</tr>
|
||||
% endfor
|
||||
</table>
|
||||
|
||||
|
||||
</table>
|
||||
<center>Total overdue amount: ${object.payment_amount_overdue} </center>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
]]></field>
|
||||
@@ -229,46 +273,57 @@ Best Regards,
|
||||
Best Regards,
|
||||
</br>
|
||||
</br>
|
||||
{$user.name}
|
||||
<p>
|
||||
<br/>
|
||||
${user.name}
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<table width=80%>
|
||||
|
||||
<tr>
|
||||
<td>Invoice date</td>
|
||||
<td>Reference</td>
|
||||
<td>Maturity date</td>
|
||||
<td>Due date</td>
|
||||
<td>Amount</td>
|
||||
<td>Lit.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
% for aml in object.accountmoveline_ids :
|
||||
|
||||
<%
|
||||
amls = object.accountmoveline_ids
|
||||
mel = {}
|
||||
for aml in amls:
|
||||
strbegin = "<TD> "
|
||||
strend = "</TD> "
|
||||
date = False
|
||||
if aml.date_maturity:
|
||||
date = aml.date_maturity
|
||||
if aml.date_maturity <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
if aml.date <= ctx['current_date'] and aml.debit > 0:
|
||||
strbegin = "<TD><B>"
|
||||
strend = "</B></TD>"
|
||||
else:
|
||||
strbegin = "<TD>"
|
||||
strend = "</TD>"
|
||||
date = aml.date
|
||||
block = " "
|
||||
if aml.blocked:
|
||||
block = "X"
|
||||
mel[aml.id] = strbegin + str(aml.date) + strend + strbegin + aml.ref + strend + strbegin + str(date) + strend + strbegin + str(aml.result) + strend + strbegin + block + strend
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
${aml.date}
|
||||
</td>
|
||||
<td>
|
||||
${aml.ref}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.date_maturity:
|
||||
${aml.date_maturity}
|
||||
% else:
|
||||
${aml.date}
|
||||
% endif
|
||||
</td>
|
||||
<td>
|
||||
${aml.debit}
|
||||
</td>
|
||||
<td>
|
||||
% if aml.blocked:
|
||||
X
|
||||
% endif
|
||||
</td>
|
||||
</tr>
|
||||
% for aml in amls:
|
||||
<tr>
|
||||
${mel[aml.id]}
|
||||
</tr>
|
||||
% endfor
|
||||
|
||||
</table>
|
||||
</p>
|
||||
<center>Total overdue amount: ${object.payment_amount_overdue} </center>
|
||||
<br/>
|
||||
</div>
|
||||
]]></field>
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
</record>
|
||||
|
||||
<record id="demo_followup_line1" model="account_followup.followup.line">
|
||||
<field name="name">Level 0 : 15 net days</field>
|
||||
<field name="name">Level 0 : 15 days</field>
|
||||
<field name="sequence">0</field>
|
||||
<field name="start">days</field>
|
||||
<field name="delay">15</field>
|
||||
<field name="followup_id" ref="demo_followup1"/>
|
||||
<field name="description">
|
||||
@@ -27,9 +26,8 @@ Best Regards,
|
||||
</record>
|
||||
|
||||
<record id="demo_followup_line2" model="account_followup.followup.line">
|
||||
<field name="name">Level 1 : 30 net days</field>
|
||||
<field name="name">Level 1 : 30 days</field>
|
||||
<field name="sequence">1</field>
|
||||
<field name="start">days</field>
|
||||
<field name="delay">30</field>
|
||||
<field name="followup_id" ref="demo_followup1"/>
|
||||
<field name="email_template_id" ref="email_template_account_followup_level1"/>
|
||||
@@ -50,9 +48,8 @@ Best Regards,
|
||||
</record>
|
||||
|
||||
<record id="demo_followup_line3" model="account_followup.followup.line">
|
||||
<field name="name">Level 2 : 45 days end of month</field>
|
||||
<field name="name">Level 2 : 45 days</field>
|
||||
<field name="sequence">2</field>
|
||||
<field name="start">end_of_month</field>
|
||||
<field name="delay">45</field>
|
||||
<field name="followup_id" ref="demo_followup1"/>
|
||||
<field name="email_template_id" ref="email_template_account_followup_level2"/>
|
||||
|
||||
@@ -29,15 +29,16 @@
|
||||
</div>
|
||||
</group>
|
||||
<div class="oe_grey">
|
||||
<label string="The actions checked below will be executed when running the wizard, the actions of the previous level were done and the current date is greater than or equal to the due date of an invoice + the amount of days above. The action will be done at most once for every overdue invoice. "/>
|
||||
<label string="When the follow-up sending wizard is run, for every partner the most overdue invoice is checked. If the amount of days overdue is greater or equal than the amount of days specified above
|
||||
and the actions of the previous follow-up level were done, then the actions checked below will be executed. "/>
|
||||
</div>
|
||||
<separator string="Processing actions"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="send_letter"/>
|
||||
<field name="phonecall"/>
|
||||
<field name="manual_action" attrs="{'invisible': [('phonecall', '=', False)]}"/>
|
||||
<field name="action_responsible" attrs="{'invisible': [('phonecall', '=', False)]}"/>
|
||||
<field name="manual_action"/>
|
||||
<field name="manual_action_note" attrs="{'invisible': [('manual_action', '=', False)]}"/>
|
||||
<field name="manual_action_responsible_id" attrs="{'invisible': [('manual_action', '=', False)]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="send_email"/>
|
||||
@@ -137,7 +138,6 @@
|
||||
<field name="followup_date"/>
|
||||
<field name="debit" sum="Total debit"/>
|
||||
<field name="credit" sum="Total credit"/>
|
||||
|
||||
<field name="state"/>
|
||||
<field name="date_maturity"/>
|
||||
</tree>
|
||||
|
||||
@@ -127,13 +127,13 @@ class account_followup_print(osv.osv_memory):
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
partner_ids_to_print = []
|
||||
for partner in self.pool.get('account_followup.stat.by.partner').browse(cr, uid, partner_ids, context=context):
|
||||
if partner.max_followup_id.phonecall:
|
||||
partner_obj.do_partner_phonecall(cr, uid, [partner.partner_id.id], context)
|
||||
if partner.max_followup_id.manual_action:
|
||||
partner_obj.do_partner_manual_action(cr, uid, [partner.partner_id.id], context)
|
||||
if partner.max_followup_id.send_email:
|
||||
partner_obj.do_partner_mail(cr, uid, [partner.partner_id.id], context)
|
||||
if partner.max_followup_id.send_letter:
|
||||
partner_ids_to_print.append(partner.id)
|
||||
partner_obj.message_post(cr, uid, [partner.partner_id.id], body="Follow-up letter will be sent", context=context)
|
||||
partner_obj.message_post(cr, uid, [partner.partner_id.id], body=_("Follow-up letter will be sent"), context=context)
|
||||
action = partner_obj.do_partner_print(cr, uid, partner_ids_to_print, data, context)
|
||||
return action or {}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class email_template(osv.osv):
|
||||
if res_id:
|
||||
record = self.pool.get(model).browse(cr, uid, res_id, context=context)
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
context['current_date'] = fields.date.context_today(cr, uid, context) #change by inheritance
|
||||
|
||||
result = MakoTemplate(template).render_unicode(object=record,
|
||||
user=user,
|
||||
# context kw would clash with mako internals
|
||||
|
||||
Reference in New Issue
Block a user