[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:
parent
0cba3bef47
commit
6fee78b475
|
@ -179,6 +179,9 @@ class res_partner(osv.osv):
|
||||||
def _test_percent(self, cr, uid, ids, field_name, arg, context=None):
|
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)}
|
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):
|
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
|
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'),
|
'invoices_stat_button': fields.function(_invoices_stat_button, string="Invoices", type='html'),
|
||||||
'testpercent': fields.function(_test_percent, string="TestPercent", type='float'),
|
'testpercent': fields.function(_test_percent, string="TestPercent", type='float'),
|
||||||
'journal_items_ids': fields.one2many('account.move.line', 'partner_id', 'Journal Items'),
|
'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(
|
'property_account_payable': fields.property(
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
|
|
|
@ -64,15 +64,16 @@
|
||||||
<field name="priority" eval="20"/>
|
<field name="priority" eval="20"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[@name='buttons']" position="inside">
|
<xpath expr="//div[@name='buttons']" position="inside">
|
||||||
<statbutton type="action"
|
<button type="action"
|
||||||
|
class="oe_stat_button"
|
||||||
name="%(account.action_invoice_tree)d"
|
name="%(account.action_invoice_tree)d"
|
||||||
context="{'search_default_partner_id': active_id,'default_partner_id': active_id}" groups="account.group_account_invoice">
|
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="TestPercent" name="testpercent" widget="percentpie" attrs="{'readonly':1}"/>
|
||||||
<field string="Invoices" name="invoices_stat_button" attrs="{'readonly':1}"/>
|
<field string="Invoices" name="invoices_stat_button" attrs="{'readonly':1}"/>
|
||||||
</statbutton>
|
</button>
|
||||||
<statbutton type="action" name="%(account.action_account_moves_all_tree)d" groups="account.group_account_user" icon="fa-book">
|
<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_items_ids" widget="x2many" attrs="{'readonly':1}"/>
|
<field string="Journal Items" name="journal_item_count" widget="statinfo"/>
|
||||||
</statbutton>
|
</button>
|
||||||
<button type="action" string="Contracts" name="%(account.action_open_partner_analytic_accounts)d"
|
<button type="action" string="Contracts" name="%(account.action_open_partner_analytic_accounts)d"
|
||||||
groups="analytic.group_analytic_accounting"/>
|
groups="analytic.group_analytic_accounting"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
|
@ -25,7 +25,7 @@ class res_partner(osv.osv):
|
||||||
""" Inherits partner and adds CRM information in the partner form """
|
""" Inherits partner and adds CRM information in the partner form """
|
||||||
_inherit = 'res.partner'
|
_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))
|
res = dict(map(lambda x: (x,{'opportunity_count': 0, 'meeting_count': 0}), ids))
|
||||||
# the user may not have access rights for opportunities or meetings
|
# the user may not have access rights for opportunities or meetings
|
||||||
try:
|
try:
|
||||||
|
@ -33,6 +33,7 @@ class res_partner(osv.osv):
|
||||||
res[partner.id] = {
|
res[partner.id] = {
|
||||||
'opportunity_count': len(partner.opportunity_ids),
|
'opportunity_count': len(partner.opportunity_ids),
|
||||||
'meeting_count': len(partner.meeting_ids),
|
'meeting_count': len(partner.meeting_ids),
|
||||||
|
'phonecall_count': len(partner.meeting_ids),
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -46,8 +47,9 @@ class res_partner(osv.osv):
|
||||||
'Meetings'),
|
'Meetings'),
|
||||||
'phonecall_ids': fields.one2many('crm.phonecall', 'partner_id',\
|
'phonecall_ids': fields.one2many('crm.phonecall', 'partner_id',\
|
||||||
'Phonecalls'),
|
'Phonecalls'),
|
||||||
'opportunity_count': fields.function(_opportunity_meeting_count, string="Opportunity", 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_count, string="# Meetings", 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):
|
def copy(self, cr, uid, record_id, default=None, context=None):
|
||||||
|
|
|
@ -90,25 +90,25 @@
|
||||||
<field name="section_id" completion="1" groups="base.group_multi_salesteams"/>
|
<field name="section_id" completion="1" groups="base.group_multi_salesteams"/>
|
||||||
</field>
|
</field>
|
||||||
<xpath expr="//div[@name='buttons']" position="inside">
|
<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)]}"
|
attrs="{'invisible': [('customer', '=', False)]}"
|
||||||
name="%(crm.crm_case_category_act_oppor11)d"
|
name="%(crm.crm_case_category_act_oppor11)d"
|
||||||
icon="fa-star"
|
icon="fa-star"
|
||||||
context="{'search_default_partner_id': active_id}">
|
context="{'search_default_partner_id': active_id}">
|
||||||
<field string="Opportunities" name="opportunity_ids" widget="x2many"/>
|
<field string="Opportunities" name="opportunity_count" widget="statinfo"/>
|
||||||
</statbutton>
|
</button>
|
||||||
<statbutton class="oe_inline" type="action"
|
<button class="oe_inline oe_stat_button" type="action"
|
||||||
name="%(calendar.action_calendar_event)d"
|
name="%(calendar.action_calendar_event)d"
|
||||||
icon="fa-calendar"
|
icon="fa-calendar"
|
||||||
context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}">
|
context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}">
|
||||||
<field string="Meetings" name="meeting_ids" widget="x2many"/>
|
<field string="Meetings" name="meeting_count" widget="statinfo"/>
|
||||||
</statbutton>
|
</button>
|
||||||
<statbutton class="oe_inline" type="action"
|
<button class="oe_inline oe_stat_button" type="action"
|
||||||
name="%(crm.crm_case_categ_phone_incoming0)d"
|
name="%(crm.crm_case_categ_phone_incoming0)d"
|
||||||
icon="fa-phone"
|
icon="fa-phone"
|
||||||
context="{'search_default_partner_id': active_id, 'default_duration': 1.0}">
|
context="{'search_default_partner_id': active_id, 'default_duration': 1.0}">
|
||||||
<field string="Calls" name="phonecall_ids" widget="x2many"/>
|
<field string="Calls" name="phonecall_count" widget="statinfo"/>
|
||||||
</statbutton>
|
</button>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
</field>
|
</field>
|
||||||
|
|
Loading…
Reference in New Issue