Files
odoo_source/addons/payment/models/res_partner.py
T
Gaurav Panchal 6b55539dc7 [IMP] res_partner: form view cleaning
Better display of contacts, simplified contact creation, use default image
for shipping and delivery, and various fixes and improvements in the
form view.

Main impacted addons :

 - account: add a bank_account_count field and stat button that replaces the
 2many field
 - base_vat: remove the button to check vat, as there is already a constraint
 and removed and unused import
 - payment: add a payment_method_count field and stat button that replaces
 the 2many field
2015-08-18 10:51:27 +02:00

21 lines
911 B
Python

from openerp.osv import fields, osv
class res_partner(osv.osv):
_name = 'res.partner'
_inherit = 'res.partner'
def _compute_payment_method_count(self, cr, uid, ids, field_names, arg, context=None):
result = {}
payment_data = self.pool['payment.method'].read_group(
cr, uid, [('partner_id', 'in', ids)], ['partner_id'], ['partner_id'], context=context)
mapped_data = dict([(payment['partner_id'][0], payment['partner_id_count']) for payment in payment_data])
for partner in self.browse(cr, uid, ids, context=context):
result[partner.id] = mapped_data.get(partner.id, 0)
return result
_columns = {
'payment_method_ids': fields.one2many('payment.method', 'partner_id', 'Payment Methods'),
'payment_method_count': fields.function(_compute_payment_method_count, string='Count Payment Method', type="integer"),
}