Skip to content

Commit

Permalink
Updated membership modules
Browse files Browse the repository at this point in the history
Added partner_cde module

updates

Changed from AbstractModel to Model

Changes to add applications menu in Members,move wants_to_collaborate and type field to membership_group, made allow_membership_registration True by default

pre-commit fix
  • Loading branch information
ByteMeAsap committed Nov 15, 2024
1 parent 2c9c271 commit 4be4230
Show file tree
Hide file tree
Showing 106 changed files with 2,294 additions and 470 deletions.
1 change: 0 additions & 1 deletion membership_contribution/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from . import models
1 change: 0 additions & 1 deletion membership_contribution/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from . import res_partner
11 changes: 11 additions & 0 deletions membership_group/models/membership_group_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ class MembershipGroupMember(models.Model):

partner_id = fields.Many2one("res.partner", required=True, ondelete="cascade")
group_id = fields.Many2one("membership.group", required=True, ondelete="cascade")
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 = [
(
Expand Down
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: 3 additions & 1 deletion membership_group/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
<xpath expr="//field[@name='member_lines']" position="after">
<group>
<field name="membership_group_member_ids" string="Groups" colspan="4">
<tree editable="top">
<tree editable="bottom">
<field name="group_id"/>
<field name="type" />
<field name="wants_to_collaborate" />
</tree>
</field>
</group>
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",
"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
24 changes: 24 additions & 0 deletions membership_hr/tests/test_membership_hr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo.tests import common


class TestMembershipHr(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
membership_group_obj = cls.env["membership.group"]
hr_department_obj = cls.env["hr.department"]

cls.group_1 = membership_group_obj.create({"name": "Test Group 1"})
cls.group_2 = membership_group_obj.create({"name": "Test Group 2"})
cls.hr_department_1 = hr_department_obj.create({"name": "Test Department 1"})
cls.hr_department_2 = hr_department_obj.create({"name": "Test Department 2"})

def test_01_membership_hr(self):
self.group_1.department_ids = [
(6, 0, [self.hr_department_1.id, self.hr_department_2.id])
]
self.assertEqual(self.group_1.department_id, self.hr_department_1)
self.group_1.department_id = self.hr_department_2.id
self.assertEqual(self.hr_department_2.membership_group_id, self.group_1)
self.group_2.department_id = self.hr_department_1.id
self.assertEqual(self.hr_department_1.membership_group_id, self.group_2)
2 changes: 1 addition & 1 deletion membership_hr/views/hr_department.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name="inherit_id" ref="hr.view_department_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='parent_id']" position="after">
<field name="section_id" />
<field name="membership_group_id" />
</xpath>
</field>
</record>
Expand Down
5 changes: 2 additions & 3 deletions membership_hr/views/hr_employee_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
<xpath expr="//page[last()]" position="after">
<field name="employee_type" invisible="1" />
<page string="Membership" attrs="{'invisible': [('employee_type','!=','member')]}">
<field name="section_membership_ids" string="Sections" nolabel="1" colspan="4">
<field name="membership_group_member_ids" string="Membership Groups" nolabel="1" colspan="4">
<tree editable="top">
<field name="section_id"/>
<field name="start_date"/>
<field name="group_id"/>
</tree>
</field>
</page>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="membership_section_view_tree" model="ir.ui.view">
<field name="model">membership.section</field>
<field name="inherit_id" ref="membership_section.membership_section_view_tree" />
<record id="membership_group_view_tree" model="ir.ui.view">
<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="department_id"/>
</xpath>
</field>
</record>

<record id="membership_section_view_form" model="ir.ui.view">
<field name="model">membership.section</field>
<field name="inherit_id" ref="membership_section.membership_section_view_form" />
<record id="membership_group_view_form" model="ir.ui.view">
<field name="model">membership.group</field>
<field name="inherit_id" ref="membership_group.membership_group_view_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='form_body']" position="inside">
<group name="hr_informations" string="Human Resources">
Expand Down
3 changes: 2 additions & 1 deletion membership_hr_recruitment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"website": "https://www.onestein.nl",
"depends": [
"membership_hr",
"membership_section",
"membership_group",
"hr_recruitment",
],
"data": [
"views/hr_applicant_view.xml",
"menuitems.xml",
],
"demo": [
"data/hr_applicant_demo.xml",
Expand Down
4 changes: 2 additions & 2 deletions membership_hr_recruitment/data/hr_applicant_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<record id="hr_applicant_demo_member_2" model="hr.applicant">
<field name="name">Aspiring Member</field>
<field name="job_id" ref="membership_hr.job_member"/>
<field name="department_id" ref="membership_hr.demo_hr_department_section_4"/>
<field name="department_id" ref="membership_hr.demo_hr_department_group_4"/>
<field name="user_id" ref="base.user_demo"/>
<field name="priority">1</field>
<field name="partner_id" ref="membership_section.demo_member_2" />
<field name="partner_id" ref="membership_group.demo_member_2" />
<field name="partner_name">Jane Smith</field>
<field name="stage_id" ref="hr_recruitment.stage_job1"/>
<field name="membership_applicant" eval="True" />
Expand Down
9 changes: 9 additions & 0 deletions membership_hr_recruitment/menuitems.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

<menuitem
name="Applications"
parent="membership.menu_marketing_config_association"
id="menu_applications" action="hr_recruitment.crm_case_categ0_act_job" />

</odoo>
4 changes: 2 additions & 2 deletions membership_hr_recruitment/models/hr_applicant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class HRApplicant(models.Model):
_inherit = "hr.applicant"

membership_applicant = fields.Boolean()
section_membership_ids = fields.One2many(
related="partner_id.section_membership_ids"
membership_group_member_ids = fields.One2many(
related="partner_id.membership_group_member_ids"
)

def create_employee_from_applicant(self):
Expand Down
1 change: 1 addition & 0 deletions membership_hr_recruitment/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_membership_hr_recruitment
Loading

0 comments on commit 4be4230

Please sign in to comment.