Skip to content

Commit

Permalink
[IMP] donation: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
albariera committed Jun 22, 2021
1 parent 4a0fc20 commit 20f5188
Show file tree
Hide file tree
Showing 29 changed files with 1,174 additions and 969 deletions.
48 changes: 22 additions & 26 deletions donation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Donation',
'version': '12.0.1.0.0',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'summary': 'Manage donations',
'author': 'Barroux Abbey, Akretion, Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/donation',
'depends': [
'donation_base'
"name": "Donation",
"version": "12.0.1.0.0",
"category": "Accounting & Finance",
"license": "AGPL-3",
"summary": "Manage donations",
"author": "Barroux Abbey, Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/donation",
"depends": ["donation_base"],
"data": [
"security/donation_security.xml",
"security/ir.model.access.csv",
"wizard/tax_receipt_option_switch_view.xml",
"views/donation.xml",
"views/account.xml",
"views/donation_campaign.xml",
"views/users.xml",
"views/partner.xml",
"report/donation_report_view.xml",
"wizard/donation_validate_view.xml",
],
'data': [
'security/donation_security.xml',
'security/ir.model.access.csv',
'wizard/tax_receipt_option_switch_view.xml',
'views/donation.xml',
'views/account.xml',
'views/donation_campaign.xml',
'views/users.xml',
'views/partner.xml',
'report/donation_report_view.xml',
'wizard/donation_validate_view.xml',
],
'post_init_hook': 'update_account_journal',
'demo': [
'demo/donation_demo.xml'
],
'installable': True,
"post_init_hook": "update_account_journal",
"demo": ["demo/donation_demo.xml"],
"installable": True,
}
10 changes: 2 additions & 8 deletions donation/demo/donation_demo.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="quest_origin" model="donation.campaign">
<field name="code">Q1</field>
<field name="name">Quest Christmas 2015</field>
</record>

<record id="prospecting_origin" model="donation.campaign">
<field name="code">P1</field>
<field name="name">Prospecting 2016</field>
</record>

<record id="catalog_origin" model="donation.campaign">
<field name="code">C1</field>
<field name="name">Catalog Q1 2016</field>
</record>

<record id="base.user_demo" model="res.users">
<field name="groups_id" eval="[(4, ref('group_donation_user'))]"/>
<field name="groups_id" eval="[(4, ref('group_donation_user'))]" />
</record>

</odoo>
26 changes: 15 additions & 11 deletions donation/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@
# Copyright 2014-2016 Akretion France
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, fields, api, _
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class AccountJournal(models.Model):
_inherit = 'account.journal'
_inherit = "account.journal"

allow_donation = fields.Boolean('Donation Payment Method')
allow_donation = fields.Boolean("Donation Payment Method")

@api.constrains('type', 'allow_donation')
@api.constrains("type", "allow_donation")
def _check_donation(self):
for journal in self:
if journal.allow_donation and journal.type not in ('bank', 'cash'):
raise ValidationError(_(
"The journal '%s' has the option "
"'Donation Payment Method', so it's type should "
"be 'Cash' or 'Bank and Checks'.") % journal.name)
if journal.allow_donation and journal.type not in ("bank", "cash"):
raise ValidationError(
_(
"The journal '%s' has the option "
"'Donation Payment Method', so it's type should "
"be 'Cash' or 'Bank and Checks'."
)
% journal.name
)

@api.onchange('type')
@api.onchange("type")
def donation_journal_type_change(self):
for journal in self:
if journal.type in ('cash', 'bank'):
if journal.type in ("cash", "bank"):
journal.allow_donation = True
Loading

0 comments on commit 20f5188

Please sign in to comment.