Skip to content

Commit c760212

Browse files
authored
Modules Fixes (#851)
* [REM] predefined ID Type * [ADD] disable of delete and archive on farmer * [FIX] disable of delete and archive on farmer * [FIX] disable of delete and archive on farmer * [FIX] disable of delete and archive on farmer * [FIX] disable of delete and archive on farmer * [FIX] disable of delete and archive on farmer * [IMP] disable of delete on social and spmis * [IMP] access rights and actions groups * [FIX] pre-commit * [FIX] disable delete on entitlements * [FIX] spp_change_request_base: source mixin * [ADD] validation stage * [IMP] hiding of actions * [FIX] hiding of actions * [IMP] move new fields to spp_change_request not on base * [FIX] error * [IMP] apply changes to other CR Types * [ADD] admin on actions for batches * [IMP] hiding of preview if no file * [IMP] hiding of CR Actions * [IMP] current user assigned compute * [IMP] hq group on assign action * [IMP] apply changes to other CR types * [IMP] disable delete * [FIX] delete instead of create * [IMP] assign action * [IMP] showing of preview button * [IMP] assign action * [IMP] assign action * [IMP] showing of preview button * [IMP] showing of preview button * [IMP] showing of preview button * [FIX] apply changes to other cr types * [REM] faulty test * [FIX] pre-commit * [ADD] change request tests * [ADD] more tests * [FIX] import * [FIX] test error * [FIX] test * [FIX] insert id to be removed * [FIX] test and remove national ID * [FIX] checking for hiding assign button * [FIX] checking for hiding assign button * [FIX] edit farmer test
1 parent 25a80dc commit c760212

57 files changed

Lines changed: 2065 additions & 472 deletions

File tree

Some content is hidden

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

spp_base_farmer_registry/views/group_view.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,14 @@
294294
</xpath>
295295
</field>
296296
</record>
297+
<record id="view_groups_list_farmer_registry_tree" model="ir.ui.view">
298+
<field name="name">view_groups_list_farmer_registry_tree</field>
299+
<field name="model">res.partner</field>
300+
<field name="inherit_id" ref="g2p_registry_group.view_groups_list_tree" />
301+
<field name="arch" type="xml">
302+
<xpath expr="//tree" position="attributes">
303+
<attribute name="delete">0</attribute>
304+
</xpath>
305+
</field>
306+
</record>
297307
</odoo>

spp_base_farmer_registry/views/individual_view.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,14 @@
100100
</xpath>
101101
</field>
102102
</record>
103+
<record id="view_individuals_list_farmer_registry_tree" model="ir.ui.view">
104+
<field name="name">view_individuals_list_farmer_registry_tree</field>
105+
<field name="model">res.partner</field>
106+
<field name="inherit_id" ref="g2p_registry_individual.view_individuals_list_tree" />
107+
<field name="arch" type="xml">
108+
<xpath expr="//tree" position="attributes">
109+
<attribute name="delete">0</attribute>
110+
</xpath>
111+
</field>
112+
</record>
103113
</odoo>

spp_base_social_registry/__manifest__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
"spp_base_spmis",
3030
],
3131
"external_dependencies": {},
32-
"data": [],
32+
"data": [
33+
"views/registrant_view.xml",
34+
],
3335
"assets": {},
3436
"demo": [],
3537
"images": [],
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<odoo>
3+
4+
<record id="view_individuals_list_social_registry_tree" model="ir.ui.view">
5+
<field name="name">view_individuals_list_social_registry_tree</field>
6+
<field name="model">res.partner</field>
7+
<field name="inherit_id" ref="g2p_registry_individual.view_individuals_list_tree" />
8+
<field name="arch" type="xml">
9+
<xpath expr="//tree" position="attributes">
10+
<attribute name="delete">0</attribute>
11+
</xpath>
12+
</field>
13+
</record>
14+
15+
<record id="view_groups_list_social_registry_tree" model="ir.ui.view">
16+
<field name="name">view_groups_list_social_registry_tree</field>
17+
<field name="model">res.partner</field>
18+
<field name="inherit_id" ref="g2p_registry_group.view_groups_list_tree" />
19+
<field name="arch" type="xml">
20+
<xpath expr="//tree" position="attributes">
21+
<attribute name="delete">0</attribute>
22+
</xpath>
23+
</field>
24+
</record>
25+
26+
</odoo>

spp_base_spmis/views/registrant_view.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,26 @@
2525
</field>
2626
</record>
2727

28+
<record id="view_individuals_list_spmis_tree" model="ir.ui.view">
29+
<field name="name">view_individuals_list_spmis_tree</field>
30+
<field name="model">res.partner</field>
31+
<field name="inherit_id" ref="g2p_registry_individual.view_individuals_list_tree" />
32+
<field name="arch" type="xml">
33+
<xpath expr="//tree" position="attributes">
34+
<attribute name="delete">0</attribute>
35+
</xpath>
36+
</field>
37+
</record>
38+
39+
<record id="view_groups_list_spmis_tree" model="ir.ui.view">
40+
<field name="name">view_groups_list_spmis_tree</field>
41+
<field name="model">res.partner</field>
42+
<field name="inherit_id" ref="g2p_registry_group.view_groups_list_tree" />
43+
<field name="arch" type="xml">
44+
<xpath expr="//tree" position="attributes">
45+
<attribute name="delete">0</attribute>
46+
</xpath>
47+
</field>
48+
</record>
49+
2850
</odoo>

spp_change_request/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
22

33
from . import models
4+
from .tests import test_models

spp_change_request/models/change_request.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,38 @@ class ChangeRequestBase(models.Model):
8888
domain=[("is_registrant", "=", True)],
8989
) #: Registrant who submitted the change request
9090

91+
validation_stage = fields.Selection(
92+
[
93+
("local", "Local"),
94+
("hq", "HQ"),
95+
("completed", "Completed"),
96+
],
97+
string="Validation Stage",
98+
default="local",
99+
compute="_compute_validation_stage",
100+
store=True,
101+
)
102+
103+
@api.depends("validator_ids")
104+
def _compute_validation_stage(self):
105+
for rec in self:
106+
validation_sequences = self.env["spp.change.request.validation.sequence"].search(
107+
[("request_type", "=", rec.request_type)]
108+
)
109+
total_sequences = len(validation_sequences)
110+
total_validators = len(rec.validator_ids)
111+
if not validation_sequences or total_sequences == 0:
112+
rec.validation_stage = "local"
113+
else:
114+
if total_validators == 0:
115+
rec.validation_stage = "local"
116+
elif total_validators < total_sequences - 1:
117+
rec.validation_stage = "local"
118+
elif total_validators == total_sequences - 1:
119+
rec.validation_stage = "hq"
120+
elif total_validators >= total_sequences:
121+
rec.validation_stage = "completed"
122+
91123
@api.model
92124
def _registrant_id_not_visible_in_request_type(self):
93125
return []

spp_change_request/models/mixins/source_mixin.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,63 @@ class ChangeRequestAddChildren(models.Model):
7676
# string="DMS Files",
7777
# auto_join=True,
7878
# )
79+
validation_stage = fields.Selection(
80+
string="Validation Stage",
81+
related="change_request_id.validation_stage",
82+
)
83+
show_cr_actions = fields.Boolean(compute="_compute_show_cr_actions")
84+
show_assign_button = fields.Boolean(compute="_compute_show_assign_button")
85+
show_reassign_button = fields.Boolean(compute="_compute_show_reassign_button")
86+
87+
def _compute_show_cr_actions(self):
88+
for rec in self:
89+
user = self.env.user
90+
rec.show_cr_actions = (
91+
rec.validation_stage == "local"
92+
and user.has_group("spp_change_request.group_spp_change_request_validator")
93+
and user.id == rec.assign_to_id.id
94+
) or (
95+
rec.validation_stage == "hq"
96+
and user.has_group("spp_change_request.group_spp_change_request_hq_validator")
97+
and user.id == rec.assign_to_id.id
98+
)
99+
100+
def _compute_show_assign_button(self):
101+
for rec in self:
102+
user = self.env.user
103+
assigned_id = rec.assign_to_id.id if rec.assign_to_id else None
104+
user_not_assigned = True
105+
if assigned_id:
106+
user_not_assigned = True if assigned_id != user.id else False
107+
108+
rec.show_assign_button = (
109+
rec.state in ("draft", "pending", "validated", "rejected")
110+
and (
111+
rec.validation_stage == "local"
112+
and user.has_group("spp_change_request.group_spp_change_request_validator")
113+
)
114+
or (
115+
rec.validation_stage == "hq"
116+
and user.has_group("spp_change_request.group_spp_change_request_hq_validator")
117+
)
118+
or user.has_group("g2p_registry_base.group_g2p_admin")
119+
) and user_not_assigned
120+
121+
def _compute_show_reassign_button(self):
122+
for rec in self:
123+
user = self.env.user
124+
rec.show_reassign_button = (
125+
rec.state in ("draft", "pending", "validated", "rejected")
126+
and (
127+
rec.validation_stage == "local"
128+
and user.has_group("spp_change_request.group_spp_change_request_validator")
129+
)
130+
or (
131+
rec.validation_stage == "hq"
132+
and user.has_group("spp_change_request.group_spp_change_request_hq_validator")
133+
)
134+
or user.has_group("g2p_registry_base.group_g2p_admin")
135+
) and rec.assign_to_id.id == user.id
79136

80137
def _copy_group_member_ids(self, group_id_field, group_ref_field="registrant_id"):
81138
for rec in self:

spp_change_request/tests/common.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)