# -*- coding: utf-8 -*-
# © 2014-2016 Barroux Abbey (http://www.barroux.org)
# © 2014-2016 Akretion France (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, fields, api


class ResPartner(models.Model):
    _inherit = 'res.partner'

    tax_receipt_option = fields.Selection([
        ('none', 'None'),
        ('each', 'For Each Donation'),
        ('annual', 'Annual Tax Receipt'),
        ], string='Tax Receipt Option', track_visibility='onchange')
    tax_receipt_ids = fields.One2many(
        'donation.tax.receipt', 'partner_id', string='Tax Receipts')
    tax_receipt_count = fields.Integer(
        compute='_compute_tax_receipt_count', string="# of Tax Receipts",
        readonly=True)

    @api.model
    def _commercial_fields(self):
        res = super(ResPartner, self)._commercial_fields()
        res.append('tax_receipt_option')
        return res

    @api.multi
    @api.depends('tax_receipt_ids')
    def _compute_tax_receipt_count(self):
        for partner in self:
            try:
                partner.tax_receipt_count = len(partner.tax_receipt_ids)
            except:
                partner.tax_receipt_count = 0

# -*- coding: utf-8 -*-
# © 2014-2016 Barroux Abbey (http://www.barroux.org)
# © 2014-2016 Akretion France (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, fields, api


class ResPartner(models.Model):
    _inherit = 'res.partner'

    tax_receipt_option = fields.Selection([
        ('none', 'None'),
        ('each', 'For Each Donation'),
        ('annual', 'Annual Tax Receipt'),
        ], string='Tax Receipt Option', default='each',
        track_visibility='onchange')
    tax_receipt_ids = fields.One2many(
        'donation.tax.receipt', 'partner_id', string='Tax Receipts')
    tax_receipt_count = fields.Integer(
        compute='_compute_tax_receipt_count', string="# of Tax Receipts",
        readonly=True)

    @api.model
    def _commercial_fields(self):
        res = super(ResPartner, self)._commercial_fields()
        res.append('tax_receipt_option')
        return res

    @api.multi
    @api.depends('tax_receipt_ids')
    def _compute_tax_receipt_count(self):
        for partner in self:
            try:
                partner.tax_receipt_count = len(partner.tax_receipt_ids)
            except:
                partner.tax_receipt_count = 0

Change default value for donation_tax_receipt on partners