[WIP] Adding search filters and changing amount to overdue amount

bzr revid: jco@openerp.com-20121031112907-wltw4mnm30tux1d9
This commit is contained in:
Josse Colpaert 2012-10-31 12:29:07 +01:00
parent ed5bc8a591
commit cabac6daed
6 changed files with 130 additions and 23 deletions

View File

@ -61,7 +61,7 @@ Note that if you want to check the follow-up level for a given partner/account e
'demo': [],
'test': [
'test/account_followup.yml',
#'test/account_followup_report.yml',
'test/account_followup_report.yml',
],
'installable': True,
'auto_install': False,

View File

@ -161,6 +161,37 @@ class res_partner(osv.osv):
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):
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 = {}
@ -203,7 +234,8 @@ class res_partner(osv.osv):
for partner in self.browse(cr, uid, ids, context):
res[partner.id] = 0.0
for aml in partner.accountmoveline_ids:
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
return res
@ -355,7 +387,12 @@ 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':''}, context)
_inherit = "res.partner"
_columns = {
@ -369,8 +406,8 @@ class res_partner(osv.osv):
'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="latest followup date", store=True),
'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=True),
'next_followup_level_id':fields.function(_get_next_followup_level_id, method=True, type='many2one', relation='account_followup.followup.line', string="Next Level"),
'payment_amount_outstanding':fields.function(_get_amount, method=True, type='float', string="Amount", store=True),
'next_followup_level_id':fields.function(_get_next_followup_level_id_optimized, method=True, type='many2one', relation='account_followup.followup.line', string="Next Level", help="Next level that will be printed"),
'payment_amount_outstanding':fields.function(_get_amount, method=True, type='float', string="Amount Overdue", store=True),
}
res_partner()

View File

@ -10,13 +10,16 @@
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<form string="Customer FollowUp form">
<group col="4" colspan="4">
<form string="Customer FollowUp form" version="7.0">
<group>
<field name="name"/>
<field name="phone" />
<!--<field name="sales" readonly="True"/>-->
</group>
<separator string="Detail of accounts" />
<field name="accountmoveline_ids" nolabel="1" domain="[('reconcile_id', '=', False)]"> <!--domain does not work-->
<separator string="Detail of accounts" />
<group>
<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"/>
@ -28,23 +31,37 @@
<field name="blocked" string="Litigation"/>
<field name="payment_commitment"/>
<field name="payment_date"/>
<field name="reconcile_id" invisible="True"/>
<!--<field name="reconcile_id" invisible="True"/>-->
<field name="reconcile_partial_id" readonly="True"/>
<field name="invoice"/>
</tree>
</field>
</group>
<newline/>
<group>
<separator string="Actions to be taken"/>
<newline/>
<separator string="Payment Followup Remarks" colspan="4"/>
<newline/>
<group col="6" colspan="6">
<field name="payment_next_action"/>
<group>
<field name="payment_next_action" help="Describes agreement with the client"/>
<button name="action_done" type="object" string="Follow-up Action Done" class="oe_highlight" help="This button will clear the action and the action date. "/>
</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"/>
</group>
</group>
<separator string="Payment Followup Remarks"/>
<newline/>
<group>
<field name="payment_note"/>
<field name="payment_responsible_id"/>
<!--<field name="payment_followup_level_id"/>-->
<field name="latest_followup_level_id"/>
<field name="latest_followup_date"/>
<field name="next_followup_level_id"/>
<field name="payment_next_action_date"/>
</group>
</form>
</field>
@ -80,10 +97,19 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search view">
<filter string="Actions to be taken" domain="[('payment_next_action', '!=', '')]"/>
<filter string="Follow-up sent" domain="[('latest_followup_level_id', '!=', '')]"/>
<!--<filter string="Actions to be taken with overdue amount" domain="['&amp;', ('payment_amount_outstanding', '>', 0.0), ('payment_next_action_date', '&lt;=', time.strftime('%%Y-%%m-%%d'))]"/>
<separator/>-->
<filter string="Overdue amount outstanding" domain="[('payment_amount_outstanding', '>', 0.0)]"/>
<separator/>
<filter string="Action to be taken now" domain="[('payment_next_action_date', '&lt;=', time.strftime('%%Y-%%m-%%d'))]"/>
<separator/>
<filter string="Action to be taken" domain="[('payment_next_action', '!=', '')]"/>
<filter string="Follow-up sent" domain="[('latest_followup_level_id', '!=', False)]"/>
<separator/>
<filter string="Without responsible" domain="[('payment_responsible_id', '=', False)]"/>
<filter string="I am responsible" domain="[('payment_responsible_id','=', uid)]"/>
</search>
</field>
</record>
@ -113,6 +139,35 @@
<field name="view_id" ref="customer_followup_tree"/>
<field name="act_window_id" ref="action_customer_followup"/>
</record>
<record model="ir.ui.view" id="view_partner_inherit_followup_form">
<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="arch" type="xml">
<notebook position="inside">
<page string="Payments Follow-up" position="inside">
<separator string="Payments follow-up"/>
<group>
<field name="payment_amount_outstanding"/>
<field name="latest_followup_level_id"/>
<field name="payment_next_action"/>
<field name="payment_next_action_date"/>
</group>
</page>
</notebook>
<!--<field name="name" position="after">
<field name="payment_next_action"/>
</field>-->
<!--<field name="payment_amount_outstanding" position="after">
<separator string="Account Move Lines" colspan="4"/>
<field name="accountmoveline_ids" nolabel="1" colspan="4"/>
</field>-->
</field>
</record>
<!-- Menus about followup of customers -->
<menuitem id="account_followup_" action="action_customer_followup" parent="account.menu_configuration_misc" name="Customer follow up"/>

View File

@ -168,6 +168,5 @@
</field>
</field>
</record>
</data>
</openerp>
</openerp>

View File

@ -3,7 +3,15 @@
-
!record {model: account.invoice, id: account.demo_invoice_0}:
check_total: 14.0
-
date_invoice: 2012-06-2
invoice_line:
- account_id : account.a_sale
name: 'Stupid PC'
quantity: 1.0
journal_id: account.bank_journal
partner_id: base.res_partner_12
reference_type: none
-
!workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0}
-
I create a follow-up.
@ -14,4 +22,13 @@
I will process follow-ups
-
!python {model: account.followup.print}: |
self.do_process(cr, uid, [ref("account_followup_print_0")], {"active_ids": [ref("account_followup.account_followup_print_menu")], "active_id": ref("account_followup.account_followup_print_menu"),})
self.do_process(cr, uid, [ref("account_followup_print_0")], {"active_ids": [ref("account_followup.account_followup_print_menu")], "active_id": ref("account_followup.account_followup_print_menu"),})
#-
# Test it has everything
#-
# !assert {model: account.invoice, id: account.demo_invoice_0}:
# - reference_type = None
#!assert {model: res.partner, id: base.res_partner_12} :
# -
#latest_followup_level_id == ref("demo_followup_line1")

View File

@ -132,7 +132,6 @@ 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)
action = partner_obj.do_partner_print(cr, uid, partner_ids_to_print, data, context)
return action or {}