from odoo import models, fields, api
|
|
from odoo.exceptions import UserError, ValidationError
|
|
from psycopg2 import sql, DatabaseError
|
|
|
|
from werkzeug import utils
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class partner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
@api.depends('qualifier_ids.partner_id')
|
|
def _compute_qualifier_count(self):
|
|
# The current user may not have access rights for donations
|
|
for partner in self:
|
|
try:
|
|
partner.qualifier_count = len(partner.qualifier_ids)
|
|
except Exception:
|
|
partner.qualifier_count = 0
|
|
|
|
def _compute_address_count(self):
|
|
# The current user may not have access rights for donations
|
|
for partner in self:
|
|
try:
|
|
partner.address_count = len(partner.address_ids)
|
|
except Exception:
|
|
partner.address_count = 0
|
|
|
|
qualifier_ids = fields.One2many(
|
|
'opendons_qualifier.partnerqualifier',
|
|
'partner_id',
|
|
string='Qualifier',
|
|
readonly=True
|
|
)
|
|
qualifier_count = fields.Integer(
|
|
compute='_compute_qualifier_count',
|
|
string="# of Qualifiers",
|
|
readonly=True
|
|
)
|
|
|
|
address_ids = fields.One2many(
|
|
'opendons.partneraddress',
|
|
'partner_id',
|
|
string='Address',
|
|
readonly=True
|
|
)
|
|
address_count = fields.Integer(
|
|
compute='_compute_address_count',
|
|
string="# of Addresses",
|
|
readonly=True
|
|
)
|
|
|