forked from OCA/donation
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start the update to new architecture explained in issue OCA#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
- Loading branch information
1 parent
20f5188
commit 8acbb19
Showing
21 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/OCA/donation/issues/22>`_. | ||
|
||
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 <informatique - at - barroux.org> | ||
* Brother Irénée (Barroux Abbey) | ||
* Alexis de Lattre <[email protected]> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Barroux Abbey (http://www.barroux.org) | ||
# © 2014-2016 Akretion France (Alexis de Lattre <[email protected]>) | ||
# 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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
© 2014-2016 Barroux Abbey (http://www.barroux.org) | ||
© 2014-2016 Akretion France (Alexis de Lattre <[email protected]>) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
|
||
<openerp> | ||
<data noupdate="1"> | ||
|
||
<record id="donation_tax_receipt_seq" model="ir.sequence"> | ||
<field name="name">Donation Tax Receipt</field> | ||
<field name="code">donation.tax.receipt</field> | ||
<!-- <field name="prefix">%(fy)s-</field> --> | ||
<field name="prefix">%(year)s-</field> | ||
<field name="padding">5</field> | ||
<field name="company_id" eval="False"/> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<odoo> | ||
<data noupdate="1"> | ||
|
||
|
||
<!-- PRODUCTS --> | ||
<record id="product_product_donation" model="product.product"> | ||
<field name="name">Donation</field> | ||
<field name="default_code">DON</field> | ||
<field name="categ_id" ref="product.product_category_5"/> | ||
<field name="sale_ok" eval="True"/> | ||
<field name="donation" eval="True"/> | ||
<field name="tax_receipt_ok" eval="True"/> | ||
<field name="list_price">0</field> | ||
<field name="type">service</field> | ||
<field name="uom_id" ref="product.product_uom_unit"/> | ||
<field name="uom_po_id" ref="product.product_uom_unit"/> | ||
<field name="description">This donation item is eligible for a tax receipt.</field> | ||
</record> | ||
|
||
|
||
<record id="product_product_donation_notaxreceipt" model="product.product"> | ||
<field name="name">Donation - no tax receipt</field> | ||
<field name="default_code">DON-NOTAXR</field> | ||
<field name="categ_id" ref="product.product_category_5"/> | ||
<field name="sale_ok" eval="True"/> | ||
<field name="donation" eval="True"/> | ||
<field name="tax_receipt_ok" eval="False"/> | ||
<field name="list_price">0</field> | ||
<field name="type">service</field> | ||
<field name="uom_id" ref="product.product_uom_unit"/> | ||
<field name="uom_po_id" ref="product.product_uom_unit"/> | ||
<field name="description">This donation item is not eligible for a tax receipt.</field> | ||
</record> | ||
|
||
<record id="product_product_inkind_donation" model="product.product"> | ||
<field name="name">In-Kind Donation</field> | ||
<field name="default_code">KIND-DON</field> | ||
<field name="categ_id" ref="product.product_category_5"/> | ||
<field name="sale_ok" eval="True"/> | ||
<field name="donation" eval="True"/> | ||
<field name="tax_receipt_ok" eval="True"/> | ||
<field name="in_kind_donation" eval="True"/> | ||
<field name="list_price">0</field> | ||
<field name="type">service</field> | ||
<field name="uom_id" ref="product.product_uom_unit"/> | ||
<field name="uom_po_id" ref="product.product_uom_unit"/> | ||
<field name="description">This donation item is eligible for a tax receipt.</field> | ||
</record> | ||
|
||
<record id="product_product_inkind_donation_notaxreceipt" model="product.product"> | ||
<field name="name">In-Kind Donation - no tax receipt</field> | ||
<field name="default_code">KIND-DON-NOTAXR</field> | ||
<field name="categ_id" ref="product.product_category_5"/> | ||
<field name="sale_ok" eval="True"/> | ||
<field name="donation" eval="True"/> | ||
<field name="tax_receipt_ok" eval="False"/> | ||
<field name="in_kind_donation" eval="True"/> | ||
<field name="list_price">0</field> | ||
<field name="type">service</field> | ||
<field name="uom_id" ref="product.product_uom_unit"/> | ||
<field name="uom_po_id" ref="product.product_uom_unit"/> | ||
<field name="description">This donation item is not eligible for a tax receipt.</field> | ||
</record> | ||
|
||
|
||
<!-- PARTNERS --> | ||
<record id="donor1" model="res.partner"> | ||
<field name="name">Rémi Duplat</field> | ||
<field name="customer" eval="1"/> | ||
<field name="street">12 rue de l'espérance</field> | ||
<field name="zip">69100</field> | ||
<field name="city">Villeurbanne</field> | ||
<field name="country_id" ref="base.fr"/> | ||
<field name="email">[email protected]</field> | ||
<field name="tax_receipt_option">each</field> | ||
</record> | ||
|
||
<record id="donor2" model="res.partner"> | ||
<field name="name">Lucie Dubois</field> | ||
<field name="customer" eval="1"/> | ||
<field name="street">34 rue Pierre Dupont</field> | ||
<field name="zip">69001</field> | ||
<field name="city">Lyon</field> | ||
<field name="country_id" ref="base.fr"/> | ||
<field name="email">[email protected]</field> | ||
<field name="tax_receipt_option">annual</field> | ||
</record> | ||
|
||
<record id="donor3" model="res.partner"> | ||
<field name="name">Joe Smith</field> | ||
<field name="customer" eval="1"/> | ||
<field name="street">Craig Pond Trail</field> | ||
<field name="zip">04431</field> | ||
<field name="city">East Orland</field> | ||
<field name="state_id" ref="base.state_us_20"/> | ||
<field name="country_id" ref="base.us"/> | ||
<field name="email">[email protected]</field> | ||
<field name="tax_receipt_option">none</field> | ||
</record> | ||
|
||
</data> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import product | ||
from . import partner | ||
from . import donation_tax_receipt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Barroux Abbey (http://www.barroux.org) | ||
# © 2014-2016 Akretion France (Alexis de Lattre <[email protected]>) | ||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Barroux Abbey (http://www.barroux.org) | ||
# © 2014-2016 Akretion France (Alexis de Lattre <[email protected]>) | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Barroux Abbey (http://www.barroux.org) | ||
# © 2014-2016 Akretion France (Alexis de Lattre <[email protected]>) | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) | ||
Copyright (C) 2014-2015 Akretion France (www.akretion.com) | ||
@author: Alexis de Lattre <[email protected]> | ||
The licence is in the file __openerp__.py | ||
--> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<report id="report_donation_tax_receipt" | ||
model="donation.tax.receipt" | ||
string="Donation Tax Receipt" | ||
report_type="qweb-pdf" | ||
name="donation_tax_receipt.report_donationtaxreceipt" | ||
file="donation_tax_receipt.report_donationtaxreceipt" | ||
/> | ||
|
||
</data> | ||
</openerp> |
Oops, something went wrong.