2009-10-13 05:58:37 +00:00
# -*- coding: utf-8 -*-
2006-12-07 13:41:40 +00:00
##############################################################################
2010-07-03 09:30:47 +00:00
#
2009-10-14 11:15:34 +00:00
# OpenERP, Open Source Management Solution
2010-01-12 09:18:39 +00:00
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
2006-12-07 13:41:40 +00:00
#
2008-11-03 19:18:56 +00:00
# This program is free software: you can redistribute it and/or modify
2009-10-14 11:15:34 +00:00
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
2006-12-07 13:41:40 +00:00
#
2008-11-03 19:18:56 +00:00
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2009-10-14 11:15:34 +00:00
# GNU Affero General Public License for more details.
2006-12-07 13:41:40 +00:00
#
2009-10-14 11:15:34 +00:00
# You should have received a copy of the GNU Affero General Public License
2010-07-03 09:30:47 +00:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2006-12-07 13:41:40 +00:00
#
##############################################################################
from osv import fields , osv
2012-11-16 16:14:37 +00:00
from lxml import etree
2006-12-07 13:41:40 +00:00
2012-11-08 14:14:57 +00:00
from tools . translate import _
2012-11-22 08:32:24 +00:00
#TODO: context is a kwarg and thus should be used as 'context=context'
#TODO: remove trailing spaces and commented code
2006-12-07 13:41:40 +00:00
class followup ( osv . osv ) :
2008-07-22 15:11:28 +00:00
_name = ' account_followup.followup '
2012-06-27 06:28:21 +00:00
_description = ' Account Follow-up '
2012-11-15 08:16:34 +00:00
_rec_name = ' name '
2008-07-22 15:11:28 +00:00
_columns = {
2012-06-27 06:28:21 +00:00
' followup_line ' : fields . one2many ( ' account_followup.followup.line ' , ' followup_id ' , ' Follow-up ' ) ,
2012-11-21 14:49:32 +00:00
' company_id ' : fields . many2one ( ' res.company ' , ' Company ' , required = True ) ,
2012-11-15 08:16:34 +00:00
' name ' : fields . related ( ' company_id ' , ' name ' , string = " Name " ) ,
2008-07-22 15:11:28 +00:00
}
2010-07-03 09:30:47 +00:00
_defaults = {
' company_id ' : lambda s , cr , uid , c : s . pool . get ( ' res.company ' ) . _company_default_get ( cr , uid , ' account_followup.followup ' , context = c ) ,
2010-10-11 10:51:16 +00:00
}
2012-11-22 08:32:24 +00:00
_sql_constraints = [ ( ' company_uniq ' , ' unique(company_id) ' , ' Only one follow-up per company is allowed ' ) ]
2012-11-21 14:49:32 +00:00
2006-12-07 13:41:40 +00:00
followup ( )
2012-11-12 17:38:57 +00:00
2012-11-21 14:49:32 +00:00
class followup_line ( osv . osv ) :
2012-11-06 17:15:22 +00:00
def _get_default_template ( self , cr , uid , ids , context = None ) :
2012-11-22 08:32:24 +00:00
dummy , templ = self . pool . get ( ' ir.model.data ' ) . get_object_reference ( cr , uid , ' account_followup ' , ' email_template_account_followup_default ' )
return templ
2012-11-06 17:15:22 +00:00
2008-07-22 15:11:28 +00:00
_name = ' account_followup.followup.line '
2012-06-27 06:28:21 +00:00
_description = ' Follow-up Criteria '
2008-07-22 15:11:28 +00:00
_columns = {
2012-11-21 14:49:32 +00:00
' name ' : fields . char ( ' Follow-Up Action ' , size = 64 , required = True ) ,
2011-05-09 10:06:20 +00:00
' sequence ' : fields . integer ( ' Sequence ' , help = " Gives the sequence order when displaying a list of follow-up lines. " ) ,
2012-11-22 15:30:49 +00:00
' delay ' : fields . integer ( ' Due Days ' , help = " The number of days after the due date of the invoice to wait before sending the reminder. Could be negative if you want to send a polite alert beforehand. " , required = True ) ,
2008-07-22 15:11:28 +00:00
' followup_id ' : fields . many2one ( ' account_followup.followup ' , ' Follow Ups ' , required = True , ondelete = " cascade " ) ,
2009-01-28 14:43:31 +00:00
' description ' : fields . text ( ' Printed Message ' , translate = True ) ,
2012-11-21 14:49:32 +00:00
' send_email ' : fields . boolean ( ' Send an Email ' , help = " When processing, it will send an email " ) ,
' send_letter ' : fields . boolean ( ' Send a Letter ' , help = " When processing, it will print a letter " ) ,
2012-11-20 12:40:26 +00:00
' manual_action ' : fields . boolean ( ' Manual Action ' , help = " When processing, it will set the manual action to be taken for that customer. " ) ,
2012-11-21 14:49:32 +00:00
' manual_action_note ' : fields . text ( ' Action To Do ' , placeholder = " e.g. Give a phone call, check with others , ... " ) ,
' manual_action_responsible_id ' : fields . many2one ( ' res.users ' , ' Assign a Responsible ' , ondelete = ' set null ' ) ,
' email_template_id ' : fields . many2one ( ' email.template ' , ' Email Template ' , ondelete = ' set null ' ) ,
2010-10-11 10:51:16 +00:00
}
2012-11-06 17:15:22 +00:00
_order = ' delay '
2012-11-22 15:30:49 +00:00
_sql_constraints = [ ( ' days_uniq ' , ' unique(followup_id, delay) ' , ' Days of the follow-up levels must be different ' ) ]
2011-05-10 13:55:57 +00:00
_defaults = {
2012-10-19 08:07:37 +00:00
' send_email ' : True ,
' send_letter ' : False ,
2012-11-21 14:49:32 +00:00
' manual_action ' : False ,
2012-11-06 17:15:22 +00:00
' description ' : """
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 .
2011-09-24 10:42:25 +00:00
2012-11-06 17:15:22 +00:00
Best Regards ,
""" ,
' email_template_id ' : _get_default_template ,
2011-05-10 13:55:57 +00:00
}
2012-11-21 14:49:32 +00:00
2011-09-24 10:42:25 +00:00
def _check_description ( self , cr , uid , ids , context = None ) :
for line in self . browse ( cr , uid , ids , context = context ) :
if line . description :
try :
line . description % { ' partner_name ' : ' ' , ' date ' : ' ' , ' user_signature ' : ' ' , ' company_name ' : ' ' }
except :
return False
return True
_constraints = [
( _check_description , ' Your description is invalid, use the right legend or %% if you want to use the percent character. ' , [ ' description ' ] ) ,
]
2010-07-03 09:30:47 +00:00
2006-12-07 13:41:40 +00:00
followup_line ( )
class account_move_line ( osv . osv ) :
2012-11-21 14:49:32 +00:00
2012-11-16 16:14:37 +00:00
def set_kanban_state_litigation ( self , cr , uid , ids , context = None ) :
for l in self . browse ( cr , uid , ids , context ) :
self . write ( cr , uid , [ l . id ] , { ' blocked ' : not l . blocked } )
return False
2012-11-21 14:49:32 +00:00
2012-11-07 16:51:30 +00:00
def _get_result ( self , cr , uid , ids , name , arg , context = None ) :
res = { }
2012-11-21 14:49:32 +00:00
for aml in self . browse ( cr , uid , ids , context ) :
2012-11-07 16:51:30 +00:00
res [ aml . id ] = aml . debit - aml . credit
return res
2012-11-21 14:49:32 +00:00
2008-07-22 15:11:28 +00:00
_inherit = ' account.move.line '
_columns = {
2012-11-22 15:30:49 +00:00
' followup_line_id ' : fields . many2one ( ' account_followup.followup.line ' , ' Follow-up Level ' ,
ondelete = ' restrict ' ) , #restrict deletion of the followup line
2011-01-17 11:20:56 +00:00
' followup_date ' : fields . date ( ' Latest Follow-up ' , select = True ) ,
2012-10-19 08:07:37 +00:00
' payment_commitment ' : fields . text ( ' Commitment ' ) ,
' payment_date ' : fields . date ( ' Date ' ) ,
2012-11-20 12:40:26 +00:00
' payment_next_action ' : fields . text ( ' Next Action ' ) ,
2012-11-22 15:30:49 +00:00
' result ' : fields . function ( _get_result , type = ' float ' , method = True ,
string = " Balance " ) #'balance' field is not the same
2011-10-28 15:43:37 +00:00
}
2010-07-03 09:30:47 +00:00
2006-12-07 13:41:40 +00:00
account_move_line ( )
2012-11-22 15:30:49 +00:00
2012-11-08 14:14:57 +00:00
class email_template ( osv . osv ) :
_inherit = ' email.template '
2012-11-21 14:49:32 +00:00
2012-11-22 15:30:49 +00:00
# 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
2012-11-08 14:14:57 +00:00
def render_template ( self , cr , uid , template , model , res_id , context = None ) :
2012-11-22 15:30:49 +00:00
context [ ' current_date ' ] = fields . date . context_today ( cr , uid , context )
2012-11-08 14:14:57 +00:00
return super ( email_template , self ) . render_template ( cr , uid , template , model , res_id , context )
2008-07-23 14:41:47 +00:00
2012-11-08 14:14:57 +00:00
email_template ( )
2012-10-19 17:29:17 +00:00
2012-10-19 08:07:37 +00:00
class res_partner ( osv . osv ) :
2012-10-19 17:29:17 +00:00
2012-11-22 08:32:24 +00:00
#TODO: that was not what we decided...
2012-11-16 16:14:37 +00:00
def fields_view_get ( self , cr , uid , view_id = None , view_type = None , context = None , toolbar = False , submenu = False ) :
2012-11-21 14:49:32 +00:00
res = super ( res_partner , self ) . fields_view_get ( cr , uid , view_id = view_id , view_type = view_type , context = context ,
2012-11-16 16:14:37 +00:00
toolbar = toolbar , submenu = submenu )
2012-11-19 10:18:57 +00:00
if view_type == ' form ' and context and ' Followupfirst ' in context . keys ( ) and context [ ' Followupfirst ' ] == True :
2012-11-16 16:14:37 +00:00
doc = etree . XML ( res [ ' arch ' ] , parser = None , base_url = None )
2012-11-21 14:49:32 +00:00
first_node = doc . xpath ( " //page[@string= ' Payments Follow-up ' ] " )
#first_node[0].getparent().append(first_node[0])
root = first_node [ 0 ] . getparent ( )
2012-11-19 10:18:57 +00:00
root . insert ( 0 , first_node [ 0 ] )
2012-11-16 16:14:37 +00:00
res [ ' arch ' ] = etree . tostring ( doc )
return res
2012-11-21 14:49:32 +00:00
2012-11-16 16:14:37 +00:00
2012-11-20 12:40:26 +00:00
# def _get_latest_followup_date(self, cr, uid, ids, name, arg, context=None):
# res = {}
2012-11-21 14:49:32 +00:00
# for partner in self.browse(cr, uid, ids, context):
# amls = partner.accountmoveline_ids
# res[partner.id] = max([x.followup_date for x in amls]) if len(amls) else False
2012-11-20 12:40:26 +00:00
# return res
#
#
2012-11-22 15:30:49 +00:00
#TODO: refactor these functions: remove this one, rework _get_latest and _get_next_followup_level_id must call _get_latest
2012-11-21 14:49:32 +00:00
2012-10-23 12:23:24 +00:00
def _get_latest_followup_level_id ( self , cr , uid , ids , name , arg , context = None ) :
2012-10-19 17:29:17 +00:00
res = { }
2012-11-22 15:30:49 +00:00
for partner in self . browse ( cr , uid , ids , context = context ) :
2012-11-08 14:14:57 +00:00
level_days = False
2012-10-23 12:23:24 +00:00
res [ partner . id ] = False
2012-11-22 08:32:24 +00:00
for accountmoveline in partner . accountmoveline_ids :
2012-10-26 15:11:25 +00:00
if ( accountmoveline . followup_line_id != False ) and ( not level_days or level_days < accountmoveline . followup_line_id . delay ) :
2012-10-23 12:23:24 +00:00
level_days = accountmoveline . followup_line_id . delay
2012-11-22 08:32:24 +00:00
res [ partner . id ] = accountmoveline . followup_line_id . id
2012-10-23 12:23:24 +00:00
#res[partner.id] = max(x.followup_line_id.delay for x in amls) if len(amls) else False
return res
2012-11-21 14:49:32 +00:00
2012-11-22 15:30:49 +00:00
#TODO: refactor + take into account company id
def get_latest_from_company ( self , cr , uid , ids , names , arg , context = None , company_id = None ) :
2012-11-12 17:38:57 +00:00
res = { }
2012-11-22 15:30:49 +00:00
# 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)
for partner in self . browse ( cr , uid , ids , context = context ) :
2012-11-06 17:15:22 +00:00
amls = partner . accountmoveline_ids
2012-11-12 17:38:57 +00:00
latest_date = False
latest_level = False
2012-11-20 15:29:59 +00:00
latest_days = False
2012-11-22 15:30:49 +00:00
latest_level_without_lit = False
2012-11-20 15:29:59 +00:00
latest_days_without_lit = False
2012-11-21 14:49:32 +00:00
for aml in amls :
2012-11-22 15:30:49 +00:00
if ( aml . followup_line_id != False ) and ( not latest_days or latest_days < aml . followup_line_id . delay ) :
latest_days = aml . followup_line_id . delay
latest_level = aml . followup_line_id . id
if ( not latest_date or latest_date < aml . followup_date ) :
2012-11-12 17:38:57 +00:00
latest_date = aml . followup_date
2012-11-22 15:30:49 +00:00
if ( aml . blocked == False ) and ( aml . followup_line_id != False and
( not latest_days_without_lit or latest_days_without_lit < aml . followup_line_id . delay ) ) :
latest_days_without_lit = aml . followup_line_id . delay
2012-11-20 15:29:59 +00:00
latest_level_without_lit = aml . followup_line_id . id
res [ partner . id ] = { ' latest_followup_date ' : latest_date ,
2012-11-21 14:49:32 +00:00
' latest_followup_level_id ' : latest_level ,
2012-11-12 17:38:57 +00:00
' latest_followup_level_id_without_lit ' : latest_level_without_lit }
2012-11-06 17:15:22 +00:00
return res
2012-11-22 15:30:49 +00:00
def _get_latest ( self , cr , uid , ids , names , arg , context = None ) :
company = self . pool . get ( ' res.users ' ) . browse ( cr , uid , uid , context = context )
return self . get_latest_from_company ( cr , uid , ids , names , arg , context = context , company_id = company )
2012-11-20 12:40:26 +00:00
#Problems company id? / Method necessary?
2012-11-22 08:32:24 +00:00
#TODO: must use the company_id of the uid + refactor
2012-10-24 15:37:34 +00:00
def _get_next_followup_level_id ( self , cr , uid , ids , name , arg , context = None ) :
res = { }
2012-11-22 08:32:24 +00:00
for partner in self . browse ( cr , uid , ids , context = context ) :
2012-10-24 15:37:34 +00:00
latest_id = self . _get_latest_followup_level_id ( cr , uid , [ partner . id ] , name , arg , context ) [ partner . id ]
2012-11-22 08:32:24 +00:00
latest = latest_id and self . pool . get ( ' account_followup.followup.line ' ) . browse ( cr , uid , latest_id , context = context ) or False
2012-10-24 15:37:34 +00:00
delay = False
newlevel = False
2012-11-08 14:14:57 +00:00
old_delay = False
if latest : #if latest exists
2012-10-24 15:37:34 +00:00
newlevel = latest . id
old_delay = latest . delay
2012-11-21 14:49:32 +00:00
fl_ar = self . pool . get ( ' account_followup.followup.line ' ) . search ( cr , uid , [ ( ' followup_id.company_id.id ' , ' = ' , partner . company_id . id ) ] )
2012-10-26 15:11:25 +00:00
for fl_obj in self . pool . get ( ' account_followup.followup.line ' ) . browse ( cr , uid , fl_ar ) :
2012-11-21 14:49:32 +00:00
if not old_delay :
if not delay or fl_obj . delay < delay :
2012-10-24 15:37:34 +00:00
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
return res
2012-10-26 08:09:14 +00:00
2012-11-20 12:40:26 +00:00
# def _get_amount_overdue(self, cr, uid, ids, name, arg, context=None):
# #Get the total amount in the account move lines that the customer owns us
# res={}
# print "get amount overdue"
# for partner in self.browse(cr, uid, ids, context):
# res[partner.id] = 0.0
2012-11-21 14:49:32 +00:00
# for aml in partner.accountmoveline_ids:
2012-11-20 12:40:26 +00:00
# res[partner.id] = res[partner.id] + aml.debit - aml.credit #or by using function field
# return res
2012-11-21 14:49:32 +00:00
2012-11-20 12:40:26 +00:00
#
2012-11-22 08:32:24 +00:00
#TODO: remove
2012-11-21 14:49:32 +00:00
#
2012-11-20 12:40:26 +00:00
def _get_amount_due ( self , cr , uid , ids , name , arg , context = None ) :
res = { }
2012-10-30 11:05:21 +00:00
for partner in self . browse ( cr , uid , ids , context ) :
2012-11-20 12:40:26 +00:00
res [ partner . id ] = partner . credit
2012-10-30 11:05:21 +00:00
return res
2012-11-21 14:49:32 +00:00
2012-11-22 08:32:24 +00:00
#TODO: to refactor and to comment. I don't get the 'else' statements...
2012-11-08 14:14:57 +00:00
def do_partner_manual_action ( self , cr , uid , partner_ids , context = None ) :
2012-11-22 08:32:24 +00:00
#partner_ids are res.partner ids #TODO: useless comment to remove
for partner in self . browse ( cr , uid , partner_ids , context ) :
2012-11-20 12:40:26 +00:00
if True : #(not partner.payment_next_action_date) and (not partner.payment_next_action) and (not partner.payment_responsible_id)
action_text = " "
#Check action
if partner . payment_next_action :
2012-11-21 14:49:32 +00:00
action_text = ( partner . payment_next_action or ' ' ) + " \n " + ( partner . latest_followup_level_id_without_lit . manual_action_note or ' ' )
2012-11-20 12:40:26 +00:00
else :
action_text = partner . latest_followup_level_id_without_lit . manual_action_note
#Check minimum date
action_date = False
if partner . payment_next_action_date :
action_date = min ( partner . payment_next_action_date , fields . date . context_today ( cr , uid , context ) )
else :
action_date = fields . date . context_today ( cr , uid , context )
responsible_id = False
#Check responsible
if partner . payment_responsible_id :
responsible_id = partner . payment_responsible_id . id
else :
if partner . latest_followup_level_id_without_lit . manual_action_responsible_id :
2012-11-21 14:49:32 +00:00
responsible_id = partner . latest_followup_level_id_without_lit . manual_action_responsible_id . id
self . write ( cr , uid , [ partner . id ] , { ' payment_next_action_date ' : action_date ,
' payment_next_action ' : action_text ,
2012-11-20 12:40:26 +00:00
' payment_responsible_id ' : responsible_id } )
2012-11-21 14:49:32 +00:00
2012-10-26 08:09:14 +00:00
2012-11-06 17:15:22 +00:00
def do_partner_print ( self , cr , uid , partner_ids , data , context = None ) :
2012-11-21 14:49:32 +00:00
#partner_ids are ids from special view, not from res.partner
2012-10-26 08:09:14 +00:00
#data.update({'date': context['date']})
2012-11-21 14:49:32 +00:00
if not partner_ids :
2012-10-26 08:09:14 +00:00
return { }
data [ ' partner_ids ' ] = partner_ids
datas = {
' ids ' : [ ] ,
' model ' : ' account_followup.followup ' ,
' form ' : data
}
return {
2012-11-21 14:49:32 +00:00
' type ' : ' ir.actions.report.xml ' ,
' report_name ' : ' account_followup.followup.print ' ,
' datas ' : datas ,
2012-10-26 08:09:14 +00:00
}
def do_partner_mail ( self , cr , uid , partner_ids , context = None ) :
2012-11-08 14:14:57 +00:00
#partner_ids are res.partner ids
# If not defined by latest level, it will the default template if it can find it
2012-10-26 08:09:14 +00:00
mtp = self . pool . get ( ' email.template ' )
2012-11-20 12:40:26 +00:00
unknown_mails = 0
2012-10-26 08:09:14 +00:00
for partner in self . browse ( cr , uid , partner_ids , context ) :
2012-11-20 15:29:59 +00:00
print " Email " , partner . email
if partner . email != False and partner . email != ' ' and partner . email != ' ' :
2012-11-21 14:49:32 +00:00
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 :
2012-11-20 12:40:26 +00:00
mtp . send_mail ( cr , uid , partner . latest_followup_level_id_without_lit . email_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 )
else :
unknown_mails = unknown_mails + 1
action_text = _ ( " Email not sent because of email address of partner not filled in " )
if partner . payment_next_action_date :
payment_action_date = min ( fields . date . context_today ( cr , uid , context ) , partner . payment_next_action_date )
else :
payment_action_date = fields . date . context_today ( cr , uid , context )
if partner . payment_next_action :
payment_next_action = partner . payment_next_action + " + " + action_text
else :
payment_next_action = action_text
2012-11-21 14:49:32 +00:00
self . write ( cr , uid , [ partner . id ] , { ' payment_next_action_date ' : payment_action_date ,
2012-11-20 12:40:26 +00:00
' payment_next_action ' : payment_next_action } , context )
return unknown_mails
2012-10-26 08:09:14 +00:00
2012-10-31 11:29:07 +00:00
def action_done ( self , cr , uid , ids , context = None ) :
2012-11-06 17:15:22 +00:00
self . write ( cr , uid , ids , { ' payment_next_action_date ' : False , ' payment_next_action ' : ' ' , ' payment_responsible_id ' : False } , context )
2012-11-21 14:49:32 +00:00
2012-11-08 14:14:57 +00:00
def do_button_print ( self , cr , uid , ids , context = None ) :
2012-11-22 08:32:24 +00:00
#TODO: assert that ids is a list of 1 element only before doing ids[0]
2012-11-08 14:14:57 +00:00
self . message_post ( cr , uid , [ ids [ 0 ] ] , body = _ ( ' Printed overdue payments report ' ) , context = context )
2012-11-06 17:15:22 +00:00
datas = {
' ids ' : ids ,
' model ' : ' res.partner ' ,
' form ' : self . read ( cr , uid , ids [ 0 ] , context = context )
}
return {
' type ' : ' ir.actions.report.xml ' ,
' report_name ' : ' account.overdue ' ,
' datas ' : datas ,
' nodestroy ' : True
}
2012-11-21 14:49:32 +00:00
2012-11-06 17:15:22 +00:00
def do_button_mail ( self , cr , uid , ids , context = None ) :
2012-11-07 16:51:30 +00:00
self . do_partner_mail ( cr , uid , ids , context )
2012-11-21 14:49:32 +00:00
2012-11-07 16:51:30 +00:00
def _get_aml_storeids ( self , cr , uid , ids , context = None ) :
2012-11-06 17:15:22 +00:00
partnerlist = [ ]
for aml in self . pool . get ( " account.move.line " ) . browse ( cr , uid , ids , context ) :
2012-11-21 14:49:32 +00:00
if aml . partner_id . id not in partnerlist :
2012-11-06 17:15:22 +00:00
partnerlist . append ( aml . partner_id . id )
return partnerlist
2012-10-30 11:05:21 +00:00
2012-10-19 08:07:37 +00:00
_inherit = " res.partner "
_columns = {
2012-11-21 14:49:32 +00:00
2012-11-22 08:32:24 +00:00
' payment_responsible_id ' : fields . many2one ( ' res.users ' , ondelete = ' set null ' , string = ' Followup Responsible ' , help = " Responsible for making sure the action happens. " ) , #TODO find better name for field
2012-11-21 14:49:32 +00:00
' payment_note ' : fields . text ( ' Customer Payment Promise ' , help = " Payment Note " ) ,
' payment_next_action ' : fields . text ( ' Next Action ' ,
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. " ) , #TODO: size=128
' payment_next_action_date ' : fields . date ( ' Next Action Date ' ,
2012-11-12 17:38:57 +00:00
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
2012-11-07 16:51:30 +00:00
' accountmoveline_ids ' : fields . one2many ( ' account.move.line ' , ' partner_id ' , domain = [ ' & ' , ( ' reconcile_id ' , ' = ' , False ) , ' & ' ,
2012-11-22 08:32:24 +00:00
( ' account_id.active ' , ' = ' , True ) , ' & ' , ( ' account_id.type ' , ' = ' , ' receivable ' ) , ( ' state ' , ' != ' , ' draft ' ) ] ) , #TODO: find better name
2012-11-12 17:38:57 +00:00
' latest_followup_date ' : fields . function ( _get_latest , method = True , type = ' date ' , string = " Latest Follow-up Date " ,
help = " Latest date that the follow-up level of the partner was changed " ,
store = { ' account.move.line ' : ( _get_aml_storeids , [ ' followup_line_id ' , ' followup_date ' ] , 10 ) } ,
multi = " latest " ) ,
' latest_followup_level_id ' : fields . function ( _get_latest , method = True ,
type = ' many2one ' , relation = ' account_followup.followup.line ' , string = " Latest Follow-up Level " ,
help = " The maximum follow-up level " ,
store = { ' account.move.line ' : ( _get_aml_storeids , [ ' followup_line_id ' , ' followup_date ' ] , 10 ) } ,
multi = " latest " ) ,
' latest_followup_level_id_without_lit ' : fields . function ( _get_latest , method = True ,
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 " ,
store = { ' account.move.line ' : ( _get_aml_storeids , [ ' followup_line_id ' , ' followup_date ' ] , 10 ) } ,
multi = " latest " ) ,
' 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 ' ] , 10 ) } ) ,
2012-11-22 08:32:24 +00:00
' payment_amount_due ' : fields . function ( _get_amount_due , method = True , type = ' float ' , store = False ) , #TODO: use a fields.related
2012-11-21 14:49:32 +00:00
}
2012-10-19 08:07:37 +00:00
res_partner ( )
2011-09-24 10:42:25 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: