[IMP] Wizard extra button try + next level field

bzr revid: jco@openerp.com-20121024153734-rda572kyd627yims
This commit is contained in:
Josse Colpaert 2012-10-24 17:37:34 +02:00
parent 4e14df3180
commit 5518ab757b
4 changed files with 110 additions and 21 deletions

View File

@ -127,8 +127,7 @@ class res_partner(osv.osv):
# 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.account_id.type is 'receivable')
and (a.debit > 0), 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
#else:
# res[partner.id] = False
@ -149,23 +148,58 @@ class res_partner(osv.osv):
res[partner.id] = False
for accountmoveline in amls:
if (accountmoveline.followup_line_id != False) and (level_days < accountmoveline.followup_line_id.delay) and (accountmoveline.state != "draft"): # and (accountmoveline.debit > 0):
if (accountmoveline.followup_line_id != False) and (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(self, cr, uid, ids, name, arg, context=None):
res = {}
for partner in self.browse(cr, uid, ids):
latest_id = self._get_latest_followup_level_id(cr, uid, [partner.id], name, arg, context)[partner.id]
latest = self.pool.get('account_followup.followup.line').browse(cr, uid, [latest_id], context)[0]
delay = False
newlevel = False
if latest: #if latest exists
newlevel = latest.id
old_delay = latest.delay
else:
old_delay = False
for fl in self.pool.get('account_followup.followup.line').search(cr, uid, []): #('followup_id.company_id','=',latest.followup_id.company_id)
fl_obj = self.pool.get('account_followup.followup.line').browse(cr, uid, [fl])[0]
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
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null'),
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Responsible', help="Responsible"),
#'payment_followup_level_id':fields.many2one('account_followup.followup.line', 'Followup line'),
'payment_note':fields.text('Payment note', help="Payment note"),
'payment_note':fields.text('Payment note', help="Payment note"),
'payment_new_action':fields.text('New action'), #one2many/selection?
'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id'),
'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="latest followup date"),
'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('debit', '>', 0.0), '&', ('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=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"),
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"),
}

View File

@ -16,30 +16,37 @@
<field name="phone" />
</group>
<separator string="Detail of accounts" />
<field name="accountmoveline_ids" nolabel="1" domain="[('debit', '&gt;', 0)]">
<field name="accountmoveline_ids" nolabel="1" domain="[('reconcile_id', '=', False)]"> <!--domain does not work-->
<tree string="Account Move line" editable="bottom">
<field name="date" readonly="True"/>
<field name="move_id" readonly="True"/>
<field name="ref" readonly="True"/>
<field name="debit" 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="reconcile_id" invisible="True"/>
<field name="reconcile_partial_id" readonly="True"/>
<field name="invoice"/>
</tree>
</field>
<newline/>
<separator string="Payment Followup Remarks"/>
<!--<field name="payment_responsible_id"/>-->
<group col="4" colspan="4">
<separator string="Payment Followup Remarks" colspan="4"/>
<newline/>
<group col="6" colspan="6">
<field name="payment_next_action"/>
<field name="payment_note"/>
<field name="payment_responsible_id"/>
<!--<field name="payment_followup_level_id"/>-->
<field name="payment_new_action"/>
<field name="latest_followup_level_id"/>
<field name="latest_followup_date"/>
<field name="next_followup_level_id"/>
</group>
</form>
</field>
@ -48,23 +55,38 @@
<record id="customer_followup_tree" model="ir.ui.view">
<field name="name">ddd</field>
<field name="model">res.partner</field>
<!--<field name="type">tree</field>-->
<!--<field name="type">tree</field>-->
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<tree string="Customer Followup">
<field name="name"/>
<field name="latest_followup_level_id"/>
<field name="latest_followup_date"/>
<field name="payment_new_action"/>
<field name="payment_next_action"/>
<field name="payment_note"/>
<field name="phone"/>
<field name="payment_responsible_id"/>
<field name="email"/>
<field name="next_followup_level_id"/>
<!-- <field name="latest_followup_date"/>-->
</tree>
</field>
</record>
<record id ="customer_followup_search_view" model="ir.ui.view">
<field name="name">Search</field>
<field name="model">res.partner</field>
<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="Without responsible" domain="[('payment_responsible_id', '=', False)]"/>
<filter string="I am responsible" domain="[('payment_responsible_id','=', uid)]"/>
</search>
</field>
</record>
<record id="action_customer_followup" model="ir.actions.act_window">
<field name="name">Customer Follow Up</field>
@ -72,12 +94,15 @@
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('customer', '=', True)]</field>
<!--<field name="domain">[('latest_followup_date','!=', False)]</field>--> <!--('customer', '=', True), -->
<field name="search_view_id" ref="customer_followup_search_view"/>
</record>
<record id="action_view_customer_followup_form" model="ir.actions.act_window.view">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>

View File

@ -188,7 +188,6 @@ class account_followup_print_all(osv.osv_memory):
if result['start'] == 'end_of_month':
fups[old][0].replace(day=1)
old = result['id']
fups[old] = (datetime.date(datetime.MAXYEAR, 12, 31), old)
partner_list = []
@ -239,7 +238,7 @@ class account_followup_print_all(osv.osv_memory):
msg_unsent = ''
data_user = user_obj.browse(cr, uid, uid, context=context)
for partner in self.pool.get('res.partner').browse(cr, uid, partners, context=context):
if True: #partner.latest_followup_level_id.send_email:
if partner.next_followup_level_id.send_email:
ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable']),('company_id','=',context.get('company_id', False))])
data_lines = move_obj.browse(cr, uid, ids_lines, context=context)
total_amt = 0.0
@ -353,6 +352,31 @@ class account_followup_print_all(osv.osv_memory):
'datas': datas,
}
def do_process(self, cr, uid, ids, context=None):
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()

View File

@ -100,5 +100,11 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>