[IMP] removes the testing field testpercent in res.partner and improves the way the buttons are displayed in form view (addon account)
bzr revid: ged@openerp.com-20140317152828-v2den23s32kzaqxh
This commit is contained in:
parent
6fee78b475
commit
aac67e8bc5
|
@ -21,7 +21,6 @@
|
|||
|
||||
from operator import itemgetter
|
||||
import time
|
||||
import random
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
|
@ -163,21 +162,8 @@ class res_partner(osv.osv):
|
|||
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'] or 0
|
||||
res[partner.id] = """
|
||||
<div><strong>%s</strong> Invoices</div>
|
||||
<div>Total: %s</div>
|
||||
""" % (len(partner.invoice_ids), total)
|
||||
return 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 _invoice_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
return {partner.id: len(partner.invoice_ids) 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)}
|
||||
|
@ -210,8 +196,7 @@ class res_partner(osv.osv):
|
|||
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'),
|
||||
'testpercent': fields.function(_test_percent, string="TestPercent", type='float'),
|
||||
'invoice_count': fields.function(_invoice_count, string="Invoices", type='html'),
|
||||
'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(
|
||||
|
|
|
@ -66,10 +66,10 @@
|
|||
<xpath expr="//div[@name='buttons']" position="inside">
|
||||
<button type="action"
|
||||
class="oe_stat_button"
|
||||
icon="fa-pencil-square-o"
|
||||
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}"/>
|
||||
<field string="Invoices" name="invoice_count" widget="statinfo" attrs="{'readonly':1}"/>
|
||||
</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"/>
|
||||
|
|
Loading…
Reference in New Issue