[IMP] start to change field names

bzr revid: jco@openerp.com-20121107165130-qsew0m14iq11y8bg
This commit is contained in:
Josse Colpaert 2012-11-07 17:51:30 +01:00
parent c28de65268
commit 15e8d78339
5 changed files with 59 additions and 164 deletions

View File

@ -114,6 +114,14 @@ Best Regards,
followup_line()
class account_move_line(osv.osv):
def _get_result(self, cr, uid, ids, name, arg, context=None):
res = {}
for aml in self.browse(cr, uid, ids, context):
res[aml.id] = aml.debit - aml.credit
return res
_inherit = 'account.move.line'
_columns = {
'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level', ondelete='restrict'), #restrict deletion of the followup line
@ -122,6 +130,7 @@ class account_move_line(osv.osv):
'payment_date':fields.date('Date'),
#'payment_note':fields.text('Payment note'),
'payment_next_action':fields.text('New action'),
'result':fields.function(_get_result, type='float', method=True, string="Balance")
}
account_move_line()
@ -137,15 +146,14 @@ class res_partner(osv.osv):
for partner in self.browse(cr, uid, ids):
accountmovelines = partner.accountmoveline_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:
amls2 = filter(lambda a: (a.state != 'draft') and (a.debit > 0), accountmovelines)
res[partner.id] = max(x.followup_date for x in amls2) if len(amls2) else False
res[partner.id] = max([x.followup_date for x in amls]) if len(amls) else False
#else:
# res[partner.id] = False
@ -258,18 +266,18 @@ class res_partner(osv.osv):
def _get_amount(self, cr, uid, ids, name, arg, context=None):
def _get_amount_overdue(self, cr, uid, ids, name, arg, context=None):
'''
Get the total outstanding 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 due date)
'''
res={}
for partner in self.browse(cr, uid, ids, context):
res[partner.id] = 0.0
for aml in partner.accountmoveline_ids:
if ((not aml.date_maturity) and (aml.date < fields.date.context_today(cr, uid, context))) or (aml.date_maturity < fields.date.context_today(cr, uid, context)):
res[partner.id] = res[partner.id] + aml.debit
if ((not aml.date_maturity) and (aml.date <= fields.date.context_today(cr, uid, context))) or (aml.date_maturity <= fields.date.context_today(cr, uid, context)):
res[partner.id] = res[partner.id] + aml.debit - aml.credit #or by using function field
return res
def do_partner_phonecall(self, cr, uid, partner_ids, context=None):
#partners = self.browse(cr, uid, partner_ids, context)
@ -280,10 +288,9 @@ class res_partner(osv.osv):
# 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)
for partner in self.browse(cr, uid, partner_ids, context):
print "partner", partner.name
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,
'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})
def do_partner_print(self, cr, uid, partner_ids, data, context=None):
@ -311,6 +318,7 @@ class res_partner(osv.osv):
#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"
@ -323,7 +331,8 @@ class res_partner(osv.osv):
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):
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',
@ -338,10 +347,10 @@ class res_partner(osv.osv):
def do_button_mail(self, cr, uid, ids, context=None):
do_partner_mail(slf, r, uid, ids, context)
self.do_partner_mail(cr, uid, ids, context)
def get_aml_storeids(self, cr, uid, ids, context=None):
def _get_aml_storeids(self, cr, uid, ids, context=None):
partnerlist = []
for aml in self.pool.get("account.move.line").browse(cr, uid, ids, context):
if aml.partner_id not in partnerlist:
@ -351,20 +360,20 @@ class res_partner(osv.osv):
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Responsible', help="Responsible"),
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Responsible', help="Responsible for making sure the action happens."),
#'payment_followup_level_id':fields.many2one('account_followup.followup.line', 'Followup line'),
'payment_note':fields.text('Payment note', help="Payment note"),
'payment_next_action':fields.char('Next action', 50, help="Write here the comments of your customer"), #Just a note
'payment_next_action_date':fields.date('Next action date', help="Next date to take action"), # next action date
'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('debit', '>', 0.0), '&', ('reconcile_id', '=', False), '&',
'payment_note':fields.text('Payment note', help="Payment Note"),
'payment_next_action':fields.char('Next Action', 50, help="This is the next action to be taken by the user. It will automatically be set when the action fields are empty and the partner gets a follow-up level that requires a manual action. "), #Just a note
'payment_next_action_date':fields.date('Next Action Date', help="This is when further follow-up is needed. The date will have been set to the current date if the action fields are empty and the partner gets a follow-up level that requires a manual action. "), # next action date
'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', False), '&',
('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]),
'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="latest followup date", store= {'account.move.line': (get_aml_storeids, ['followup_line_id', 'followup_date'], 20)}),
'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="Latest Follow-up Date", store={'account.move.line': (_get_aml_storeids, ['followup_line_id', 'followup_date'], 20)}, help="Latest date that the follow-up level of the partner was changed" ), #
'latest_followup_level_id':fields.function(_get_latest_followup_level_id, method=True,
type='many2one', relation='account_followup.followup.line', string="Latest Followup Level", store={'account.move.line': (get_aml_storeids, ['followup_line_id', 'followup_date'], 20)}),
type='many2one', relation='account_followup.followup.line', string="Latest Follow-up Level", store={'account.move.line': (_get_aml_storeids, ['followup_line_id', 'followup_date'], 20)}, help="The maximum follow-up level"),
'latest_followup_level_id_without_lit':fields.function(_get_latest_followup_level_id_without_lit, method=True,
type='many2one', relation='account_followup.followup.line', string="Latest Followup Level without litigation"),
'next_followup_level_id':fields.function(_get_next_followup_level_id, method=True, type='many2one', relation='account_followup.followup.line', string="Next Level", help="Next level that will be printed", store={'account.move.line': (get_aml_storeids, ['followup_line_id', 'followup_date'], 20)}),
'payment_amount_outstanding':fields.function(_get_amount, method=True, type='float', string="Amount Overdue", store= {'account.move.line': (get_aml_storeids, ['debit'], 20)}),
type='many2one', relation='account_followup.followup.line', string="Latest Follow-up Level without litigation", help="The maximum follow-up level without taking into account the account move lines with litigation"),
'next_followup_level_id':fields.function(_get_next_followup_level_id, method=True, type='many2one', relation='account_followup.followup.line', string="Next Level", help="The next follow-up level to come when the customer still refuses to pay", store={'account.move.line': (_get_aml_storeids, ['followup_line_id', 'followup_date'], 20)}),
'payment_amount_overdue':fields.function(_get_amount_overdue, method=True, type='float', string="Amount Overdue", help="Amount Overdue: The amount the customer should already have paid"),
}
res_partner()

View File

@ -3,6 +3,8 @@
<!-- followup of customers views
-->
<!-- Was specific view, not used anymore -->
<record id="customer_followup_formgone" model="ir.ui.view">
<field name="name">eee</field>
@ -22,7 +24,7 @@
<field name="accountmoveline_ids" nolabel="1" > <!--domain="[('reconcile_id', '=', False)]" not necessary-->
<tree string="Account Move line" editable="bottom">
<field name="date" readonly="True"/>
<field name="move_id" readonly="True"/>
<!--<field name="move_id" readonly="True"/>-->
<field name="ref" readonly="True"/>
<field name="debit" readonly="True"/>
<field name="credit" readonly="True"/>
@ -48,15 +50,13 @@
</group>
<group>
<field name="payment_responsible_id" help="The user who takes responsibility to follow it up. "/>
<field name="payment_next_action_date" help="This is when further follow-up is needed. The date will have been set to the currrent date when processing the follow-ups asks for a phone call"/>
<field name="payment_next_action_date"/>
</group>
</group>
<separator string="Payment Followup Remarks"/>
<newline/>
<group>
<field name="payment_note"/>
<!--<field name="payment_followup_level_id"/>-->
<field name="latest_followup_level_id"/>
<field name="latest_followup_date"/>
@ -113,6 +113,9 @@
<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>
@ -140,12 +143,12 @@
<field name="model">res.partner</field>
<field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
<field name="arch" type="xml">
<sheet position="before">
<header>
<button name="do_button_print" string="Print Overdue Payments Report"/>
<button name="do_button_mail" string="Send Overdue Email"/>
</header>
</sheet>
<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"/>
</div>
<page string="Accounting" position="before" version="7.0">
<page string="Payments Follow-up" position="inside">
@ -166,6 +169,7 @@
<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"/>-->
@ -178,15 +182,16 @@
<tree string="Account Move line" editable="bottom" colors="red:date_maturity and date_maturity&lt;current_date or date&lt;current_date"> <!---->
<field name="date" readonly="True"/>
<field name="move_id" readonly="True"/>
<field name="ref" readonly="True"/>
<field name="debit" readonly="True"/>
<field name="credit" readonly="True"/>
<!--<field name="ref" readonly="True"/>-->
<!--<field name="debit" readonly="True"/>
<field name="credit" readonly="True"/>-->
<field name="result" readonly="True"/>
<field name="followup_date" readonly="True"/>
<field name="followup_line_id" readonly="True"/>
<!--<field name="followup_line_id" readonly="True"/>-->
<field name="blocked" string="Litigation"/>
<field name="payment_commitment"/>
<field name="payment_date"/>
<field name="date_maturity"/>
<!--<field name="payment_commitment"/>
<field name="payment_date"/>-->
<field name="date_maturity" readonly="True"/>
<!--<field name="reconcile_id" invisible="True"/>-->
<field name="reconcile_partial_id" readonly="True"/>
<!--<field name="invoice"/>-->
@ -207,66 +212,7 @@
</field>
</record>
<record id="customer_followup_form" model="ir.ui.view">
<field name="name">eee</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="inherits_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@string='Payments Follow-up']" position="replace">
<page string="Payments Follow-up" position="inside">
<group>
<group>
<field name="payment_amount_outstanding"/>
</group>
<group>
<label for="payment_next_action"/>
<div>
<field name="payment_next_action_date" nolabel="1"/> <label string="-" attrs="{'invisible': ['|', ('payment_next_action_date', '=', False), ('payment_next_action', '=', False)]}"/>
<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"/>
</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>
<group>
<field name="accountmoveline_ids" nolabel="1" > <!--domain="[('reconcile_id', '=', False)]" not necessary-->
<tree string="Account Move line" editable="bottom" colors="red:date_maturity and date_maturity&lt;current_date or date&lt;current_date"> <!---->
<field name="date" readonly="True"/>
<field name="move_id" readonly="True"/>
<field name="ref" readonly="True"/>
<field name="debit" readonly="True"/>
<field name="credit" readonly="True"/>
<field name="followup_date" readonly="True"/>
<field name="followup_line_id" readonly="True"/>
<field name="blocked" string="Litigation"/>
<field name="payment_commitment"/>
<field name="payment_date"/>
<field name="date_maturity"/>
<!--<field name="reconcile_id" invisible="True"/>-->
<field name="reconcile_partial_id" readonly="True"/>
<!--<field name="invoice"/>-->
</tree>
</field>
</group>
</page>
</xpath>
</field>
</record>
<!-- <record id="action_view_customer_followup_form" model="ir.actions.act_window.view">

View File

@ -29,7 +29,7 @@
</div>
</group>
<div class="oe_grey">
<label string="This explains the behaviour of the lines and so on"/>
<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. "/>
</div>
<separator string="Processing actions"/>
<group>

View File

@ -133,6 +133,7 @@ class account_followup_print(osv.osv_memory):
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)
action = partner_obj.do_partner_print(cr, uid, partner_ids_to_print, data, context)
return action or {}
@ -179,39 +180,6 @@ class account_followup_print(osv.osv_memory):
#'partner_ids': _get_partners,
'summary': _get_summary,
}
#account_followup_print()
#class account_followup_print_all(osv.osv_memory):
# _name = 'account.followup.print.all'
# _description = 'Print Follow-up & Send Mail to Customers'
# _columns = {
# 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_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 configure from company'),
# 'email_body': fields.text('Email Body'),
# 'summary': fields.text('Summary', required=True, readonly=True),
# 'test_print': fields.boolean('Test Print', help='Check if you want to print follow-ups without changing follow-ups level.')
# }
# def _get_summary(self, cr, uid, context=None):
# if context is None:
# context = {}
# return context.get('summary', '')
#
# def _get_partners(self, cr, uid, context=None):
# return self._get_partners_followp(cr, uid, [], context=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,
# }
def _get_partners_followp(self, cr, uid, ids, context=None):
data = {}
@ -231,7 +199,7 @@ class account_followup_print(osv.osv_memory):
"AND (l.debit > 0) "\
"AND (l.company_id = %s) " \
"AND (l.blocked = False)" \
"ORDER BY l.date", (company_id,)) #l.blocked added to take litigation into account
"ORDER BY l.date", (company_id,)) #l.blocked added to take litigation into account and it is not necessary to change follow-up level of account move lines without debit
move_lines = cr.fetchall()
old = None
fups = {}
@ -313,33 +281,4 @@ class account_followup_print(osv.osv_memory):
account_followup_print()
#jco tests
# resu = self.do_mail(cr,uid,ids,context)
# mod_obj = self.pool.get('ir.model.data')
# move_obj = self.pool.get('account.move.line')
# user_obj = self.pool.get('res.users')
# if context is None:
# context = {}
# data = self.browse(cr, uid, ids, context=context)[0]
# stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
# partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
# 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']
# print "start changeof new action..."
#
# partnersfilt = []
# partner_obj = self.pool.get('res.partner')
# for partner in partner_obj.browse(cr, uid, partners, context):
# if partner.next_followup_level_id.phonecall:
# partnersfilt.append(partner.id)
# print "Should have been changed"
# print partner.name
# partner_obj = self.pool.get('res.partner').write(cr, uid, partnersfilt, {'payment_new_action': "Take your phone and call him, please!!!"})
# resu2 = self.do_print(cr,uid,ids,context)
# return resu2
#account_followup_print_all()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -66,6 +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