Skip to content

Commit 3ee6d09

Browse files
frva-odoovava-odoo
authored andcommitted
[ADD] ngo: add non-profitable organization module
Add the ngo module, with the following features: - Create and manage your petitions with the possibility for website visitors to sign them. - Handle donations and print fiscal attestations for the donators. - Add datas to help organize these in the new community app. Part-of: #1138 Signed-off-by: Vallaeys Valentin (vava) <[email protected]>
1 parent 21019f4 commit 3ee6d09

File tree

147 files changed

+9170
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+9170
-0
lines changed

.weblate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@
341341
"filemask": "museum/i18n/*.po",
342342
"new_base": "museum/i18n/museum.pot"
343343
},
344+
{
345+
"name": "ngo",
346+
"filemask": "ngo/i18n/*.po",
347+
"new_base": "ngo/i18n/ngo.pot"
348+
},
344349
{
345350
"name": "odoo_partner",
346351
"filemask": "odoo_partner/i18n/*.po",

ngo/__manifest__.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
'name': 'Nonprofit organization',
3+
'version': '2.0',
4+
'category': 'Services',
5+
'depends': [
6+
'base_industry_data',
7+
'documents_project',
8+
'hr_expense',
9+
'hr_sign',
10+
'knowledge',
11+
'mass_mailing',
12+
'partnership',
13+
'sale_pdf_quote_builder',
14+
'sale_planning',
15+
'sale_subscription',
16+
'survey',
17+
'web_studio',
18+
'website_crm',
19+
'website_event_sale',
20+
],
21+
'data': [
22+
'data/ir_attachment.xml',
23+
'data/crm_tag.xml',
24+
'data/crm_stage.xml',
25+
'data/ir_model.xml',
26+
'data/ir_model_fields.xml',
27+
'data/ir_default.xml',
28+
'data/account_report.xml',
29+
'data/account_journal.xml',
30+
'data/ir_actions_act_window.xml',
31+
'data/res_partner_category.xml',
32+
'data/ir_actions_server.xml',
33+
'data/ir_ui_view.xml',
34+
'data/hr_employee_category.xml',
35+
'data/product_category.xml',
36+
'data/product_public_category.xml',
37+
'data/res_partner_grade.xml',
38+
'data/product_template.xml',
39+
'data/product_product.xml',
40+
'data/qweb_view.xml',
41+
'data/ir_ui_menu.xml',
42+
'data/base_automation.xml',
43+
'data/res_config_settings.xml',
44+
'data/ir_model_access.xml',
45+
'data/knowledge_cover.xml',
46+
'data/knowledge_article.xml',
47+
'data/knowledge_article_favorite.xml',
48+
'data/mail_message.xml',
49+
'data/planning_role.xml',
50+
'data/website_page.xml',
51+
'data/website_controller_page.xml',
52+
'data/website_menu.xml',
53+
'data/website_theme_apply.xml',
54+
'data/x_petition_tag.xml',
55+
'data/mail_template.xml',
56+
'data/product_pricelist.xml',
57+
'data/product_pricelist_item.xml',
58+
],
59+
'demo': [
60+
'demo/qweb_view.xml',
61+
'demo/website_page.xml',
62+
'demo/website_menu.xml',
63+
'demo/website_theme_apply.xml',
64+
'demo/product_template.xml',
65+
'demo/project_task_type.xml',
66+
'demo/project_project.xml',
67+
'demo/x_petition.xml',
68+
'demo/event_tag.xml',
69+
'demo/event_event.xml',
70+
'demo/event_event_ticket.xml',
71+
'demo/payment_provider_demo_post.xml',
72+
'demo/res_partner.xml',
73+
'demo/crm_lead.xml',
74+
'demo/hr_employee.xml',
75+
'demo/hr_job.xml',
76+
'demo/hr_expense.xml',
77+
'demo/planning_recurrency.xml',
78+
'demo/planning_slot_template.xml',
79+
'demo/planning_slot.xml',
80+
'demo/project_tags.xml',
81+
'demo/project_task.xml',
82+
'demo/mail_activity.xml',
83+
'demo/sale_order.xml',
84+
'demo/sale_order_line.xml',
85+
'demo/survey_survey.xml',
86+
'demo/survey_question.xml',
87+
'demo/survey_question_answer.xml',
88+
'demo/x_signature.xml',
89+
'demo/sale_order_confirm.xml',
90+
'demo/mailing_mailing.xml',
91+
'demo/website.xml',
92+
],
93+
'license': 'OPL-1',
94+
'author': 'Odoo S.A.',
95+
"cloc_exclude": [
96+
"data/knowledge_article.xml",
97+
"data/qweb_view.xml",
98+
"demo/qweb_view.xml",
99+
],
100+
'images': ['images/main.png'],
101+
}

ngo/data/account_journal.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo noupdate="1">
3+
<record id="account_journal_donations" model="account.journal">
4+
<field name="name">Donations</field>
5+
<field name="type">sale</field>
6+
<field name="code">DON1</field>
7+
<field name="refund_sequence" eval="True"/>
8+
<field name="x_journal_is_donation" eval="True"/>
9+
<field name="invoice_template_pdf_report_id" ref="account_invoices_report"/>
10+
</record>
11+
</odoo>

ngo/data/account_report.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="account_invoices_report" model="ir.actions.report">
4+
<field name="name">Fiscal Attestation PDF</field>
5+
<field name="model">account.move</field>
6+
<field name="report_type">qweb-pdf</field>
7+
<field name="domain">[]</field>
8+
<field name="report_name">ngo.report_fiscal_attestation_with_payments</field>
9+
<field name="report_file">ngo.report_fiscal_attestation_with_payments</field>
10+
<field name="is_invoice_report">True</field>
11+
<field name="print_report_name">(object._get_report_base_filename())</field>
12+
<field name="attachment"/>
13+
<field name="binding_model_id" ref="account.model_account_move"/>
14+
<field name="binding_type">report</field>
15+
<field name="group_ids" eval="[(4, ref('account.group_account_invoice')), (4, ref('account.group_account_readonly'))]"/>
16+
</record>
17+
</odoo>

ngo/data/base_automation.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<odoo>
3+
<record id="add_signatory_category_to_signing_partner" model="base.automation">
4+
<field name="model_id" ref="x_signature_model"/>
5+
<field name="action_server_ids"
6+
eval="[(6, 0, [ref('action_server_add_signatory_category_to_contact')])]"/>
7+
<field name="trigger">on_create_or_write</field>
8+
<field name="name">Add signatory category to signing partner</field>
9+
<field name="trigger_field_ids" eval="[(6, 0, [ref('x_partner_id_field_x_signature')])]"/>
10+
</record>
11+
<record id="base_automation_on_so_confirmation" model="base.automation">
12+
<field name="model_id" ref="sale.model_sale_order"/>
13+
<field name="action_server_ids"
14+
eval="[(6, 0, [ref('action_server_assign_invoicing_journal_to_so')])]"/>
15+
<field name="trigger">on_create_or_write</field>
16+
<field name="name">On Sale Order Confirmation</field>
17+
<field name="trigger_field_ids" eval="[(6, 0, [ref('sale.field_sale_order__state')])]"/>
18+
<field name="filter_domain" eval="[('state', '=', 'sale')]"/>
19+
</record>
20+
</odoo>

ngo/data/crm_stage.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<odoo noupdate="1">
3+
<record id="crm_stage_5" model="crm.stage">
4+
<field name="name">Confirmed</field>
5+
<field name="sequence">3</field>
6+
<field name="is_won" eval="True"/>
7+
</record>
8+
</odoo>

ngo/data/crm_tag.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<odoo noupdate="1">
3+
<record id="crm_tag_1" model="crm.tag">
4+
<field name="name">Petition</field>
5+
</record>
6+
<record id="crm_tag_2" model="crm.tag">
7+
<field name="name">Donor</field>
8+
</record>
9+
<record id="crm_tag_3" model="crm.tag">
10+
<field name="name">Reseller</field>
11+
</record>
12+
<record id="crm_tag_4" model="crm.tag">
13+
<field name="name">Partner</field>
14+
</record>
15+
<record id="crm_tag_5" model="crm.tag">
16+
<field name="name">Mixed Order</field>
17+
</record>
18+
</odoo>

ngo/data/hr_employee_category.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<odoo noupdate="1">
3+
<record id="hr_employee_category_volunteer" model="hr.employee.category">
4+
<field name="name">Volunteer</field>
5+
</record>
6+
<record id="hr_employee_category_founder" model="hr.employee.category">
7+
<field name="name">Founder</field>
8+
</record>
9+
</odoo>

ngo/data/ir_actions_act_window.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<odoo>
3+
<record id="action_window_members" model="ir.actions.act_window">
4+
<field name="name">Members</field>
5+
<field name="res_model">res.partner</field>
6+
<field name="view_mode">kanban,list,form,map</field>
7+
<field name="context">{'group_by': 'grade_id'}</field>
8+
</record>
9+
<record id="action_window_petition" model="ir.actions.act_window">
10+
<field name="name">Petitions</field>
11+
<field name="res_model">x_petition</field>
12+
<field name="view_mode">list,form,kanban,graph,pivot</field>
13+
</record>
14+
<record id="action_window_petition_tag" model="ir.actions.act_window">
15+
<field name="name">Petition Tags</field>
16+
<field name="res_model">x_petition_tag</field>
17+
</record>
18+
<record id="action_window_donations" model="ir.actions.act_window">
19+
<field name="name">Donations</field>
20+
<field name="res_model">sale.order</field>
21+
<field name="domain">[('order_line.product_id.categ_id.x_product_category_is_donation', '!=', False)]</field>
22+
<field name="view_mode">list,form,graph</field>
23+
</record>
24+
<record id="action_window_signature" model="ir.actions.act_window">
25+
<field name="name">Signatures</field>
26+
<field name="res_model">x_signature</field>
27+
<field name="view_mode">list,form,calendar</field>
28+
<field name="context">{'default_x_date': context_today()}</field>
29+
</record>
30+
<record id="petition_related_x_signature" model="ir.actions.act_window">
31+
<field name="context">{'search_default_x_petition_id': active_id,'default_x_petition_id': active_id, 'default_x_date': context_today()}</field>
32+
<field name="domain">[('x_petition_id', '=', active_id)]</field>
33+
<field name="name">Signatures</field>
34+
<field name="res_model">x_signature</field>
35+
</record>
36+
<record id="partner_related_x_signature" model="ir.actions.act_window">
37+
<field name="context">{'search_default_x_partner_id': active_id,'default_x_partner_id': active_id, 'default_x_date': context_today()}</field>
38+
<field name="domain">[('x_partner_id', '=', active_id)]</field>
39+
<field name="name">Signatures</field>
40+
<field name="res_model">x_signature</field>
41+
</record>
42+
</odoo>

ngo/data/ir_actions_server.xml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<odoo>
3+
<record id="action_server_add_signatory_category_to_contact" model="ir.actions.server">
4+
<field name="model_id" ref="x_signature_model"/>
5+
<field name="update_path">x_partner_id.category_id</field>
6+
<field name="state">object_write</field>
7+
<field name="crud_model_id" ref="base.model_res_partner"/>
8+
<field name="name">Update Contact</field>
9+
<field name="update_field_id" ref="base.field_res_partner__category_id"/>
10+
<field name="usage">base_automation</field>
11+
<field name="value" ref="partner_category_signatory"/>
12+
</record>
13+
<record id="action_create_x_signature" model="ir.actions.server">
14+
<field name="code"><![CDATA[
15+
partner = env['res.partner'].sudo().search([('email', '=', request.params.get('email'))], limit=1)
16+
country = env['res.country'].sudo().search([('id', '=', request.params.get('country_id'))], limit=1)
17+
if not partner:
18+
partner = env['res.partner'].sudo().create({
19+
'name': request.params.get('name'),
20+
'email': request.params.get('email'),
21+
'country_id': country.id,
22+
})
23+
else:
24+
partner.write({'name': request.params.get('name'), 'country_id': country.id})
25+
existing_signature = env['x_signature'].sudo().search([('x_partner_id', '=', partner.id), ('x_petition_id', '=', int(request.params.get('petition_id')))], limit=1)
26+
if existing_signature:
27+
response = request.make_json_response({'id': existing_signature.id}, status=200)
28+
elif request.params.get('petition_id'):
29+
new_signature = env['x_signature'].sudo().create({
30+
"x_partner_id": partner.id,
31+
"x_date": datetime.datetime.today().strftime('%Y-%m-%d'),
32+
"x_petition_id": request.params.get('petition_id'),
33+
"x_newsletter": request.params.get('newsletter'),
34+
})
35+
#Force compute the amount of signatures
36+
related_petition = env['x_petition'].sudo().browse([int(request.params.get('petition_id'))])
37+
related_petition.write({'x_current_signatures': env['x_signature'].sudo().search_count([('x_petition_id', '=', int(request.params.get('petition_id')))])})
38+
message = env['mail.message'].sudo().create({
39+
'model': 'x_signature',
40+
'res_id': new_signature.id,
41+
'body': '<p>Comment: '+ request.params.get('comments', '')+'</p>',
42+
'message_type': 'comment',
43+
})
44+
response = request.make_json_response({'id': new_signature.id}, status=200)
45+
]]></field>
46+
<field name="model_id" ref="mail.model_discuss_channel_member"/>
47+
<field name="state">code</field>
48+
<field name="website_published">True</field>
49+
<field name="website_path">new_signature</field>
50+
<field name="name">Create Signature</field>
51+
</record>
52+
<record id="open_x_petition_website_page" model="ir.actions.server">
53+
<field name="code"><![CDATA[
54+
response = {
55+
'type': 'ir.actions.act_url',
56+
'target': 'self',
57+
'url': record.x_website_url,
58+
}
59+
]]></field>
60+
<field name="model_id" ref="x_petition_model"/>
61+
<field name="state">code</field>
62+
<field name="name">Open Petition Website Page</field>
63+
</record>
64+
<record id="action_server_assign_invoicing_journal_to_so" model="ir.actions.server">
65+
<field name="code"><![CDATA[
66+
for so in records:
67+
products_is_donation = so.order_line.mapped('product_id.categ_id.x_product_category_is_donation')
68+
if any(products_is_donation):
69+
so['journal_id'] = env.ref('ngo.account_journal_donations')
70+
if not all(products_is_donation):
71+
so['tag_ids'] = [Command.link(env.ref('ngo.crm_tag_5').id)]
72+
]]></field>
73+
<field name="model_id" ref="sale.model_sale_order"/>
74+
<field name="state">code</field>
75+
<field name="name">action_server_assign_invoicing_journal_to_so</field>
76+
</record>
77+
</odoo>

0 commit comments

Comments
 (0)