[IMP] improves the way the res_partner fields are displayed in the buttons in form view. Specifically, uses the widget 'statinfo' and some related cleanup (addons account, crm)

bzr revid: ged@openerp.com-20140314140114-9t2piu3cpqkldnbo
This commit is contained in:
Gery Debongnie 2014-03-14 15:01:14 +01:00
parent 0cba3bef47
commit 6fee78b475
4 changed files with 24 additions and 17 deletions

View File

@ -179,6 +179,9 @@ class res_partner(osv.osv):
def _test_percent(self, cr, uid, ids, field_name, arg, context=None):
return {partner.id: random.random()*100 for partner in self.browse(cr, uid, ids, context)}
def _journal_item_count(self, cr, uid, ids, field_name, arg, context=None):
return {partner.id: len(partner.journal_items_ids) for partner in self.browse(cr, uid, ids, context)}
def has_something_to_reconcile(self, cr, uid, partner_id, context=None):
'''
at least a debit, a credit and a line older than the last reconciliation date of the partner
@ -210,6 +213,7 @@ class res_partner(osv.osv):
'invoices_stat_button': fields.function(_invoices_stat_button, string="Invoices", type='html'),
'testpercent': fields.function(_test_percent, string="TestPercent", type='float'),
'journal_items_ids': fields.one2many('account.move.line', 'partner_id', 'Journal Items'),
'journal_item_count': fields.function(_journal_item_count, string="Journal Items", type="integer"),
'property_account_payable': fields.property(
type='many2one',
relation='account.account',

View File

@ -64,15 +64,16 @@
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<statbutton type="action"
<button type="action"
class="oe_stat_button"
name="%(account.action_invoice_tree)d"
context="{'search_default_partner_id': active_id,'default_partner_id': active_id}" groups="account.group_account_invoice">
<field string="TestPercent" name="testpercent" widget="percentpie" attrs="{'readonly':1}"/>
<field string="Invoices" name="invoices_stat_button" attrs="{'readonly':1}"/>
</statbutton>
<statbutton type="action" name="%(account.action_account_moves_all_tree)d" groups="account.group_account_user" icon="fa-book">
<field string="Journal Items" name="journal_items_ids" widget="x2many" attrs="{'readonly':1}"/>
</statbutton>
</button>
<button type="action" class="oe_stat_button" name="%(account.action_account_moves_all_tree)d" groups="account.group_account_user" icon="fa-book">
<field string="Journal Items" name="journal_item_count" widget="statinfo"/>
</button>
<button type="action" string="Contracts" name="%(account.action_open_partner_analytic_accounts)d"
groups="analytic.group_analytic_accounting"/>
</xpath>

View File

@ -25,7 +25,7 @@ class res_partner(osv.osv):
""" Inherits partner and adds CRM information in the partner form """
_inherit = 'res.partner'
def _opportunity_meeting_count(self, cr, uid, ids, field_name, arg, context=None):
def _opportunity_meeting_phonecall_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict(map(lambda x: (x,{'opportunity_count': 0, 'meeting_count': 0}), ids))
# the user may not have access rights for opportunities or meetings
try:
@ -33,6 +33,7 @@ class res_partner(osv.osv):
res[partner.id] = {
'opportunity_count': len(partner.opportunity_ids),
'meeting_count': len(partner.meeting_ids),
'phonecall_count': len(partner.meeting_ids),
}
except:
pass
@ -46,8 +47,9 @@ class res_partner(osv.osv):
'Meetings'),
'phonecall_ids': fields.one2many('crm.phonecall', 'partner_id',\
'Phonecalls'),
'opportunity_count': fields.function(_opportunity_meeting_count, string="Opportunity", type='integer', multi='opp_meet'),
'meeting_count': fields.function(_opportunity_meeting_count, string="# Meetings", type='integer', multi='opp_meet'),
'opportunity_count': fields.function(_opportunity_meeting_phonecall_count, string="Opportunity", type='integer', multi='opp_meet'),
'meeting_count': fields.function(_opportunity_meeting_phonecall_count, string="# Meetings", type='integer', multi='opp_meet'),
'phonecall_count': fields.function(_opportunity_meeting_phonecall_count, string="Phonecalls", type="integer", multi='opp_meet'),
}
def copy(self, cr, uid, record_id, default=None, context=None):

View File

@ -90,25 +90,25 @@
<field name="section_id" completion="1" groups="base.group_multi_salesteams"/>
</field>
<xpath expr="//div[@name='buttons']" position="inside">
<statbutton class="oe_inline" type="action"
<button class="oe_inline oe_stat_button" type="action"
attrs="{'invisible': [('customer', '=', False)]}"
name="%(crm.crm_case_category_act_oppor11)d"
icon="fa-star"
context="{'search_default_partner_id': active_id}">
<field string="Opportunities" name="opportunity_ids" widget="x2many"/>
</statbutton>
<statbutton class="oe_inline" type="action"
<field string="Opportunities" name="opportunity_count" widget="statinfo"/>
</button>
<button class="oe_inline oe_stat_button" type="action"
name="%(calendar.action_calendar_event)d"
icon="fa-calendar"
context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}">
<field string="Meetings" name="meeting_ids" widget="x2many"/>
</statbutton>
<statbutton class="oe_inline" type="action"
<field string="Meetings" name="meeting_count" widget="statinfo"/>
</button>
<button class="oe_inline oe_stat_button" type="action"
name="%(crm.crm_case_categ_phone_incoming0)d"
icon="fa-phone"
context="{'search_default_partner_id': active_id, 'default_duration': 1.0}">
<field string="Calls" name="phonecall_ids" widget="x2many"/>
</statbutton>
<field string="Calls" name="phonecall_count" widget="statinfo"/>
</button>
</xpath>
</data>
</field>