""" Inherits partner and adds invoice information in the partner form """
_inherit = 'res.partner'
_columns = {
- 'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices', readonly=True),
+ 'invoice_ids': fields.one2many('account.invoice', 'partner_id', 'Invoices', readonly=True),
}
def _find_accounting_partner(self, partner):
def _debit_search(self, cr, uid, obj, name, args, context=None):
return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context)
+ def _invoices_stat_button(self, cr, uid, ids, field_name, arg, context=None):
+ res = {}
+ obj = self.pool.get('account.invoice')
+ for partner in self.browse(cr, uid, ids, context):
+ domain = [('id', 'in', map(int, partner.invoice_ids))]
+ group_obj = obj.read_group(cr, uid, domain, ['amount_total'], [''], context=context)
+ total = group_obj[0]['amount_total']
+ res[partner.id] = """
+ <div><strong>%s</strong> invoices</div>
+ <div>Total: %s</div>
+ """ % (len(partner.invoice_ids), total)
+ return res
+
+ def _journal_items_stat_button(self, cr, uid, ids, field_name, arg, context=None):
+ html = "<div><strong>%s</strong> Journal Items</div>"
+ return {partner.id: html % len(partner.journal_items_ids) for partner in self.browse(cr, uid, ids, context)}
+ res = {}
+
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
fnct_search=_credit_search, string='Total Receivable', multi='dc', help="Total amount this customer owes you."),
'debit': fields.function(_credit_debit_get, fnct_search=_debit_search, string='Total Payable', multi='dc', help="Total amount you have to pay to this supplier."),
'debit_limit': fields.float('Payable Limit'),
+ 'invoices_stat_button': fields.function(_invoices_stat_button, string="Invoices", type='html'),
+ 'journal_items_ids': fields.one2many('account.move.line', 'partner_id', 'Journal Items'),
+ 'journal_items_stat_button': fields.function(_journal_items_stat_button, string='Journal Items', type='html'),
'property_account_payable': fields.property(
type='many2one',
relation='account.account',
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
- <button type="action" string="Invoices"
+ <statbutton type="action"
name="%(account.action_invoice_tree)d"
- context="{'search_default_partner_id': active_id,'default_partner_id': active_id}" groups="account.group_account_invoice"/>
- <button type="action" string="Journal Items" name="%(account.action_account_moves_all_tree)d" groups="account.group_account_user"/>
+ icon="fa-pencil-square-o"
+ context="{'search_default_partner_id': active_id,'default_partner_id': active_id}" groups="account.group_account_invoice">
+ <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_stat_button" attrs="{'readonly':1}"/>
+ </statbutton>
<button type="action" string="Contracts" name="%(account.action_open_partner_analytic_accounts)d"
groups="analytic.group_analytic_accounting"/>
</xpath>
pass
return res
+ def _opportunities_stat_button(self, cr, uid, ids, field_name, arg, context=None):
+ html = "<div><strong>%s</strong> opportunities</div>"
+ return {partner.id: html % len(partner.opportunity_ids) for partner in self.browse(cr, uid, ids, context)}
+ res = {}
+
+ def _meetings_stat_button(self, cr, uid, ids, field_name, arg, context=None):
+ html = "<div><strong>%s</strong> meetings</div>"
+ return {partner.id: html % len(partner.meeting_ids) for partner in self.browse(cr, uid, ids, context)}
+
+ def _calls_stat_button(self, cr, uid, ids, field_name, arg, context=None):
+ html = "<div><strong>%s</strong> calls</div>"
+ return {partner.id: html % len(partner.phonecall_ids) for partner in self.browse(cr, uid, ids, context)}
+
_columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'opportunity_ids': fields.one2many('crm.lead', 'partner_id',\
'Leads and Opportunities', domain=[('probability', 'not in', ['0', '100'])]),
- 'meeting_ids': fields.many2many('calendar.event', 'calendar_event_partner_rel','partner_id', 'meeting_id',
+ 'opportunities_stat_button': fields.function(_opportunities_stat_button, string="Opportunities", type='html'),
+ 'meeting_ids': fields.many2many('calendar.event', 'calendar_event_res_partner_rel','res_partner_id', 'calendar_event_id',
'Meetings'),
+ 'meetings_stat_button': fields.function(_meetings_stat_button, string="Meetings", type='html'),
'phonecall_ids': fields.one2many('crm.phonecall', 'partner_id',\
'Phonecalls'),
+ 'calls_stat_button': fields.function(_calls_stat_button, string="Calls", type='html'),
'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'),
}
<field name="section_id" completion="1" groups="base.group_multi_salesteams"/>
</field>
<xpath expr="//div[@name='buttons']" position="inside">
- <button class="oe_inline" type="action" string="Opportunities"
+ <statbutton class="oe_inline" type="action"
attrs="{'invisible': [('customer', '=', False)]}"
name="%(crm.crm_case_category_act_oppor11)d"
- context="{'search_default_partner_id': active_id}"/>
- <button class="oe_inline" type="action"
- string="Meetings"
+ icon="fa-star"
+ context="{'search_default_partner_id': active_id}">
+ <field string="Opportunities" name="opportunities_stat_button"/>
+ </statbutton>
+ <statbutton class="oe_inline" type="action"
name="%(calendar.action_calendar_event)d"
- context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}"/>
- <button class="oe_inline" type="action" string="Calls"
+ icon="fa-calendar"
+ context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}">
+ <field string="Meetings" name="meetings_stat_button"/>
+ </statbutton>
+ <statbutton class="oe_inline" type="action"
name="%(crm.crm_case_categ_phone_incoming0)d"
- context="{'search_default_partner_id': active_id, 'default_duration': 1.0}" />
+ icon="fa-phone"
+ context="{'search_default_partner_id': active_id, 'default_duration': 1.0}">
+ <field string="Calls" name="calls_stat_button"/>
+ </statbutton>
</xpath>
</data>
</field>