[ADD] Account_followup: Print followup wizard => OSV Memory
bzr revid: mra@tinyerp.com-20100429044902-8f2me21dgyqjfgmr
This commit is contained in:
parent
ff1e0be0e1
commit
cd55a71c25
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/wizard_view.xml',
|
||||
'wizard/account_followup_print_view.xml',
|
||||
'followup_report_view.xml',
|
||||
'followup_view.xml',
|
||||
'followup_data.xml'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -41,7 +41,7 @@ class report_rappel(report_sxw.rml_parse):
|
|||
pool = pooler.get_pool(self.cr.dbname)
|
||||
all_partners = []
|
||||
for partner in partners_ids:
|
||||
partners = pool.get('account_followup.stat').browse(self.cr, self.uid, partner[2])
|
||||
partners = pool.get('account_followup.stat').browse(self.cr, self.uid, [partner])
|
||||
for par in partners:
|
||||
all_partners.append(par.name)
|
||||
return all_partners
|
||||
|
@ -88,6 +88,7 @@ class report_rappel(report_sxw.rml_parse):
|
|||
'company_name': fp_obj.browse(self.cr, self.uid, followup_id).company_id.name,
|
||||
'user_signature': pooler.get_pool(self.cr.dbname).get('res.users').browse(self.cr, self.uid, self.uid, context).signature,
|
||||
}
|
||||
|
||||
return text
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,11 +15,10 @@
|
|||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard_followup_print
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
import account_followup_print
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -18,209 +18,99 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import datetime
|
||||
import pooler
|
||||
import time
|
||||
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
_email_summary_form = """<?xml version="1.0"?>
|
||||
<form string="Summary">
|
||||
<field name="summary" height="300" width="800"/>
|
||||
</form>"""
|
||||
|
||||
_email_summary_fields = {
|
||||
'summary': {'string': 'Summary', 'type': 'text', 'required': False, 'readonly': True},
|
||||
}
|
||||
|
||||
_followup_wizard_screen1_form = """<?xml version="1.0"?>
|
||||
<form string="Follow-up and Date Selection">
|
||||
<field name="followup_id"/>
|
||||
<field name="date"/>
|
||||
</form>"""
|
||||
|
||||
_followup_wizard_screen1_fields = {
|
||||
'date': {'string': 'Follow-up Sending Date', 'type': 'date', 'required': True, 'help':"This field allow you to select a forecast date to plan your follow-ups"},
|
||||
'followup_id': {'string': 'Follow-up', 'type':'many2one', 'relation':'account_followup.followup', 'required': True,},
|
||||
}
|
||||
|
||||
|
||||
|
||||
_followup_wizard_all_form = """<?xml version="1.0"?>
|
||||
<form string="Select partners" colspan="4">
|
||||
<notebook>
|
||||
<page string="Partner Selection">
|
||||
<separator string="Select partners to remind" colspan="4"/>
|
||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Email Settings">
|
||||
<field name="email_conf" colspan="4"/>
|
||||
<field name="partner_lang" colspan="4"/>
|
||||
<field name="email_subject" colspan="4"/>
|
||||
<separator string="Email body" colspan="4" attrs="{'readonly':[('partner_lang','=',True)]}"/>
|
||||
<field name="email_body" colspan="4" nolabel="1"/>
|
||||
<separator string="Legend" colspan="4"/>
|
||||
|
||||
<label string="%(partner_name)s: Partner name" colspan="2"/>
|
||||
<label string="%(user_signature)s: User name" colspan="2"/>
|
||||
<label string="%(followup_amount)s: Total Amount Due" colspan="2"/>
|
||||
<label string="%(date)s: Current Date" colspan="2"/>
|
||||
<label string="%(company_name)s: User's Company name" colspan="2"/>
|
||||
<label string="%(company_currency)s: User's Company Currency" colspan="2"/>
|
||||
<label string="%(heading)s: Move line header" colspan="2"/>
|
||||
<label string="%(line)s: Ledger Posting lines" colspan="2"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>"""
|
||||
|
||||
_followup_wizard_all_fields = {
|
||||
'partner_ids': {
|
||||
'string': "Partners",
|
||||
'type': 'many2many',
|
||||
'required': True,
|
||||
'relation': 'account_followup.stat',
|
||||
},
|
||||
'email_conf': {
|
||||
'string': "Send email confirmation",
|
||||
'type': 'boolean',
|
||||
},
|
||||
'email_subject' : {
|
||||
'string' : "Email Subject",
|
||||
'type' : "char",
|
||||
'size': 64,
|
||||
'default': 'Invoices Reminder'
|
||||
},
|
||||
'partner_lang':{
|
||||
'string': "Send Email in Partner Language",
|
||||
'type': 'boolean',
|
||||
'default':True,
|
||||
'help':'Do not change message text, if you want to send email in partner language, or configre from company'
|
||||
},
|
||||
'email_body': {
|
||||
'string': "Email body",
|
||||
'type': 'text',
|
||||
'default': '''
|
||||
Date : %(date)s
|
||||
|
||||
Dear %(partner_name)s,
|
||||
|
||||
Please find in attachment a reminder of all your unpaid invoices, for a total amount due of:
|
||||
|
||||
%(followup_amount).2f %(company_currency)s
|
||||
|
||||
|
||||
Thanks,
|
||||
--
|
||||
%(user_signature)s
|
||||
%(company_name)s
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
class followup_all_print(wizard.interface):
|
||||
def _update_partners(self, cr, uid, data, context):
|
||||
to_update = data['form']['to_update']
|
||||
for id in to_update.keys():
|
||||
if to_update[id]['partner_id'] in data['form']['partner_ids'][0][2]:
|
||||
cr.execute(
|
||||
"UPDATE account_move_line "\
|
||||
"SET followup_line_id=%s, followup_date=%s "\
|
||||
"WHERE id=%s",
|
||||
(to_update[id]['level'],
|
||||
data['form']['date'], int(id),))
|
||||
return {}
|
||||
|
||||
def _sendmail(self ,cr, uid, data, context):
|
||||
if data['form']['email_conf']:
|
||||
mail_notsent = ''
|
||||
msg_sent = ''
|
||||
msg_unsent = ''
|
||||
count = 0
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
data_user = pool.get('res.users').browse(cr,uid,uid)
|
||||
line_obj = pool.get('account_followup.stat')
|
||||
move_lines = line_obj.browse(cr,uid,data['form']['partner_ids'][0][2])
|
||||
partners = []
|
||||
dict_lines = {}
|
||||
for line in move_lines:
|
||||
partners.append(line.name)
|
||||
dict_lines[line.name.id] =line
|
||||
for partner in partners:
|
||||
ids_lines = pool.get('account.move.line').search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable'])])
|
||||
data_lines = pool.get('account.move.line').browse(cr,uid,ids_lines)
|
||||
followup_data = dict_lines[partner.id]
|
||||
dest = False
|
||||
if partner.address:
|
||||
for adr in partner.address:
|
||||
if adr.type=='contact':
|
||||
if adr.email:
|
||||
dest = [adr.email]
|
||||
if (not dest) and adr.type=='default':
|
||||
if adr.email:
|
||||
dest = [adr.email]
|
||||
src = tools.config.options['email_from']
|
||||
if not data['form']['partner_lang']:
|
||||
body = data['form']['email_body']
|
||||
else:
|
||||
cxt = context.copy()
|
||||
cxt['lang'] = partner.lang
|
||||
body = pool.get('res.users').browse(cr, uid, uid, context=cxt).company_id.follow_up_msg
|
||||
|
||||
total_amt = followup_data.debit - followup_data.credit
|
||||
move_line = ''
|
||||
subtotal_due = 0.0
|
||||
subtotal_paid = 0.0
|
||||
subtotal_maturity = 0.0
|
||||
balance = 0.0
|
||||
l = '--------------------------------------------------------------------------------------------------------------------------'
|
||||
head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Maturity date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
|
||||
for i in data_lines:
|
||||
maturity = 0.00
|
||||
if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
|
||||
maturity = i.debit - i.credit
|
||||
subtotal_due = subtotal_due + i.debit
|
||||
subtotal_paid = subtotal_paid + i.credit
|
||||
subtotal_maturity = subtotal_maturity + int(maturity)
|
||||
balance = balance + (i.debit - i.credit)
|
||||
move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
|
||||
move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
|
||||
move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
|
||||
val = {
|
||||
'partner_name':partner.name,
|
||||
'followup_amount':total_amt,
|
||||
'user_signature':data_user.name,
|
||||
'company_name':data_user.company_id.name,
|
||||
'company_currency':data_user.company_id.currency_id.name,
|
||||
'line':move_line,
|
||||
'heading': head,
|
||||
'date':time.strftime('%Y-%m-%d'),
|
||||
class account_followup_print(osv.osv_memory):
|
||||
_name = 'account.followup.print'
|
||||
_description = 'Print Followup & Send Mail to Customers'
|
||||
_columns = {
|
||||
'date': fields.date('Follow-up Sending Date', required=True, help="This field allow you to select a forecast date to plan your follow-ups"),
|
||||
'followup_id': fields.many2one('account_followup.followup', 'Follow-up', required=True)
|
||||
}
|
||||
body = body%val
|
||||
sub = tools.ustr(data['form']['email_subject'])
|
||||
msg = ''
|
||||
if dest:
|
||||
tools.email_send(src,dest,sub,body)
|
||||
msg_sent += partner.name + '\n'
|
||||
else:
|
||||
msg += partner.name + '\n'
|
||||
msg_unsent += msg
|
||||
if not msg_unsent:
|
||||
summary = _("All E-mails have been successfully sent to Partners:.\n\n") + msg_sent
|
||||
else:
|
||||
msg_unsent = _("E-Mail not sent to following Partners, Email not available !\n\n") + msg_unsent
|
||||
msg_sent = msg_sent and _("\n\nE-Mail sent to following Partners successfully. !\n\n") + msg_sent
|
||||
line = '=========================================================================='
|
||||
summary = msg_unsent + line + msg_sent
|
||||
return {'summary' : summary}
|
||||
else:
|
||||
return {'summary' : '\n\n\nE-Mail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'}
|
||||
|
||||
def _get_partners(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
def _get_followup(self, cr, uid, context=None):
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
tmp = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)])
|
||||
return tmp and tmp[0] or False
|
||||
|
||||
def do_continue(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
context.update({'followup_id': data['followup_id'], 'date':data['date']})
|
||||
return {
|
||||
'name': _('Select partners'),
|
||||
'view_type': 'form',
|
||||
'context': context,
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.followup.print.all',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'followup_id': _get_followup,
|
||||
}
|
||||
|
||||
account_followup_print()
|
||||
|
||||
class account_followup_print_all(osv.osv_memory):
|
||||
_name = 'account.followup.print.all'
|
||||
_description = 'Print Followup & Send Mail to Customers'
|
||||
_columns = {
|
||||
'partner_ids': fields.many2many('account_followup.stat', 'partner_stat_rel', 'followup_id', 'stat_id', 'Partners', required=True),
|
||||
'email_conf': fields.boolean('Send email confirmation'),
|
||||
'email_subject': fields.char('Email Subject', size=64),
|
||||
'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configre from company'),
|
||||
'email_body': fields.text('Email body'),
|
||||
'summary': fields.text('Summary', required=True, readonly=True)
|
||||
}
|
||||
def _get_summary(self, cr, uid, context=None):
|
||||
return context.get('summary', '')
|
||||
|
||||
def _get_partners(self, cr, uid, context=None):
|
||||
return self._get_partners_followp(cr, uid, [], context)['partner_ids']
|
||||
|
||||
def _get_msg(self, cr, uid, context=None):
|
||||
return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg
|
||||
|
||||
_defaults = {
|
||||
'email_body': _get_msg,
|
||||
'email_subject': 'Invoices Reminder',
|
||||
'partner_lang': True,
|
||||
'partner_ids': _get_partners,
|
||||
'summary': _get_summary,
|
||||
# 'email_body':'''
|
||||
#Date : %(date)s
|
||||
#
|
||||
#Dear %(partner_name)s,
|
||||
#
|
||||
#Please find in attachment a reminder of all your unpaid invoices, for a total amount due of:
|
||||
#
|
||||
#%(followup_amount).2f %(company_currency)s
|
||||
#
|
||||
#
|
||||
#Thanks,
|
||||
#--
|
||||
#%(user_signature)s
|
||||
#%(company_name)s
|
||||
# '''
|
||||
}
|
||||
|
||||
def _get_partners_followp(self, cr, uid, ids, context=None):
|
||||
data = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
if ids:
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
cr.execute(
|
||||
"SELECT l.partner_id, l.followup_line_id,l.date_maturity, l.date, l.id "\
|
||||
"FROM account_move_line AS l "\
|
||||
|
@ -235,9 +125,10 @@ class followup_all_print(wizard.interface):
|
|||
move_lines = cr.fetchall()
|
||||
old = None
|
||||
fups = {}
|
||||
fup_id = data['form']['followup_id']
|
||||
fup_id = 'followup_id' in context and context['followup_id'] or data['followup_id']
|
||||
date = 'date' in context and context['date'] or data['date']
|
||||
|
||||
current_date = datetime.date(*time.strptime(data['form']['date'],
|
||||
current_date = datetime.date(*time.strptime(date,
|
||||
'%Y-%m-%d')[:3])
|
||||
cr.execute(
|
||||
"SELECT * "\
|
||||
|
@ -269,59 +160,138 @@ class followup_all_print(wizard.interface):
|
|||
if partner_id not in partner_list:
|
||||
partner_list.append(partner_id)
|
||||
to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': partner_id}
|
||||
|
||||
message = pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg
|
||||
|
||||
return {'partner_ids': partner_list, 'to_update': to_update, 'email_body':message}
|
||||
return {'partner_ids': partner_list, 'to_update': to_update}
|
||||
|
||||
def _get_screen1_values(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
company_id = pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
tmp = pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)])
|
||||
followup = tmp and tmp[0] or False
|
||||
return {'date': time.strftime('%Y-%m-%d'), 'followup_id': followup}
|
||||
def do_mail(self ,cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
move_obj = self.pool.get('account.move.line')
|
||||
user_obj = self.pool.get('res.users')
|
||||
line_obj = self.pool.get('account_followup.stat')
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_screen1_values],
|
||||
'result': {'type': 'form',
|
||||
'arch': _followup_wizard_screen1_form,
|
||||
'fields': _followup_wizard_screen1_fields,
|
||||
'state': [
|
||||
('end', 'Cancel'),
|
||||
('next', 'Continue'),
|
||||
]
|
||||
},
|
||||
},
|
||||
'next': {
|
||||
'actions': [_get_partners],
|
||||
'result': {'type': 'form',
|
||||
'arch': _followup_wizard_all_form,
|
||||
'fields': _followup_wizard_all_fields,
|
||||
'state': [
|
||||
('end','Cancel'),
|
||||
('print','Print Follow Ups & Send Mails'),
|
||||
]
|
||||
},
|
||||
},
|
||||
'print': {
|
||||
'actions': [_update_partners],
|
||||
'result': {'type': 'print',
|
||||
'report':'account_followup.followup.print',
|
||||
'state':'summary'},
|
||||
},
|
||||
'summary': {
|
||||
'actions': [_sendmail],
|
||||
'result': {'type': 'form',
|
||||
'arch': _email_summary_form,
|
||||
'fields': _email_summary_fields,
|
||||
'state':[('end','Ok')]
|
||||
},
|
||||
},
|
||||
}
|
||||
if data['email_conf']:
|
||||
mail_notsent = ''
|
||||
msg_sent = ''
|
||||
msg_unsent = ''
|
||||
count = 0
|
||||
data_user = user_obj.browse(cr, uid, uid)
|
||||
move_lines = line_obj.browse(cr,uid,data['partner_ids'][0][2])
|
||||
partners = []
|
||||
dict_lines = {}
|
||||
for line in move_lines:
|
||||
partners.append(line.name)
|
||||
dict_lines[line.name.id] =line
|
||||
for partner in partners:
|
||||
ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable'])])
|
||||
data_lines = move_obj.browse(cr,uid,ids_lines)
|
||||
followup_data = dict_lines[partner.id]
|
||||
dest = False
|
||||
if partner.address:
|
||||
for adr in partner.address:
|
||||
if adr.type=='contact':
|
||||
if adr.email:
|
||||
dest = [adr.email]
|
||||
if (not dest) and adr.type=='default':
|
||||
if adr.email:
|
||||
dest = [adr.email]
|
||||
src = tools.config.options['email_from']
|
||||
if not data['partner_lang']:
|
||||
body = data['email_body']
|
||||
else:
|
||||
cxt = context.copy()
|
||||
cxt['lang'] = partner.lang
|
||||
body = user_obj.browse(cr, uid, uid, context=cxt).company_id.follow_up_msg
|
||||
|
||||
followup_all_print('account_followup.followup.print.all')
|
||||
total_amt = followup_data.debit - followup_data.credit
|
||||
move_line = ''
|
||||
subtotal_due = 0.0
|
||||
subtotal_paid = 0.0
|
||||
subtotal_maturity = 0.0
|
||||
balance = 0.0
|
||||
l = '--------------------------------------------------------------------------------------------------------------------------'
|
||||
head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Maturity date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
|
||||
for i in data_lines:
|
||||
maturity = 0.00
|
||||
if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
|
||||
maturity = i.debit - i.credit
|
||||
subtotal_due = subtotal_due + i.debit
|
||||
subtotal_paid = subtotal_paid + i.credit
|
||||
subtotal_maturity = subtotal_maturity + int(maturity)
|
||||
balance = balance + (i.debit - i.credit)
|
||||
move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
|
||||
move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
|
||||
move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
|
||||
val = {
|
||||
'partner_name':partner.name,
|
||||
'followup_amount':total_amt,
|
||||
'user_signature':data_user.name,
|
||||
'company_name':data_user.company_id.name,
|
||||
'company_currency':data_user.company_id.currency_id.name,
|
||||
'line':move_line,
|
||||
'heading': head,
|
||||
'date':time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
body = body%val
|
||||
sub = tools.ustr(data['email_subject'])
|
||||
msg = ''
|
||||
if dest:
|
||||
tools.email_send(src,dest,sub,body)
|
||||
msg_sent += partner.name + '\n'
|
||||
else:
|
||||
msg += partner.name + '\n'
|
||||
msg_unsent += msg
|
||||
if not msg_unsent:
|
||||
summary = _("All E-mails have been successfully sent to Partners:.\n\n") + msg_sent
|
||||
else:
|
||||
msg_unsent = _("E-Mail not sent to following Partners, Email not available !\n\n") + msg_unsent
|
||||
msg_sent = msg_sent and _("\n\nE-Mail sent to following Partners successfully. !\n\n") + msg_sent
|
||||
line = '=========================================================================='
|
||||
summary = msg_unsent + line + msg_sent
|
||||
context.update({'summary': summary})
|
||||
else:
|
||||
context.update({'summary': '\n\n\nE-Mail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'})
|
||||
return {
|
||||
'name': _('Summary'),
|
||||
'view_type': 'form',
|
||||
'context': context,
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.followup.print.all',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'nodestroy': True
|
||||
}
|
||||
|
||||
def do_print(self, cr, uid, ids, context=None):
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
res = self._get_partners_followp(cr, uid, ids, context)['to_update']
|
||||
to_update = res
|
||||
data['followup_id'] = 'followup_id' in context and context['followup_id'] or False
|
||||
date = 'date' in context and context['date'] or data['date']
|
||||
for id in to_update.keys():
|
||||
if to_update[id]['partner_id'] in data['partner_ids'][0][2]:
|
||||
cr.execute(
|
||||
"UPDATE account_move_line "\
|
||||
"SET followup_line_id=%s, followup_date=%s "\
|
||||
"WHERE id=%s",
|
||||
(to_update[id]['level'],
|
||||
date, int(id),))
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
datas = {
|
||||
'ids': [],
|
||||
'model': 'account_followup.followup',
|
||||
'form': data
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account_followup.followup.print',
|
||||
'datas': datas,
|
||||
'nodestroy': True
|
||||
}
|
||||
|
||||
account_followup_print_all()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,132 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
|
||||
<!--<wizard string="Send followups"
|
||||
name="account_followup.followup.print.all"
|
||||
id="action_account_followup_all_wizard"
|
||||
model="account_followup.followup" />
|
||||
|
||||
<menuitem action="action_account_followup_all_wizard"
|
||||
id="account_followup_wizard_menu"
|
||||
parent="account.menu_finance_periodical_processing"
|
||||
type="wizard" />-->
|
||||
|
||||
|
||||
<record id="view_account_followup_print" model="ir.ui.view">
|
||||
<field name="name">account.followup.print.form</field>
|
||||
<field name="model">account.followup.print</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send followups">
|
||||
<group col="4" colspan="6">
|
||||
<field name="followup_id"/>
|
||||
<field name="date"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="do_continue" string="Continue" colspan="1" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_followup_print" model="ir.actions.act_window">
|
||||
<field name="name">Send followups</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.followup.print</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="account_followup_print_values">
|
||||
<field name="model_id" ref="model_account_followup_followup" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Send followups</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_followup_print'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account_followup.followup</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_account_followup_print"
|
||||
id="account_followup_print_menu"
|
||||
parent="account.menu_finance_periodical_processing"
|
||||
/>
|
||||
|
||||
|
||||
<!-- Screen2 -->
|
||||
|
||||
<record id="view_account_followup_print_all" model="ir.ui.view">
|
||||
<field name="name">account.followup.print.all.form</field>
|
||||
<field name="model">account.followup.print.all</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send followups">
|
||||
<group col="4" colspan="6">
|
||||
<notebook>
|
||||
<page string="Partner Selection">
|
||||
<separator string="Select partners to remind" colspan="4"/>
|
||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Email Settings">
|
||||
<field name="email_conf" colspan="4"/>
|
||||
<field name="partner_lang" colspan="4"/>
|
||||
<field name="email_subject" colspan="4"/>
|
||||
<!--<separator string="Email body" colspan="4" attrs="{'readonly':[('partner_lang','=',True)]}"/>-->
|
||||
<separator string="Email body" colspan="4" />
|
||||
<field name="email_body" colspan="4" nolabel="1"/>
|
||||
<separator string="Legend" colspan="4"/>
|
||||
<label string="%%(partner_name)s: Partner name" colspan="2"/>
|
||||
<label string="%%(user_signature)s: User name" colspan="2"/>
|
||||
<label string="%%(followup_amount)s: Total Amount Due" colspan="2"/>
|
||||
<label string="%%(date)s: Current Date" colspan="2"/>
|
||||
<label string="%%(company_name)s: User's Company name" colspan="2"/>
|
||||
<label string="%%(company_currency)s: User's Company Currency" colspan="2"/>
|
||||
<label string="%%(heading)s: Move line header" colspan="2"/>
|
||||
<label string="%%(line)s: Ledger Posting lines" colspan="2"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group>
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="do_print" string="Print Follow Ups" colspan="1" type="object" icon="gtk-print"/>
|
||||
<button name="do_mail" string="Send Mails" colspan="1" type="object" icon="gtk-execute"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_followup_print_all_msg" model="ir.ui.view">
|
||||
<field name="name">account.followup.print.all.msg.form</field>
|
||||
<field name="model">account.followup.print.all</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Summary">
|
||||
<group col="4" colspan="6">
|
||||
<field name="summary" height="300" width="800"/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group>
|
||||
<button special="cancel" string="Ok" icon='gtk-cancel'/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_followup_print_all" model="ir.actions.act_window">
|
||||
<field name="name">Send followups</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.followup.print.all</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><openerp><data noupdate="0">
|
||||
<wizard string="Send followups"
|
||||
name="account_followup.followup.print.all"
|
||||
id="action_account_followup_all_wizard"
|
||||
model="account_followup.followup" />
|
||||
|
||||
<menuitem action="action_account_followup_all_wizard"
|
||||
id="account_followup_wizard_menu"
|
||||
parent="account.menu_finance_periodical_processing"
|
||||
type="wizard" />
|
||||
</data></openerp>
|
||||
|
|
@ -75,8 +75,8 @@
|
|||
<field name="inherit_id" ref="project.view_task_tree2" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="remaining_hours" position="after">
|
||||
<field name="timebox_id" groups="project_gtd.group_project_getting" invisible=" not context.get('set_visible',False)"/>
|
||||
<button name="prev_timebox" type="object" icon="gtk-go-back" string="Previous" states="draft,pending,open" groups="project_gtd.group_project_getting" invisible=" not context.get('set_visible',False)"/>
|
||||
<field string="xxxxxx" name="timebox_id" groups="project_gtd.group_project_getting" invisible=" not context.get('set_visible',True)"/>
|
||||
<button name="prev_timebox" type="object" icon="gtk-go-back" string="Previous" states="draft,pending,open" groups="project_gtd.group_project_getting" invisible=" not context.get('set_visible',True)"/>
|
||||
<button name="next_timebox" type="object" icon="gtk-go-forward" string="Next" states="draft,pending,open" groups="project_gtd.group_project_getting" invisible=" not context.get('set_visible',False)"/>
|
||||
<button name="do_reopen" states="done,cancelled" string="Reactivate" type="object" icon="gtk-convert" help="For reopening the tasks" invisible="not context.get('set_visible',False)"/>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue