[IMP] removes the field journal_items_stat_button field from the res.partner model (the x2many widget replaces its functionality) and improves the view. Also, adds a new field 'testpercent' to res.partner, only for testing purposes (addon account)

bzr revid: ged@openerp.com-20140313125244-k4zgsil19gk5sjcz
This commit is contained in:
Gery Debongnie 2014-03-13 13:52:44 +01:00
parent b7bc8b3aa4
commit 3c835279e8
2 changed files with 8 additions and 9 deletions

View File

@ -21,6 +21,7 @@
from operator import itemgetter
import time
import random
from openerp.osv import fields, osv
@ -168,17 +169,15 @@ class res_partner(osv.osv):
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']
total = group_obj[0]['amount_total'] or 0
res[partner.id] = """
<div><strong>%s</strong> invoices</div>
<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 _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 has_something_to_reconcile(self, cr, uid, partner_id, context=None):
'''
@ -209,8 +208,8 @@ class res_partner(osv.osv):
'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'),
'testpercent': fields.function(_test_percent, string="TestPercent", type='float'),
'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',

View File

@ -66,12 +66,12 @@
<xpath expr="//div[@name='buttons']" position="inside">
<statbutton type="action"
name="%(account.action_invoice_tree)d"
icon="fa-pencil-square-o"
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_stat_button" attrs="{'readonly':1}"/>
<field string="Journal Items" name="journal_items_ids" widget="x2many" attrs="{'readonly':1}"/>
</statbutton>
<button type="action" string="Contracts" name="%(account.action_open_partner_analytic_accounts)d"
groups="analytic.group_analytic_accounting"/>