From 42f13cf0f7181614a4ec00aa9138ce950353fa8e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 22 Jul 2016 17:09:00 +0200 Subject: [PATCH 01/71] Start the update to new architecture explained in issue #22 Move from YAML tests to unittest in most modules Use commercial_partner_id for tax receipts (to group tax receipts for a company or a familly) On donation.line, tax_receipt_ok and in_kind are now related stored fields --- donation_base/README.rst | 51 +++++++++ donation_base/__init__.py | 4 + donation_base/__openerp__.py | 29 +++++ donation_base/data/donation_tax_seq.xml | 21 ++++ donation_base/demo/donation_demo.xml | 104 ++++++++++++++++++ donation_base/models/__init__.py | 5 + donation_base/models/donation_tax_receipt.py | 46 ++++++++ donation_base/models/partner.py | 22 ++++ donation_base/models/product.py | 63 +++++++++++ donation_base/report/report.xml | 21 ++++ donation_base/report/report_donationtax.xml | 37 +++++++ donation_base/security/ir.model.access.csv | 2 + .../security/tax_receipt_security.xml | 18 +++ donation_base/views/donation_tax_receipt.xml | 104 ++++++++++++++++++ donation_base/views/partner.xml | 24 ++++ donation_base/views/product.xml | 52 +++++++++ donation_base/wizard/__init__.py | 4 + .../wizard/tax_receipt_annual_create.py | 103 +++++++++++++++++ .../wizard/tax_receipt_annual_create_view.xml | 39 +++++++ donation_base/wizard/tax_receipt_print.py | 42 +++++++ .../wizard/tax_receipt_print_view.xml | 38 +++++++ 21 files changed, 829 insertions(+) create mode 100644 donation_base/README.rst create mode 100644 donation_base/__init__.py create mode 100644 donation_base/__openerp__.py create mode 100644 donation_base/data/donation_tax_seq.xml create mode 100644 donation_base/demo/donation_demo.xml create mode 100644 donation_base/models/__init__.py create mode 100644 donation_base/models/donation_tax_receipt.py create mode 100644 donation_base/models/partner.py create mode 100644 donation_base/models/product.py create mode 100644 donation_base/report/report.xml create mode 100644 donation_base/report/report_donationtax.xml create mode 100644 donation_base/security/ir.model.access.csv create mode 100644 donation_base/security/tax_receipt_security.xml create mode 100644 donation_base/views/donation_tax_receipt.xml create mode 100644 donation_base/views/partner.xml create mode 100644 donation_base/views/product.xml create mode 100644 donation_base/wizard/__init__.py create mode 100644 donation_base/wizard/tax_receipt_annual_create.py create mode 100644 donation_base/wizard/tax_receipt_annual_create_view.xml create mode 100644 donation_base/wizard/tax_receipt_print.py create mode 100644 donation_base/wizard/tax_receipt_print_view.xml diff --git a/donation_base/README.rst b/donation_base/README.rst new file mode 100644 index 000000000..5ad67e89c --- /dev/null +++ b/donation_base/README.rst @@ -0,0 +1,51 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============= +Donation Base +============= + +This is the base module for donations. This module doesn't do anything in itself ; it just adds some properties on products and partners and adds the *donation.tax.receipt* object. + +To get some real features, you should install the *donation* or the *donation_sale* module. To understand the difference between these 2 modules, read `this post `_. + +Configuration +============= + +To configure this module, you need to: + + * create donation products + * set the *Tax Receipt Option* on partners + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/180/9.0 + +Credits +======= + +Contributors +------------ + +* Brother Bernard +* Brother Irénée (Barroux Abbey) +* Alexis de Lattre + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/donation_base/__init__.py b/donation_base/__init__.py new file mode 100644 index 000000000..35e7c9600 --- /dev/null +++ b/donation_base/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import models +from . import wizard diff --git a/donation_base/__openerp__.py b/donation_base/__openerp__.py new file mode 100644 index 000000000..968b2ba34 --- /dev/null +++ b/donation_base/__openerp__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Barroux Abbey (http://www.barroux.org) +# © 2014-2016 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Donation Base', + 'version': '9.0.1.0.0', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Base module for donations', + 'author': 'Barroux Abbey, Akretion, Odoo Community Association (OCA)', + 'website': 'http://www.barroux.org', + 'depends': ['account'], + 'data': [ + 'security/ir.model.access.csv', + 'security/tax_receipt_security.xml', + 'data/donation_tax_seq.xml', + 'views/product.xml', + 'views/partner.xml', + 'views/donation_tax_receipt.xml', + 'report/report.xml', + 'report/report_donationtax.xml', + 'wizard/tax_receipt_annual_create_view.xml', + 'wizard/tax_receipt_print_view.xml', + ], + 'demo': ['demo/donation_demo.xml'], + 'installable': True, +} diff --git a/donation_base/data/donation_tax_seq.xml b/donation_base/data/donation_tax_seq.xml new file mode 100644 index 000000000..3b19ba449 --- /dev/null +++ b/donation_base/data/donation_tax_seq.xml @@ -0,0 +1,21 @@ + + + + + + + + Donation Tax Receipt + donation.tax.receipt + + %(year)s- + 5 + + + + + diff --git a/donation_base/demo/donation_demo.xml b/donation_base/demo/donation_demo.xml new file mode 100644 index 000000000..07c540887 --- /dev/null +++ b/donation_base/demo/donation_demo.xml @@ -0,0 +1,104 @@ + + + + + + + + + Donation + DON + + + + + 0 + service + + + This donation item is eligible for a tax receipt. + + + + + Donation - no tax receipt + DON-NOTAXR + + + + + 0 + service + + + This donation item is not eligible for a tax receipt. + + + + In-Kind Donation + KIND-DON + + + + + + 0 + service + + + This donation item is eligible for a tax receipt. + + + + In-Kind Donation - no tax receipt + KIND-DON-NOTAXR + + + + + + 0 + service + + + This donation item is not eligible for a tax receipt. + + + + + + Rémi Duplat + + 12 rue de l'espérance + 69100 + Villeurbanne + + vincent.duplat@yahoo.example.com + each + + + + Lucie Dubois + + 34 rue Pierre Dupont + 69001 + Lyon + + lucie.dubois@yahoo.example.com + annual + + + + Joe Smith + + Craig Pond Trail + 04431 + East Orland + + + joe.smith@gmail.example.com + none + + + + diff --git a/donation_base/models/__init__.py b/donation_base/models/__init__.py new file mode 100644 index 000000000..53867e6ef --- /dev/null +++ b/donation_base/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +from . import product +from . import partner +from . import donation_tax_receipt diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py new file mode 100644 index 000000000..e06ed1026 --- /dev/null +++ b/donation_base/models/donation_tax_receipt.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Barroux Abbey (http://www.barroux.org) +# © 2014-2016 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api +import openerp.addons.decimal_precision as dp + + +class DonationTaxReceipt(models.Model): + _name = 'donation.tax.receipt' + _description = "Tax Receipt for Donations" + _order = 'id desc' + _rec_name = 'number' + + number = fields.Char(string='Receipt Number') + date = fields.Date( + string='Date', required=True, default=fields.Date.context_today) + donation_date = fields.Date(string='Donation Date') + amount = fields.Monetary( + string='Amount', digits=dp.get_precision('Account'), + currency_field='currency_id') + currency_id = fields.Many2one( + 'res.currency', string='Currency', required=True, ondelete='restrict') + partner_id = fields.Many2one( + 'res.partner', string='Donor', required=True, ondelete='restrict', + domain=[('parent_id', '=', False)]) + company_id = fields.Many2one( + 'res.company', string='Company', required=True, + default=lambda self: self.env['res.company']._company_default_get( + 'donation.tax.receipt')) + print_date = fields.Date(string='Print Date') + type = fields.Selection([ + ('each', 'One-Time Tax Receipt'), + ('annual', 'Annual Tax Receipt'), + ], string='Type', required=True) + + # Maybe we can drop that code with the new seq management on v9 + @api.model + def create(self, vals=None): + if vals is None: + vals = {} + date = vals.get('donation_date') + vals['number'] = self.env['ir.sequence'].with_context( + date=date).next_by_code('donation.tax.receipt') + return super(DonationTaxReceipt, self).create(vals) diff --git a/donation_base/models/partner.py b/donation_base/models/partner.py new file mode 100644 index 000000000..0be33cee0 --- /dev/null +++ b/donation_base/models/partner.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Barroux Abbey (http://www.barroux.org) +# © 2014-2016 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp 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') + + @api.model + def _commercial_fields(self): + res = super(ResPartner, self)._commercial_fields() + res.append('tax_receipt_option') + return res diff --git a/donation_base/models/product.py b/donation_base/models/product.py new file mode 100644 index 000000000..5b228fb95 --- /dev/null +++ b/donation_base/models/product.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Barroux Abbey (http://www.barroux.org) +# © 2014-2016 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + donation = fields.Boolean( + string='Is a Donation', track_visibility='onchange', + help="Specify if the product can be selected in a donation line.") + in_kind_donation = fields.Boolean( + string="In-Kind Donation", track_visibility='onchange') + tax_receipt_ok = fields.Boolean( + string='Is Eligible for a Tax Receipt', track_visibility='onchange', + help="Specify if the product is eligible for a tax receipt") + + @api.onchange('donation') + def _donation_change(self): + if self.donation: + self.type = 'service' + + @api.onchange('in_kind_donation') + def _in_kind_donation_change(self): + if self.in_kind_donation: + self.donation = True + + @api.multi + @api.constrains('donation', 'type') + def donation_check(self): + for product in self: + if product.donation and product.type != 'service': + raise ValidationError(_( + "The product '%s' is a donation, so you must " + "configure it as a Service") % product.name) + if product.in_kind_donation and not product.donation: + raise ValidationError(_( + "The option 'In-Kind Donation' is active on " + "the product '%s', so you must also activate the " + "option 'Is a Donation'.") % product.name) + if product.tax_receipt_ok and not product.donation: + raise ValidationError(_( + "The option 'Is Eligible for a Tax Receipt' is " + "active on the product '%s', so you must also activate " + "the option 'Is a Donation'.") % product.name) + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + @api.onchange('donation') + def _donation_change(self): + if self.donation: + self.type = 'service' + + @api.onchange('in_kind_donation') + def _in_kind_donation_change(self): + if self.in_kind_donation: + self.donation = True diff --git a/donation_base/report/report.xml b/donation_base/report/report.xml new file mode 100644 index 000000000..864556de1 --- /dev/null +++ b/donation_base/report/report.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/donation_base/report/report_donationtax.xml b/donation_base/report/report_donationtax.xml new file mode 100644 index 000000000..1026a60bf --- /dev/null +++ b/donation_base/report/report_donationtax.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + diff --git a/donation_base/security/ir.model.access.csv b/donation_base/security/ir.model.access.csv new file mode 100644 index 000000000..b453effab --- /dev/null +++ b/donation_base/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_donation_tax_receipt_full,Full access on donation.tax.receipt to Config grp,model_donation_tax_receipt,base.group_system,1,1,1,1 diff --git a/donation_base/security/tax_receipt_security.xml b/donation_base/security/tax_receipt_security.xml new file mode 100644 index 000000000..f96a11075 --- /dev/null +++ b/donation_base/security/tax_receipt_security.xml @@ -0,0 +1,18 @@ + + + + + + + + Donation Tax Receipt Multi-company + + ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + + + diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml new file mode 100644 index 000000000..b944be75e --- /dev/null +++ b/donation_base/views/donation_tax_receipt.xml @@ -0,0 +1,104 @@ + + + + + + + + + donation.tax.receipt.form + donation.tax.receipt + +
+ + + + + + + + + + + +
+
+
+ + + + donation.tax.receipt.tree + donation.tax.receipt + + + + + + + + + + + + + + + + + donation.tax.receipt.search + donation.tax.receipt + + + + + + + + + + + + + + + + + donation.tax.receipt.graph + donation.tax.receipt + + + + + + + + + + donation.tax.receipt.pivot + donation.tax.receipt + + + + + + + + + + + Donation Tax Receipt + donation.tax.receipt + tree,form,graph,pivot + + + +
+
diff --git a/donation_base/views/partner.xml b/donation_base/views/partner.xml new file mode 100644 index 000000000..2adafb786 --- /dev/null +++ b/donation_base/views/partner.xml @@ -0,0 +1,24 @@ + + + + + + + + donation.tax.receipt.res.partner.form + res.partner + + + + + + + + + + diff --git a/donation_base/views/product.xml b/donation_base/views/product.xml new file mode 100644 index 000000000..88f6d625e --- /dev/null +++ b/donation_base/views/product.xml @@ -0,0 +1,52 @@ + + + + + + + + donation.product.template.search + product.template + + + + + + + + + + + donation.product.template.form + product.template + + +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
diff --git a/donation_base/wizard/__init__.py b/donation_base/wizard/__init__.py new file mode 100644 index 000000000..8cd4b9675 --- /dev/null +++ b/donation_base/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import tax_receipt_print +from . import tax_receipt_annual_create diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py new file mode 100644 index 000000000..d7ca0f743 --- /dev/null +++ b/donation_base/wizard/tax_receipt_annual_create.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Barroux Abbey (http://www.barroux.org) +# © 2014-2016 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api, _ +from openerp.exceptions import UserError +from datetime import datetime + + +class TaxReceiptAnnualCreate(models.TransientModel): + _name = 'tax.receipt.annual.create' + _description = 'Generate Annual Tax Receipt' + + @api.model + def _default_end_date(self): + return datetime(datetime.today().year - 1, 12, 31) + + @api.model + def _default_start_date(self): + return datetime(datetime.today().year - 1, 1, 1) + + start_date = fields.Date( + 'Start Date', required=True, default=_default_start_date) + end_date = fields.Date( + 'End Date', required=True, default=_default_end_date) + + # TODO: adapt code to make it independant of the donation module + @api.model + def _prepare_annual_tax_receipt(self, partner_id, partner_dict): + vals = { + 'company_id': self.env.user.company_id.id, + 'currency_id': self.env.user.company_id.currency_id.id, + 'amount': partner_dict['amount'], + 'type': 'annual', + 'partner_id': partner_id, + 'date': self.end_date, + 'donation_date': self.end_date, + 'donation_ids': [(6, 0, partner_dict['donation_ids'])], + } + return vals + + @api.multi + def generate_annual_receipts(self): + self.ensure_one() + donations = self.env['donation.donation'].search([ + ('donation_date', '>=', self.start_date), + ('donation_date', '<=', self.end_date), + ('tax_receipt_option', '=', 'annual'), + ('tax_receipt_id', '=', False), + ('tax_receipt_total', '!=', 0), + ('company_id', '=', self.env.user.company_id.id), + ('state', '=', 'done'), + ]) + tax_receipt_annual = {} + # {partner_id: { + # 'amount': amount, + # 'donation_ids': [donation1_id, donation2_id]}} + for donation in donations: + partner_id = donation.commercial_partner_id.id + tax_receipt_amount = donation.tax_receipt_total + if partner_id not in tax_receipt_annual: + tax_receipt_annual[partner_id] = { + 'amount': tax_receipt_amount, + 'donation_ids': [donation.id], + } + else: + tax_receipt_annual[partner_id]['amount'] +=\ + tax_receipt_amount + tax_receipt_annual[partner_id]['donation_ids']\ + .append(donation.id) + + tax_receipt_ids = [] + for partner_id, partner_dict in tax_receipt_annual.iteritems(): + vals = self._prepare_annual_tax_receipt(partner_id, partner_dict) + # Block if the partner already has an annual fiscal receipt + # or an each fiscal receipt + already_tax_receipts = \ + self.env['donation.tax.receipt'].search([ + ('date', '<=', self.end_date), + ('date', '>=', self.start_date), + ('company_id', '=', vals['company_id']), + ('partner_id', '=', vals['partner_id']), + ]) + if already_tax_receipts: + partner = self.env['res.partner'].browse(vals['partner_id']) + raise UserError( + _("The Donor '%s' already has a tax receipt " + "in this timeframe: %s dated %s.") + % (partner.name, already_tax_receipts[0].number, + already_tax_receipts[0].date)) + tax_receipt = self.env['donation.tax.receipt'].create(vals) + tax_receipt_ids.append(tax_receipt.id) + action = { + 'type': 'ir.actions.act_window', + 'name': 'Tax Receipts', + 'res_model': 'donation.tax.receipt', + 'view_mode': 'tree,form,graph', + 'nodestroy': False, + 'target': 'current', + 'domain': [('id', 'in', tax_receipt_ids)], + } + return action diff --git a/donation_base/wizard/tax_receipt_annual_create_view.xml b/donation_base/wizard/tax_receipt_annual_create_view.xml new file mode 100644 index 000000000..ce3806977 --- /dev/null +++ b/donation_base/wizard/tax_receipt_annual_create_view.xml @@ -0,0 +1,39 @@ + + + + + + + + + tax_receipt_annual_create.form + tax.receipt.annual.create + +
+ + + + +
+
+
+
+
+ + + Create Annual Receipts + tax.receipt.annual.create + form + new + + + +
+
diff --git a/donation_base/wizard/tax_receipt_print.py b/donation_base/wizard/tax_receipt_print.py new file mode 100644 index 000000000..317989d7b --- /dev/null +++ b/donation_base/wizard/tax_receipt_print.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Barroux Abbey (http://www.barroux.org) +# © 2014-2016 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api, _ +from openerp.exceptions import UserError + + +class DonationTaxReceiptPrint(models.TransientModel): + _name = 'donation.tax.receipt.print' + _description = 'Print Donation Tax Receipt' + + @api.model + def _get_receipts(self): + return self.env['donation.tax.receipt'].search( + [('print_date', '=', False)]) + + receipt_ids = fields.Many2many( + 'donation.tax.receipt', + column1='print_wizard_id', column2='receipt_id', + string='Receipts To Print', default=_get_receipts) + + @api.multi + def print_receipts(self): + self.ensure_one() + if not self.receipt_ids: + raise UserError( + _('There are no tax receipts to print.')) + datas = { + 'model': 'donation.tax.receipt', + 'ids': self.receipt_ids.ids, + } + today = fields.Date.context_today(self) + self.receipt_ids.write({'print_date': today}) + action = { + 'type': 'ir.actions.report.xml', + 'report_name': 'donation_tax_receipt.report_donationtaxreceipt', + 'data': datas, + 'datas': datas, # for Aeroo + } + return action diff --git a/donation_base/wizard/tax_receipt_print_view.xml b/donation_base/wizard/tax_receipt_print_view.xml new file mode 100644 index 000000000..314d6cfa0 --- /dev/null +++ b/donation_base/wizard/tax_receipt_print_view.xml @@ -0,0 +1,38 @@ + + + + + + + + + donation_tax_receipt_print.form + donation.tax.receipt.print + +
+ + + +
+
+
+
+
+ + + Print Receipts + donation.tax.receipt.print + form + new + + + +
+
From 973f03116c7bd46fa9e1bd3d1121a561fafbbc01 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 25 Jul 2016 00:55:21 +0200 Subject: [PATCH 02/71] Add index=True on fields that are often searched XML code cleanup (remove fields for which he give the default value) --- donation_base/demo/donation_demo.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/donation_base/demo/donation_demo.xml b/donation_base/demo/donation_demo.xml index 07c540887..ae7be3ca8 100644 --- a/donation_base/demo/donation_demo.xml +++ b/donation_base/demo/donation_demo.xml @@ -14,8 +14,6 @@ 0 service - - This donation item is eligible for a tax receipt. @@ -29,8 +27,6 @@ 0 service - - This donation item is not eligible for a tax receipt. @@ -44,8 +40,6 @@ 0 service - - This donation item is eligible for a tax receipt. @@ -59,8 +53,6 @@ 0 service - - This donation item is not eligible for a tax receipt. From 5fffcf6ec381f486069e4a47b8ba72c70b4e832d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 27 Jul 2016 14:50:24 +0200 Subject: [PATCH 03/71] Add module donation_sale Adapt the code of other modules for the introduction of donation_sale --- donation_base/demo/donation_demo.xml | 4 + donation_base/models/donation_tax_receipt.py | 10 ++- donation_base/models/product.py | 9 ++ .../wizard/tax_receipt_annual_create.py | 87 +++++++++---------- 4 files changed, 60 insertions(+), 50 deletions(-) diff --git a/donation_base/demo/donation_demo.xml b/donation_base/demo/donation_demo.xml index ae7be3ca8..8ac82d02e 100644 --- a/donation_base/demo/donation_demo.xml +++ b/donation_base/demo/donation_demo.xml @@ -14,6 +14,7 @@ 0 service + This donation item is eligible for a tax receipt. @@ -27,6 +28,7 @@ 0 service + This donation item is not eligible for a tax receipt. @@ -40,6 +42,7 @@ 0 service + This donation item is eligible for a tax receipt. @@ -53,6 +56,7 @@ 0 service + This donation item is not eligible for a tax receipt. diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index e06ed1026..8d716fd6c 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -15,7 +15,8 @@ class DonationTaxReceipt(models.Model): number = fields.Char(string='Receipt Number') date = fields.Date( - string='Date', required=True, default=fields.Date.context_today) + string='Date', required=True, default=fields.Date.context_today, + index=True) donation_date = fields.Date(string='Donation Date') amount = fields.Monetary( string='Amount', digits=dp.get_precision('Account'), @@ -24,7 +25,7 @@ class DonationTaxReceipt(models.Model): 'res.currency', string='Currency', required=True, ondelete='restrict') partner_id = fields.Many2one( 'res.partner', string='Donor', required=True, ondelete='restrict', - domain=[('parent_id', '=', False)]) + domain=[('parent_id', '=', False)], index=True) company_id = fields.Many2one( 'res.company', string='Company', required=True, default=lambda self: self.env['res.company']._company_default_get( @@ -44,3 +45,8 @@ def create(self, vals=None): vals['number'] = self.env['ir.sequence'].with_context( date=date).next_by_code('donation.tax.receipt') return super(DonationTaxReceipt, self).create(vals) + + @api.model + def update_tax_receipt_annual_dict(self, tax_receipt_annual_dict): + '''This method is inherited in donation and donation_sale + It is called by the tax.receipt.annual.create wizard''' diff --git a/donation_base/models/product.py b/donation_base/models/product.py index 5b228fb95..1899886e0 100644 --- a/donation_base/models/product.py +++ b/donation_base/models/product.py @@ -47,6 +47,15 @@ def donation_check(self): "The option 'Is Eligible for a Tax Receipt' is " "active on the product '%s', so you must also activate " "the option 'Is a Donation'.") % product.name) + # The check below is to make sure that we don't forget to remove + # the default sale VAT tax on the donation product, particularly + # for users of donation_sale. If there are countries that have + # sale tax on donations (!), please tell us and we can remove this + # constraint + if product.donation and product.taxes_id: + raise ValidationError(_( + "There shouldn't have any Customer Taxes on the " + "donation product '%s'.") % product.name) class ProductProduct(models.Model): diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py index d7ca0f743..0159aa3f2 100644 --- a/donation_base/wizard/tax_receipt_annual_create.py +++ b/donation_base/wizard/tax_receipt_annual_create.py @@ -25,72 +25,63 @@ def _default_start_date(self): end_date = fields.Date( 'End Date', required=True, default=_default_end_date) - # TODO: adapt code to make it independant of the donation module @api.model - def _prepare_annual_tax_receipt(self, partner_id, partner_dict): + def _prepare_annual_tax_receipt(self, partner, partner_dict): vals = { 'company_id': self.env.user.company_id.id, 'currency_id': self.env.user.company_id.currency_id.id, 'amount': partner_dict['amount'], 'type': 'annual', - 'partner_id': partner_id, + 'partner_id': partner.id, 'date': self.end_date, 'donation_date': self.end_date, - 'donation_ids': [(6, 0, partner_dict['donation_ids'])], } + # designed to add add O2M fields donation_ids and invoice_ids + vals.update(partner_dict['extra_vals']) return vals + @api.model + def update_tax_receipt_annual_dict( + self, tax_receipt_annual_dict, start_date, end_date, precision): + '''This method is inherited in donation and donation_sale''' + @api.multi def generate_annual_receipts(self): self.ensure_one() - donations = self.env['donation.donation'].search([ - ('donation_date', '>=', self.start_date), - ('donation_date', '<=', self.end_date), - ('tax_receipt_option', '=', 'annual'), - ('tax_receipt_id', '=', False), - ('tax_receipt_total', '!=', 0), + dtro = self.env['donation.tax.receipt'] + tax_receipt_annual_dict = {} + precision = self.env['decimal.precision'].precision_get('Account') + self.env['donation.tax.receipt'].update_tax_receipt_annual_dict( + tax_receipt_annual_dict, self.start_date, self.end_date, + precision) + # {commercial_partner: { + # 'amount': amount, + # 'extra_vals': {donation_ids': [donation1_id, donation2_id]}}} + tax_receipt_ids = [] + existing_annual_receipts = dtro.search([ + ('date', '<=', self.end_date), + ('date', '>=', self.start_date), ('company_id', '=', self.env.user.company_id.id), - ('state', '=', 'done'), + ('type', '=', 'annual'), ]) - tax_receipt_annual = {} - # {partner_id: { - # 'amount': amount, - # 'donation_ids': [donation1_id, donation2_id]}} - for donation in donations: - partner_id = donation.commercial_partner_id.id - tax_receipt_amount = donation.tax_receipt_total - if partner_id not in tax_receipt_annual: - tax_receipt_annual[partner_id] = { - 'amount': tax_receipt_amount, - 'donation_ids': [donation.id], - } - else: - tax_receipt_annual[partner_id]['amount'] +=\ - tax_receipt_amount - tax_receipt_annual[partner_id]['donation_ids']\ - .append(donation.id) + existing_annual_receipts_dict = {} + for receipt in existing_annual_receipts: + existing_annual_receipts_dict[receipt.partner_id] = receipt - tax_receipt_ids = [] - for partner_id, partner_dict in tax_receipt_annual.iteritems(): - vals = self._prepare_annual_tax_receipt(partner_id, partner_dict) - # Block if the partner already has an annual fiscal receipt - # or an each fiscal receipt - already_tax_receipts = \ - self.env['donation.tax.receipt'].search([ - ('date', '<=', self.end_date), - ('date', '>=', self.start_date), - ('company_id', '=', vals['company_id']), - ('partner_id', '=', vals['partner_id']), - ]) - if already_tax_receipts: - partner = self.env['res.partner'].browse(vals['partner_id']) - raise UserError( - _("The Donor '%s' already has a tax receipt " - "in this timeframe: %s dated %s.") - % (partner.name, already_tax_receipts[0].number, - already_tax_receipts[0].date)) - tax_receipt = self.env['donation.tax.receipt'].create(vals) + for partner, partner_dict in tax_receipt_annual_dict.iteritems(): + # Block if the partner already has an annual tax receipt + if partner in existing_annual_receipts_dict: + existing_receipt = existing_annual_receipts_dict[partner] + raise UserError(_( + "The Donor '%s' already has an annual tax receipt " + "in this timeframe: %s dated %s.") + % (partner.name, existing_receipt.number, + existing_receipt.date)) + vals = self._prepare_annual_tax_receipt(partner, partner_dict) + tax_receipt = dtro.create(vals) tax_receipt_ids.append(tax_receipt.id) + if not tax_receipt_ids: + raise UserError(_("No annual tax receipt to generate")) action = { 'type': 'ir.actions.act_window', 'name': 'Tax Receipts', From 7616748b4aadd664103cce17cff08fed76de19f9 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 28 Jul 2016 11:45:35 +0200 Subject: [PATCH 04/71] Set default value on donation.tax.receipt Remove tax via the onchange on donation --- donation_base/models/donation_tax_receipt.py | 3 ++- donation_base/models/product.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index 8d716fd6c..a97b257e0 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -22,7 +22,8 @@ class DonationTaxReceipt(models.Model): string='Amount', digits=dp.get_precision('Account'), currency_field='currency_id') currency_id = fields.Many2one( - 'res.currency', string='Currency', required=True, ondelete='restrict') + 'res.currency', string='Currency', required=True, ondelete='restrict', + default=lambda self: self.env.user.company_id.currency_id.id) partner_id = fields.Many2one( 'res.partner', string='Donor', required=True, ondelete='restrict', domain=[('parent_id', '=', False)], index=True) diff --git a/donation_base/models/product.py b/donation_base/models/product.py index 1899886e0..2a96fd9e4 100644 --- a/donation_base/models/product.py +++ b/donation_base/models/product.py @@ -23,6 +23,8 @@ class ProductTemplate(models.Model): def _donation_change(self): if self.donation: self.type = 'service' + self.taxes_id = False + self.supplier_taxes_id = False @api.onchange('in_kind_donation') def _in_kind_donation_change(self): From e4e1b7651fb29428c0d761392b0fd320c6778b08 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 12 Oct 2016 20:44:28 +0200 Subject: [PATCH 05/71] Port all modules (except donation_thanks) to v10 --- donation_base/README.rst | 10 +++++++++- donation_base/data/donation_tax_seq.xml | 6 ++---- donation_base/demo/donation_demo.xml | 5 ++--- donation_base/models/donation_tax_receipt.py | 7 ++++--- donation_base/models/partner.py | 2 +- donation_base/models/product.py | 4 ++-- donation_base/report/report.xml | 14 ++++++-------- donation_base/views/donation_tax_receipt.xml | 2 -- donation_base/views/partner.xml | 13 +++++-------- donation_base/views/product.xml | 4 ++-- donation_base/wizard/tax_receipt_annual_create.py | 9 ++------- donation_base/wizard/tax_receipt_print.py | 4 ++-- 12 files changed, 37 insertions(+), 43 deletions(-) diff --git a/donation_base/README.rst b/donation_base/README.rst index 5ad67e89c..f1be5712e 100644 --- a/donation_base/README.rst +++ b/donation_base/README.rst @@ -23,7 +23,15 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/180/9.0 + :target: https://runbot.odoo-community.org/runbot/180/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. Credits ======= diff --git a/donation_base/data/donation_tax_seq.xml b/donation_base/data/donation_tax_seq.xml index 3b19ba449..f19f6d0a7 100644 --- a/donation_base/data/donation_tax_seq.xml +++ b/donation_base/data/donation_tax_seq.xml @@ -5,8 +5,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> - - + Donation Tax Receipt @@ -17,5 +16,4 @@ - - + diff --git a/donation_base/demo/donation_demo.xml b/donation_base/demo/donation_demo.xml index 8ac82d02e..b37db5cdc 100644 --- a/donation_base/demo/donation_demo.xml +++ b/donation_base/demo/donation_demo.xml @@ -1,7 +1,6 @@ - - + @@ -96,5 +95,5 @@ none - + diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index a97b257e0..208afde10 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -3,8 +3,8 @@ # © 2014-2016 Akretion France (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api -import openerp.addons.decimal_precision as dp +from odoo import models, fields, api +import odoo.addons.decimal_precision as dp class DonationTaxReceipt(models.Model): @@ -48,6 +48,7 @@ def create(self, vals=None): return super(DonationTaxReceipt, self).create(vals) @api.model - def update_tax_receipt_annual_dict(self, tax_receipt_annual_dict): + def update_tax_receipt_annual_dict( + self, tax_receipt_annual_dict, start_date, end_date, precision): '''This method is inherited in donation and donation_sale It is called by the tax.receipt.annual.create wizard''' diff --git a/donation_base/models/partner.py b/donation_base/models/partner.py index 0be33cee0..66bf4589f 100644 --- a/donation_base/models/partner.py +++ b/donation_base/models/partner.py @@ -3,7 +3,7 @@ # © 2014-2016 Akretion France (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api +from odoo import models, fields, api class ResPartner(models.Model): diff --git a/donation_base/models/product.py b/donation_base/models/product.py index 2a96fd9e4..a2401e9a4 100644 --- a/donation_base/models/product.py +++ b/donation_base/models/product.py @@ -3,8 +3,8 @@ # © 2014-2016 Akretion France (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError class ProductTemplate(models.Model): diff --git a/donation_base/report/report.xml b/donation_base/report/report.xml index 864556de1..c02435b81 100644 --- a/donation_base/report/report.xml +++ b/donation_base/report/report.xml @@ -1,13 +1,12 @@ - - + - - + diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml index b944be75e..84ee0ae81 100644 --- a/donation_base/views/donation_tax_receipt.xml +++ b/donation_base/views/donation_tax_receipt.xml @@ -6,7 +6,6 @@ --> - @@ -100,5 +99,4 @@ - diff --git a/donation_base/views/partner.xml b/donation_base/views/partner.xml index 2adafb786..eefa8ffca 100644 --- a/donation_base/views/partner.xml +++ b/donation_base/views/partner.xml @@ -1,13 +1,11 @@ - - + donation.tax.receipt.res.partner.form @@ -20,5 +18,4 @@ - - + diff --git a/donation_base/views/product.xml b/donation_base/views/product.xml index 88f6d625e..e981eccd1 100644 --- a/donation_base/views/product.xml +++ b/donation_base/views/product.xml @@ -6,7 +6,7 @@ --> - + donation.product.template.search @@ -48,5 +48,5 @@ - + diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py index 0159aa3f2..1d627cd22 100644 --- a/donation_base/wizard/tax_receipt_annual_create.py +++ b/donation_base/wizard/tax_receipt_annual_create.py @@ -3,8 +3,8 @@ # © 2014-2016 Akretion France (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ -from openerp.exceptions import UserError +from odoo import models, fields, api, _ +from odoo.exceptions import UserError from datetime import datetime @@ -40,11 +40,6 @@ def _prepare_annual_tax_receipt(self, partner, partner_dict): vals.update(partner_dict['extra_vals']) return vals - @api.model - def update_tax_receipt_annual_dict( - self, tax_receipt_annual_dict, start_date, end_date, precision): - '''This method is inherited in donation and donation_sale''' - @api.multi def generate_annual_receipts(self): self.ensure_one() diff --git a/donation_base/wizard/tax_receipt_print.py b/donation_base/wizard/tax_receipt_print.py index 317989d7b..8e3002f25 100644 --- a/donation_base/wizard/tax_receipt_print.py +++ b/donation_base/wizard/tax_receipt_print.py @@ -3,8 +3,8 @@ # © 2014-2016 Akretion France (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ -from openerp.exceptions import UserError +from odoo import models, fields, api, _ +from odoo.exceptions import UserError class DonationTaxReceiptPrint(models.TransientModel): From 0867fffa7d0969c3c40d619007be218bce0586cc Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 16 Nov 2016 12:08:33 +0100 Subject: [PATCH 06/71] Add button to access tax receipts from partners --- donation_base/models/partner.py | 14 ++++++++++++++ donation_base/views/donation_tax_receipt.xml | 8 ++++---- donation_base/views/partner.xml | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/donation_base/models/partner.py b/donation_base/models/partner.py index 66bf4589f..06d3ec9c4 100644 --- a/donation_base/models/partner.py +++ b/donation_base/models/partner.py @@ -14,9 +14,23 @@ class ResPartner(models.Model): ('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 diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml index 84ee0ae81..a8b58cac1 100644 --- a/donation_base/views/donation_tax_receipt.xml +++ b/donation_base/views/donation_tax_receipt.xml @@ -59,10 +59,10 @@ - - - + @@ -93,7 +93,7 @@ - Donation Tax Receipt + Donation Tax Receipts donation.tax.receipt tree,form,graph,pivot diff --git a/donation_base/views/partner.xml b/donation_base/views/partner.xml index eefa8ffca..b0f8c14d6 100644 --- a/donation_base/views/partner.xml +++ b/donation_base/views/partner.xml @@ -7,6 +7,13 @@ + + Donation Tax Receipts + donation.tax.receipt + tree,form,graph,pivot + {'search_default_partner_id': active_id} + + donation.tax.receipt.res.partner.form res.partner @@ -15,6 +22,14 @@ + + + From 73f17fe86802a07674e13b87be769a92abb409bd Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 16 Nov 2016 14:55:28 +0100 Subject: [PATCH 07/71] Pylint fixes --- donation_base/{__openerp__.py => __manifest__.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename donation_base/{__openerp__.py => __manifest__.py} (97%) diff --git a/donation_base/__openerp__.py b/donation_base/__manifest__.py similarity index 97% rename from donation_base/__openerp__.py rename to donation_base/__manifest__.py index 968b2ba34..58d02079e 100644 --- a/donation_base/__openerp__.py +++ b/donation_base/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Donation Base', - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'category': 'Accounting & Finance', 'license': 'AGPL-3', 'summary': 'Base module for donations', From 7c6ea29bb26c48e5941ccbe7b878051b8bc858c4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 23 Nov 2016 17:13:53 +0100 Subject: [PATCH 08/71] Add fr translation for donation_base and donation_sale Cleanup a few strings --- donation_base/i18n/fr.po | 397 ++++++++++++++++++ donation_base/models/product.py | 3 +- donation_base/views/donation_tax_receipt.xml | 6 +- .../wizard/tax_receipt_annual_create.py | 2 +- donation_base/wizard/tax_receipt_print.py | 2 +- 5 files changed, 403 insertions(+), 7 deletions(-) create mode 100644 donation_base/i18n/fr.po diff --git a/donation_base/i18n/fr.po b/donation_base/i18n/fr.po new file mode 100644 index 000000000..6ce1bdb4e --- /dev/null +++ b/donation_base/i18n/fr.po @@ -0,0 +1,397 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * donation_base +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-23 15:37+0000\n" +"PO-Revision-Date: 2016-11-23 15:37+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_res_partner_tax_receipt_count +msgid "# of Tax Receipts" +msgstr "Nb de reçus fiscaux" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_amount +msgid "Amount" +msgstr "Montant" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.report_donationtaxreceipt +msgid "Amount Total:" +msgstr "Montant total :" + +#. module: donation_base +#: selection:donation.tax.receipt,type:0 +#: selection:res.partner,tax_receipt_option:0 +msgid "Annual Tax Receipt" +msgstr "Reçu fiscal annuel" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "Annual Tax Receipts" +msgstr "Reçus fiscaux annuels" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_print_form +#: model:ir.ui.view,arch_db:donation_base.tax_receipt_annual_create_form +msgid "Cancel" +msgstr "Annuler" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_company_id +msgid "Company" +msgstr "Société" + +#. module: donation_base +#: model:ir.actions.act_window,name:donation_base.tax_receipt_annual_create_action +msgid "Create Annual Receipts" +msgstr "Créer les reçus annuels" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_create_uid +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_create_uid +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_create_date +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_create_date +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_currency_id +msgid "Currency" +msgstr "Devise" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_date +msgid "Date" +msgstr "Date " + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.report_donationtaxreceipt +msgid "Date:" +msgstr "Date :" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_display_name +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_display_name +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_display_name +msgid "Display Name" +msgstr "Afficher le nom" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.product_template_search_view +#: model:product.product,name:donation_base.product_product_donation +#: model:product.template,name:donation_base.product_product_donation_product_template +msgid "Donation" +msgstr "Don" + +#. module: donation_base +#: model:product.product,name:donation_base.product_product_donation_notaxreceipt +#: model:product.template,name:donation_base.product_product_donation_notaxreceipt_product_template +msgid "Donation - no tax receipt" +msgstr "Don sans reçu fiscal" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_donation_date +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "Donation Date" +msgstr "Date du don" + +#. module: donation_base +#: model:ir.actions.report.xml,name:donation_base.report_donation_tax_receipt +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_form +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_tree +#: model:ir.ui.view,arch_db:donation_base.report_donationtaxreceipt +msgid "Donation Tax Receipt" +msgstr "Reçu fiscal de don" + +#. module: donation_base +#: model:ir.actions.act_window,name:donation_base.donation_tax_receipt_action +#: model:ir.actions.act_window,name:donation_base.partner_tax_receipt_action +msgid "Donation Tax Receipts" +msgstr "Reçus fiscaux de dons" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_graph +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_pivot +msgid "Donation Taxes Receipts" +msgstr "Reçus fiscaux de dons" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_partner_id +msgid "Donor" +msgstr "Donateur" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.report_donationtaxreceipt +msgid "Donor:" +msgstr "Donateur :" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.product_template_search_view +msgid "Eligible for a Tax Receipt" +msgstr "Éligible reçu fiscal" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_end_date +msgid "End Date" +msgstr "Date de fin" + +#. module: donation_base +#: selection:res.partner,tax_receipt_option:0 +msgid "For Each Donation" +msgstr "Pour chaque don" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.tax_receipt_annual_create_form +msgid "Generate" +msgstr "Générer" + +#. module: donation_base +#: model:ir.model,name:donation_base.model_tax_receipt_annual_create +msgid "Generate Annual Tax Receipt" +msgstr "Générer les reçus fiscaux annuels" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.tax_receipt_annual_create_form +msgid "Generate Annual Tax Receipts" +msgstr "Générer les reçus fiscaux annuels" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "Group By" +msgstr "Regrouper par" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_id +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_id +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_id +msgid "ID" +msgstr "ID" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_product_product_in_kind_donation +#: model:ir.model.fields,field_description:donation_base.field_product_template_in_kind_donation +#: model:product.product,name:donation_base.product_product_inkind_donation +#: model:product.template,name:donation_base.product_product_inkind_donation_product_template +msgid "In-Kind Donation" +msgstr "Don en nature" + +#. module: donation_base +#: model:product.product,name:donation_base.product_product_inkind_donation_notaxreceipt +#: model:product.template,name:donation_base.product_product_inkind_donation_notaxreceipt_product_template +msgid "In-Kind Donation - no tax receipt" +msgstr "Don en nature sans reçu fiscal" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_product_product_tax_receipt_ok +#: model:ir.model.fields,field_description:donation_base.field_product_template_tax_receipt_ok +msgid "Is Eligible for a Tax Receipt" +msgstr "Est éligible à l'émission d'un reçu fiscal" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_product_product_donation +#: model:ir.model.fields,field_description:donation_base.field_product_template_donation +msgid "Is a Donation" +msgstr "Est un don" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt___last_update +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print___last_update +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create___last_update +msgid "Last Modified on" +msgstr "Dernière Modification le" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_write_uid +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_write_uid +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_write_date +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_write_date +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: donation_base +#: code:addons/donation_base/wizard/tax_receipt_annual_create.py:79 +#, python-format +msgid "No annual tax receipt to generate" +msgstr "Aucun reçu fiscal à générer" + +#. module: donation_base +#: selection:res.partner,tax_receipt_option:0 +msgid "None" +msgstr "Aucun" + +#. module: donation_base +#: selection:donation.tax.receipt,type:0 +msgid "One-Time Tax Receipt" +msgstr "Reçu fiscal ponctuel" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "One-Time Tax Receipts" +msgstr "Reçus fiscaux ponctuels" + +#. module: donation_base +#: model:ir.model,name:donation_base.model_res_partner +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "Partner" +msgstr "Partenaire" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_date +msgid "Print Date" +msgstr "Date d'impression" + +#. module: donation_base +#: model:ir.model,name:donation_base.model_donation_tax_receipt_print +msgid "Print Donation Tax Receipt" +msgstr "Impression du reçu fiscal" + +#. module: donation_base +#: model:ir.actions.act_window,name:donation_base.donation_tax_receipt_print_action +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_print_form +msgid "Print Receipts" +msgstr "Imprimer les reçus" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_print_form +msgid "Print Tax Receipts" +msgstr "Imprimer les reçus fiscaux" + +#. module: donation_base +#: model:ir.model,name:donation_base.model_product_product +msgid "Product" +msgstr "Article" + +#. module: donation_base +#: model:ir.model,name:donation_base.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_number +msgid "Receipt Number" +msgstr "Numéro du reçu" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_print_receipt_ids +msgid "Receipts To Print" +msgstr "Reçus à imprimer" + +#. module: donation_base +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "Search Donation Taxes Receipts" +msgstr "Rechercher dans les reçus fiscaux" + +#. module: donation_base +#: model:ir.model.fields,help:donation_base.field_product_product_donation +#: model:ir.model.fields,help:donation_base.field_product_template_donation +msgid "Specify if the product can be selected in a donation line." +msgstr "Définit si l'article peut être sélectionné dans une ligne de don." + +#. module: donation_base +#: model:ir.model.fields,help:donation_base.field_product_product_tax_receipt_ok +#: model:ir.model.fields,help:donation_base.field_product_template_tax_receipt_ok +msgid "Specify if the product is eligible for a tax receipt" +msgstr "Définit si l'article est éligible à l'émission d'un reçu fiscal" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_tax_receipt_annual_create_start_date +msgid "Start Date" +msgstr "Date de début" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_res_partner_tax_receipt_option +msgid "Tax Receipt Option" +msgstr "Option pour le reçu fiscal" + +#. module: donation_base +#: model:ir.model,name:donation_base.model_donation_tax_receipt +msgid "Tax Receipt for Donations" +msgstr "Reçu fiscal pour les dons" + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_res_partner_tax_receipt_ids +#: model:ir.ui.view,arch_db:donation_base.view_partner_property_form +msgid "Tax Receipts" +msgstr "Reçus fiscaux" + +#. module: donation_base +#: code:addons/donation_base/wizard/tax_receipt_annual_create.py:70 +#, python-format +msgid "The Donor '%s' already has an annual tax receipt in this timeframe: %s dated %s." +msgstr "Le donateur '%s' a déjà un reçu fiscal annuel dans cet intervalle de temps: %s daté du %s." + +#. module: donation_base +#: code:addons/donation_base/models/product.py:43 +#, python-format +msgid "The option 'In-Kind Donation' is active on the product '%s', so you must also activate the option 'Is a Donation'." +msgstr "L'option 'Don en nature' est activée sur l'article '%s', donc vous devez également activer l'option 'Est un don'." + +#. module: donation_base +#: code:addons/donation_base/models/product.py:48 +#, python-format +msgid "The option 'Is Eligible for a Tax Receipt' is active on the product '%s', so you must also activate the option 'Is a Donation'." +msgstr "L'option 'Éligible au reçu fiscal' est activée sur l'article '%s', donc vous devez également activer l'option 'Est un don'." + +#. module: donation_base +#: code:addons/donation_base/models/product.py:39 +#, python-format +msgid "The product '%s' is a donation, so you must configure it as a Service" +msgstr "L'article '%s' est un don, donc il doit être de type 'service'" + +#. module: donation_base +#: code:addons/donation_base/wizard/tax_receipt_print.py:29 +#, python-format +msgid "There are no tax receipts to print." +msgstr "Il n'y a aucun reçu fiscal à imprimer." + +#. module: donation_base +#: code:addons/donation_base/models/product.py:58 +#, python-format +msgid "There shouldn't have any Customer Taxes on the donation product '%s'." +msgstr "Il ne devrait y avoir aucune taxe à la vente sur l'article de don '%s'." + +#. module: donation_base +#: model:product.product,description:donation_base.product_product_donation +#: model:product.product,description:donation_base.product_product_inkind_donation +#: model:product.template,description:donation_base.product_product_donation_product_template +#: model:product.template,description:donation_base.product_product_inkind_donation_product_template +msgid "This donation item is eligible for a tax receipt." +msgstr "Cet article est éligible au reçu fiscal." + +#. module: donation_base +#: model:product.product,description:donation_base.product_product_donation_notaxreceipt +#: model:product.product,description:donation_base.product_product_inkind_donation_notaxreceipt +#: model:product.template,description:donation_base.product_product_donation_notaxreceipt_product_template +#: model:product.template,description:donation_base.product_product_inkind_donation_notaxreceipt_product_template +msgid "This donation item is not eligible for a tax receipt." +msgstr "Cet article n'est pas éligible au reçu fiscal." + +#. module: donation_base +#: model:ir.model.fields,field_description:donation_base.field_donation_tax_receipt_type +#: model:ir.ui.view,arch_db:donation_base.donation_tax_receipt_search +msgid "Type" +msgstr "Type" + diff --git a/donation_base/models/product.py b/donation_base/models/product.py index a2401e9a4..08fd1d3fd 100644 --- a/donation_base/models/product.py +++ b/donation_base/models/product.py @@ -11,8 +11,7 @@ class ProductTemplate(models.Model): _inherit = 'product.template' donation = fields.Boolean( - string='Is a Donation', track_visibility='onchange', - help="Specify if the product can be selected in a donation line.") + string='Is a Donation', track_visibility='onchange') in_kind_donation = fields.Boolean( string="In-Kind Donation", track_visibility='onchange') tax_receipt_ok = fields.Boolean( diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml index a8b58cac1..1fa7348e1 100644 --- a/donation_base/views/donation_tax_receipt.xml +++ b/donation_base/views/donation_tax_receipt.xml @@ -51,7 +51,7 @@ donation.tax.receipt.search donation.tax.receipt - + donation.tax.receipt.graph donation.tax.receipt - + @@ -84,7 +84,7 @@ donation.tax.receipt.pivot donation.tax.receipt - + diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py index 1d627cd22..4f21695de 100644 --- a/donation_base/wizard/tax_receipt_annual_create.py +++ b/donation_base/wizard/tax_receipt_annual_create.py @@ -10,7 +10,7 @@ class TaxReceiptAnnualCreate(models.TransientModel): _name = 'tax.receipt.annual.create' - _description = 'Generate Annual Tax Receipt' + _description = 'Generate Annual Tax Receipts' @api.model def _default_end_date(self): diff --git a/donation_base/wizard/tax_receipt_print.py b/donation_base/wizard/tax_receipt_print.py index 8e3002f25..c5f468aa8 100644 --- a/donation_base/wizard/tax_receipt_print.py +++ b/donation_base/wizard/tax_receipt_print.py @@ -9,7 +9,7 @@ class DonationTaxReceiptPrint(models.TransientModel): _name = 'donation.tax.receipt.print' - _description = 'Print Donation Tax Receipt' + _description = 'Print Donation Tax Receipts' @api.model def _get_receipts(self): From 39d369bb0e3837ece01bd1adec3da02dc224808c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 5 Jan 2017 10:14:08 +0100 Subject: [PATCH 09/71] Inherit action_invoice_paid() instead of using a cron to generate tax receipts for invoices --- donation_base/data/donation_tax_seq.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/donation_base/data/donation_tax_seq.xml b/donation_base/data/donation_tax_seq.xml index f19f6d0a7..1fbb40ad2 100644 --- a/donation_base/data/donation_tax_seq.xml +++ b/donation_base/data/donation_tax_seq.xml @@ -10,10 +10,9 @@ Donation Tax Receipt donation.tax.receipt - - %(year)s- + %(range_year)s- + 5 - From e97b40f7096f4b35cd23ee7791b3d8b0433d9ea1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 24 Jan 2017 15:45:55 +0100 Subject: [PATCH 10/71] Change default value for donation_tax_receipt on partners --- donation_base/models/partner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/donation_base/models/partner.py b/donation_base/models/partner.py index 06d3ec9c4..0d3c8201c 100644 --- a/donation_base/models/partner.py +++ b/donation_base/models/partner.py @@ -13,7 +13,8 @@ class ResPartner(models.Model): ('none', 'None'), ('each', 'For Each Donation'), ('annual', 'Annual Tax Receipt'), - ], string='Tax Receipt Option', track_visibility='onchange') + ], 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( From eb8e4bc2575c5d3a88fd205667d60dae696ace27 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 26 Jan 2017 14:55:01 +0100 Subject: [PATCH 11/71] Tax receipt subtotal now includes donations in foreign currencies 'Account' decimal precision doesn't exist in v10 -> use currency precision Add Eligible tax receipt amount in donation report --- donation_base/models/donation_tax_receipt.py | 7 +++---- donation_base/wizard/tax_receipt_annual_create.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index 208afde10..ceb46435a 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -4,7 +4,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields, api -import odoo.addons.decimal_precision as dp class DonationTaxReceipt(models.Model): @@ -19,8 +18,7 @@ class DonationTaxReceipt(models.Model): index=True) donation_date = fields.Date(string='Donation Date') amount = fields.Monetary( - string='Amount', digits=dp.get_precision('Account'), - currency_field='currency_id') + string='Amount', currency_field='currency_id') currency_id = fields.Many2one( 'res.currency', string='Currency', required=True, ondelete='restrict', default=lambda self: self.env.user.company_id.currency_id.id) @@ -49,6 +47,7 @@ def create(self, vals=None): @api.model def update_tax_receipt_annual_dict( - self, tax_receipt_annual_dict, start_date, end_date, precision): + self, tax_receipt_annual_dict, start_date, end_date, + precision_rounding): '''This method is inherited in donation and donation_sale It is called by the tax.receipt.annual.create wizard''' diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py index 4f21695de..579f026e3 100644 --- a/donation_base/wizard/tax_receipt_annual_create.py +++ b/donation_base/wizard/tax_receipt_annual_create.py @@ -45,10 +45,10 @@ def generate_annual_receipts(self): self.ensure_one() dtro = self.env['donation.tax.receipt'] tax_receipt_annual_dict = {} - precision = self.env['decimal.precision'].precision_get('Account') + precision_rounding = self.env.user.company_id.currency_id.rounding self.env['donation.tax.receipt'].update_tax_receipt_annual_dict( tax_receipt_annual_dict, self.start_date, self.end_date, - precision) + precision_rounding) # {commercial_partner: { # 'amount': amount, # 'extra_vals': {donation_ids': [donation1_id, donation2_id]}}} From 759c6bd662e3706fa6767374d07d070e6379838b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 30 Jan 2017 09:53:16 +0100 Subject: [PATCH 12/71] Add ACL for donation_tax_receipt --- donation_base/security/ir.model.access.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/donation_base/security/ir.model.access.csv b/donation_base/security/ir.model.access.csv index b453effab..9e503c30f 100644 --- a/donation_base/security/ir.model.access.csv +++ b/donation_base/security/ir.model.access.csv @@ -1,2 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_donation_tax_receipt_full,Full access on donation.tax.receipt to Config grp,model_donation_tax_receipt,base.group_system,1,1,1,1 +access_donation_tax_receipt_account_full,Full access on donation.tax.receipt to Accounting Manager,model_donation_tax_receipt,account.group_account_manager,1,1,1,1 +access_donation_tax_receipt_account_invoice,Create access on donation.tax.receipt to Billing group,model_donation_tax_receipt,account.group_account_invoice,1,0,1,0 From 71bfc2ffbbd2945f28215ef86a2c294af61eda2a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 9 Feb 2017 09:08:07 +0100 Subject: [PATCH 13/71] Add log message for the generation of annual fiscal receipts --- donation_base/wizard/tax_receipt_annual_create.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py index 579f026e3..3613067d8 100644 --- a/donation_base/wizard/tax_receipt_annual_create.py +++ b/donation_base/wizard/tax_receipt_annual_create.py @@ -6,6 +6,9 @@ from odoo import models, fields, api, _ from odoo.exceptions import UserError from datetime import datetime +import logging + +logger = logging.getLogger(__name__) class TaxReceiptAnnualCreate(models.TransientModel): @@ -43,6 +46,9 @@ def _prepare_annual_tax_receipt(self, partner, partner_dict): @api.multi def generate_annual_receipts(self): self.ensure_one() + logger.info( + 'Start to generate annual fiscal receipts from %s to %s', + self.start_date, self.end_date) dtro = self.env['donation.tax.receipt'] tax_receipt_annual_dict = {} precision_rounding = self.env.user.company_id.currency_id.rounding @@ -54,8 +60,8 @@ def generate_annual_receipts(self): # 'extra_vals': {donation_ids': [donation1_id, donation2_id]}}} tax_receipt_ids = [] existing_annual_receipts = dtro.search([ - ('date', '<=', self.end_date), - ('date', '>=', self.start_date), + ('donation_date', '<=', self.end_date), + ('donation_date', '>=', self.start_date), ('company_id', '=', self.env.user.company_id.id), ('type', '=', 'annual'), ]) @@ -70,13 +76,16 @@ def generate_annual_receipts(self): raise UserError(_( "The Donor '%s' already has an annual tax receipt " "in this timeframe: %s dated %s.") - % (partner.name, existing_receipt.number, + % (partner.name_get()[0][1], existing_receipt.number, existing_receipt.date)) vals = self._prepare_annual_tax_receipt(partner, partner_dict) tax_receipt = dtro.create(vals) tax_receipt_ids.append(tax_receipt.id) + logger.info('Tax receipt %s generated', tax_receipt.number) if not tax_receipt_ids: raise UserError(_("No annual tax receipt to generate")) + logger.info( + '%d annual fiscal receipts generated', len(tax_receipt_ids)) action = { 'type': 'ir.actions.act_window', 'name': 'Tax Receipts', From d75d920da85ff1a6a8f18ff2f20f1594a061c70e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 12 Apr 2017 17:19:39 +0200 Subject: [PATCH 14/71] Add "send by email" button on donation tax receipts --- donation_base/__manifest__.py | 5 ++- donation_base/data/donation_mail_template.xml | 37 +++++++++++++++++++ donation_base/models/donation_tax_receipt.py | 30 ++++++++++++++- donation_base/views/donation_tax_receipt.xml | 33 +++++++++++------ 4 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 donation_base/data/donation_mail_template.xml diff --git a/donation_base/__manifest__.py b/donation_base/__manifest__.py index 58d02079e..e48f1392b 100644 --- a/donation_base/__manifest__.py +++ b/donation_base/__manifest__.py @@ -15,12 +15,13 @@ 'data': [ 'security/ir.model.access.csv', 'security/tax_receipt_security.xml', + 'report/report.xml', + 'report/report_donationtax.xml', 'data/donation_tax_seq.xml', + 'data/donation_mail_template.xml', 'views/product.xml', 'views/partner.xml', 'views/donation_tax_receipt.xml', - 'report/report.xml', - 'report/report_donationtax.xml', 'wizard/tax_receipt_annual_create_view.xml', 'wizard/tax_receipt_print_view.xml', ], diff --git a/donation_base/data/donation_mail_template.xml b/donation_base/data/donation_mail_template.xml new file mode 100644 index 000000000..d05781820 --- /dev/null +++ b/donation_base/data/donation_mail_template.xml @@ -0,0 +1,37 @@ + + + + + + + + Donation Tax Receipt - Send by Email + ${(user.email and '%s <%s>' % (user.name, user.email) or '')|safe} + ${object.company_id.name} - Tax Receipt ${object.number or 'n/a'} + ${object.partner_id.id} + + + + ${object.company_id.name.replace(' ', '_')}-Tax_Receipt_${(object.number or '').replace('/','_')} + ${object.partner_id.lang} + Dear ${object.partner_id.name} +% if object.partner_id.parent_id: + (${object.partner_id.parent_id.name}) +% endif +,

+ +

Please find enclosed your tax receipt ${object.number} +amounting in ${object.amount} ${object.currency_id.name} +from ${object.company_id.name}. +

+ +

Thank you very much for your donation.

+]]>
+
+ + +
diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index ceb46435a..2468ec98a 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -3,7 +3,8 @@ # © 2014-2016 Akretion France (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api +from odoo import models, fields, api, _ +from odoo.exceptions import UserError class DonationTaxReceipt(models.Model): @@ -11,6 +12,7 @@ class DonationTaxReceipt(models.Model): _description = "Tax Receipt for Donations" _order = 'id desc' _rec_name = 'number' + _inherit = ['mail.thread'] number = fields.Char(string='Receipt Number') date = fields.Date( @@ -51,3 +53,29 @@ def update_tax_receipt_annual_dict( precision_rounding): '''This method is inherited in donation and donation_sale It is called by the tax.receipt.annual.create wizard''' + + def action_send_tax_receipt(self): + self.ensure_one() + if not self.partner_id.email: + raise UserError(_( + "Missing email on partner '%s'.") + % self.partner_id.name_get()[0][1]) + template = self.env.ref('donation_base.tax_receipt_email_template') + compose_form = self.env.ref('mail.email_compose_message_wizard_form') + ctx = dict( + default_model='donation.tax.receipt', + default_res_id=self.id, + default_use_template=bool(template), + default_template_id=template.id, + default_composition_mode='comment', + ) + action = { + 'name': _('Compose Email'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'view_id': compose_form.id, + 'target': 'new', + 'context': ctx, + } + return action diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml index 1fa7348e1..bfdb85a5f 100644 --- a/donation_base/views/donation_tax_receipt.xml +++ b/donation_base/views/donation_tax_receipt.xml @@ -1,7 +1,7 @@ @@ -13,17 +13,26 @@ donation.tax.receipt
- - - - - - - - - - - +
+
+ + + + + + + + + + + + + +
+ + +
From bce2631acfb99420a20a833b152985d9770cae39 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 12 Jun 2017 19:32:25 +0200 Subject: [PATCH 15/71] Archive donation.tax.receipt reports by default (like invoices) Add print button on donation tax receipt form view --- donation_base/models/donation_tax_receipt.py | 13 +++++++++++++ donation_base/report/report.xml | 2 ++ donation_base/views/donation_tax_receipt.xml | 1 + 3 files changed, 16 insertions(+) diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index 2468ec98a..255ef2823 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -79,3 +79,16 @@ def action_send_tax_receipt(self): 'context': ctx, } return action + + def action_print(self): + self.ensure_one() + action = { + 'type': 'ir.actions.report.xml', + 'report_name': 'donation_tax_receipt.report_donationtaxreceipt', + 'datas': { + 'model': self._name, + 'ids': self.ids, + }, + 'context': self._context, + } + return action diff --git a/donation_base/report/report.xml b/donation_base/report/report.xml index c02435b81..d9bb2a7c9 100644 --- a/donation_base/report/report.xml +++ b/donation_base/report/report.xml @@ -14,6 +14,8 @@ report_type="qweb-pdf" name="donation_tax_receipt.report_donationtaxreceipt" file="donation_tax_receipt.report_donationtaxreceipt" + attachment_use="True" + attachment="'Fiscal_receipt-'+(object.number or '').replace('/','')+'.pdf'" /> diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml index bfdb85a5f..8f093ab3a 100644 --- a/donation_base/views/donation_tax_receipt.xml +++ b/donation_base/views/donation_tax_receipt.xml @@ -15,6 +15,7 @@
From 797811df086e9a15f1fb6c22d762c9493f6c4d93 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 12 Jun 2017 19:46:48 +0200 Subject: [PATCH 16/71] Qweb donation tax receipt report --- donation_base/models/donation_tax_receipt.py | 2 +- donation_base/report/report.xml | 4 ++-- donation_base/report/report_donationtax.xml | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py index 255ef2823..bd26cd960 100644 --- a/donation_base/models/donation_tax_receipt.py +++ b/donation_base/models/donation_tax_receipt.py @@ -84,7 +84,7 @@ def action_print(self): self.ensure_one() action = { 'type': 'ir.actions.report.xml', - 'report_name': 'donation_tax_receipt.report_donationtaxreceipt', + 'report_name': 'donation_base.report_donationtaxreceipt', 'datas': { 'model': self._name, 'ids': self.ids, diff --git a/donation_base/report/report.xml b/donation_base/report/report.xml index d9bb2a7c9..c86e99bcc 100644 --- a/donation_base/report/report.xml +++ b/donation_base/report/report.xml @@ -12,8 +12,8 @@ model="donation.tax.receipt" string="Donation Tax Receipt" report_type="qweb-pdf" - name="donation_tax_receipt.report_donationtaxreceipt" - file="donation_tax_receipt.report_donationtaxreceipt" + name="donation_base.report_donationtaxreceipt" + file="donation_base.report_donationtaxreceipt" attachment_use="True" attachment="'Fiscal_receipt-'+(object.number or '').replace('/','')+'.pdf'" /> diff --git a/donation_base/report/report_donationtax.xml b/donation_base/report/report_donationtax.xml index 1026a60bf..779b4cfc7 100644 --- a/donation_base/report/report_donationtax.xml +++ b/donation_base/report/report_donationtax.xml @@ -6,14 +6,12 @@ --> - -