Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add] Added modules membership_group and mass_mailing_membership_group modules #68

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mass_mailing_membership_group/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
"data/mailing_contact_demo.xml",
"data/res_partner_demo.xml",
],
"auto_install": True,
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="model">membership.group</field>
<field name="inherit_id" ref="membership_group.membership_group_view_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<xpath expr="//field[@name='complete_name']" position="after">
<field name="mailing_list_id" />
</xpath>
</field>
Expand Down
2 changes: 1 addition & 1 deletion membership_contribution/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import models
from . import models
2 changes: 1 addition & 1 deletion membership_contribution/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import res_partner
from . import res_partner
12 changes: 9 additions & 3 deletions membership_group/menuitems.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@

<menuitem
id="membership_group_info_menu"
name="Membership Groups"
name="All"
action="membership_group_action"
parent="membership_group.membership_group_top_menu"
sequence="1"
/>
tarteo marked this conversation as resolved.
Show resolved Hide resolved

<menuitem
id="membership_group_reporting_menu"
name="Reporting"
parent="membership_group.membership_group_top_menu"
sequence="2"
/>

<menuitem
id="membership_group_membership_menu"
name="Membership Group Members"
action="action_membership_group_member"
parent="membership_group.membership_group_top_menu"
sequence="2"
parent="membership_group.membership_group_reporting_menu"
/>

</odoo>
20 changes: 18 additions & 2 deletions membership_group/models/membership_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,39 @@ class MembershipGroup(models.Model):
_description = "Membership Group"
_parent_store = True
_parent_name = "parent_id"
_rec_name = "complete_name"
_order = "complete_name"

name = fields.Char()
complete_name = fields.Char(
compute="_compute_complete_name", recursive=True, store=True
)
membership_group_member_ids = fields.One2many("membership.group.member", "group_id")
parent_id = fields.Many2one(
comodel_name="membership.group", string="Parent Membership Group", index=True
comodel_name="membership.group", string="Parent", index=True
)
child_ids = fields.One2many(
comodel_name="membership.group",
inverse_name="parent_id",
string="Sub Membership Groups",
string="Subgroups",
)
parent_path = fields.Char(index=True, unaccent=False)
partner_ids = fields.Many2many(
"res.partner", string="Contacts", compute="_compute_partner_ids"
)
partner_ids_count = fields.Integer("# of Members", compute="_compute_partner_ids")

@api.depends("name", "parent_id.complete_name")
def _compute_complete_name(self):
for group in self:
if group.parent_id:
group.complete_name = "%s / %s" % (
group.parent_id.complete_name,
group.name,
)
else:
group.complete_name = group.name

@api.depends(
"membership_group_member_ids", "membership_group_member_ids.partner_id"
)
Expand Down
19 changes: 19 additions & 0 deletions membership_group/models/membership_group_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@ class MembershipGroupMember(models.Model):

partner_id = fields.Many2one("res.partner", required=True, ondelete="cascade")
group_id = fields.Many2one("membership.group", required=True, ondelete="cascade")
tarteo marked this conversation as resolved.
Show resolved Hide resolved
wants_to_collaborate = fields.Boolean()
type = fields.Selection(
[
("follower", "Follower"),
("applicant", "Applicant"),
("applicant_follower", "Applicant / Follower"),
("collaborator_follower", "Collaborator / Follower"),
("collaborator", "Collaborator"),
("committee", "Committee"),
],
)

_sql_constraints = [
(
"partner_group_uniq",
"unique(partner_id, group_id)",
"Member already exists for this group!",
)
]
19 changes: 17 additions & 2 deletions membership_group/views/membership_group_member_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,37 @@
<record id="membership_group_member_view_tree" model="ir.ui.view">
<field name="model">membership.group.member</field>
<field name="arch" type="xml">
<tree>
<tree editable="bottom">
<field name="partner_id" />
<field name="group_id" />
<field name="type" />
<field name="wants_to_collaborate" />
</tree>
</field>
</record>

<record id="membership_group_membership_view_pivot" model="ir.ui.view">
<field name="model">membership.group.member</field>
<field name="arch" type="xml">
<pivot string="Membership Group Members" disable_linking="True">
<field name="partner_id" type="row"/>
<field name="group_id" type="row"/>
<field name="type" type="col"/>
</pivot>
</field>
</record>

<record id="membership_group_member_view_search" model="ir.ui.view">
<field name="model">membership.group.member</field>
<field name="arch" type="xml">
<search>
<field name="partner_id" />
<field name="group_id" />
<field name="type" />
<group expand="0" name="claims" string="Group By">
<filter string="Partner" name="partner_id" domain="[]" help="Partner" context="{'group_by':'partner_id'}" />
<filter string="Group" name="group_id" domain="[]" help="Group" context="{'group_by':'group_id'}" />
<filter string="Type" name="type" domain="[]" help="Group" context="{'group_by':'type'}" />
</group>
</search>
</field>
Expand All @@ -28,6 +43,6 @@
<record id="action_membership_group_member" model="ir.actions.act_window">
<field name="name">Membership Group Members</field>
<field name="res_model">membership.group.member</field>
<field name="view_mode">tree</field>
<field name="view_mode">tree,pivot</field>
</record>
</odoo>
4 changes: 2 additions & 2 deletions membership_group/views/membership_group_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="model">membership.group</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="complete_name" />
<field string="Members" name="partner_ids_count" />
</tree>
</field>
Expand Down Expand Up @@ -60,7 +60,7 @@
</tree>
</field>
</page>
<page string="Sub Membership Groups">
<page string="Subgroups">
<field name="child_ids"/>
</page>
</notebook>
Expand Down
14 changes: 9 additions & 5 deletions membership_group/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
</button>
</xpath>
<xpath expr="//field[@name='member_lines']" position="after">
<field name="membership_group_member_ids" nolabel="1" colspan="4">
<tree editable="top">
<field name="group_id" />
</tree>
</field>
<group>
<field name="membership_group_member_ids" string="Groups" colspan="4">
<tree editable="bottom">
<field name="group_id"/>
<field name="type" />
<field name="wants_to_collaborate" />
</tree>
</field>
</group>
</xpath>
</field>
</record>
Expand Down
4 changes: 2 additions & 2 deletions membership_hr/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"website": "https://www.onestein.nl",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this module is installed we have an applications menu in the membership menu, so people working with memberships don't have to switch to recruitement for it.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added applications menu in members->configuration if membership_hr_recruitment module is installed

"depends": [
"membership",
"membership_section",
"membership_group",
"hr",
],
"data": [
"views/hr_employee_view.xml",
"views/hr_department.xml",
"views/membership_section.xml",
"views/membership_group.xml",
],
"demo": [
"data/hr_department_demo.xml",
Expand Down
12 changes: 5 additions & 7 deletions membership_hr/data/hr_department_demo.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<odoo noupdate="1">

<record id="demo_hr_department_section_1" model="hr.department">
<record id="demo_hr_department_group_1" model="hr.department">
<field name="name">Executive Board</field>
</record>

<record id="demo_hr_department_section_2" model="hr.department">
<record id="demo_hr_department_group_2" model="hr.department">
<field name="name">Marketing Team</field>
</record>

<record id="demo_hr_department_section_3" model="hr.department">
<record id="demo_hr_department_group_3" model="hr.department">
<field name="name">Finance Committee</field>
</record>

<record id="demo_hr_department_section_4" model="hr.department">
<record id="demo_hr_department_group_4" model="hr.department">
<field name="name">Youth Club</field>
</record>

</data>
</odoo>
6 changes: 2 additions & 4 deletions membership_hr/data/hr_employee_demo.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<odoo noupdate="1">

<record id="employee_demo_member_1" model="hr.employee">
<field name="name">John Doe</field>
<field name="user_id" ref="user_demo_member_1"/>
<field name="department_id" ref="demo_hr_department_section_1"/>
<field name="department_id" ref="demo_hr_department_group_1"/>
<field name="job_id" ref="job_member"/>
<field name="employee_type">member</field>
<field name="category_ids" eval="[(6, 0, [ref('hr.employee_category_4')])]"/>
</record>

</data>
</odoo>
4 changes: 1 addition & 3 deletions membership_hr/data/hr_job_demo.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<odoo noupdate="1">

<record id="job_member" model="hr.job">
<field name="name">Member</field>
</record>

</data>
</odoo>
6 changes: 2 additions & 4 deletions membership_hr/data/res_users_demo.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<odoo noupdate="1">

<record id="user_demo_member_1" model="res.users">
<field name="partner_id" ref="membership_section.demo_member_1"/>
<field name="partner_id" ref="membership_group.demo_member_1"/>
<field name="login">demo_member</field>
<field name="password">demo_member</field>
<field name="company_id" ref="base.main_company"/>
<field name="groups_id" eval="[Command.set([ref('base.group_user'), ref('base.group_partner_manager'), ref('base.group_allow_export')])]"/>
</record>

</data>
</odoo>
2 changes: 1 addition & 1 deletion membership_hr/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import hr_department
from . import hr_employee_base
from . import hr_employee
from . import membership_section
from . import membership_group
4 changes: 2 additions & 2 deletions membership_hr/models/hr_department.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from odoo import fields, models


class HRDepartment(models.AbstractModel):
class HRDepartment(models.Model):
_inherit = "hr.department"

section_id = fields.Many2one("membership.section")
membership_group_id = fields.Many2one("membership.group")
6 changes: 3 additions & 3 deletions membership_hr/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from odoo import fields, models


class HREmployee(models.AbstractModel):
class HREmployee(models.Model):
_inherit = "hr.employee"

section_membership_ids = fields.One2many(
related="user_partner_id.section_membership_ids"
membership_group_member_ids = fields.One2many(
related="user_partner_id.membership_group_member_ids"
)
36 changes: 36 additions & 0 deletions membership_hr/models/membership_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from odoo import api, fields, models


class MembershipGroup(models.AbstractModel):
_inherit = "membership.group"

department_id = fields.Many2one(
"hr.department",
compute="_compute_department",
inverse="_inverse_department",
store=True,
readonly=False,
)

department_ids = fields.One2many(
"hr.department", "membership_group_id", string="Departments"
)

@api.depends("department_ids")
def _compute_department(self):
for membership_group in self:
membership_group.department_id = (
membership_group.department_ids
and membership_group.department_ids[0]
or False
)

def _inverse_department(self):
hr_department_obj = self.env["hr.department"]
for membership_group in self:
if membership_group.department_ids:
department = hr_department_obj.browse(
membership_group.department_ids[0].id
)
department.membership_group_id = False
membership_group.department_id.membership_group_id = membership_group
34 changes: 0 additions & 34 deletions membership_hr/models/membership_section.py

This file was deleted.

1 change: 1 addition & 0 deletions membership_hr/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_membership_hr
Loading
Loading