-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] spp_change_request_edit_farmer
- Loading branch information
Showing
24 changed files
with
2,294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
=================================== | ||
OpenSPP Change Request: Edit Farmer | ||
=================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:acaecaa0c5a4b0eeeacac2e19f416521d252c7c913eff91aeb22d41b9d7de0b8 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OpenSPP%2Fopenspp--modules-lightgray.png?logo=github | ||
:target: https://github.com/OpenSPP/openspp-modules/tree/17.0/spp_change_request_edit_farmer | ||
:alt: OpenSPP/openspp-modules | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
OpenSPP Change Request: Edit Farmer | ||
=================================== | ||
|
||
Overview | ||
-------- | ||
|
||
The `spp_change_request_edit_farmer <spp_change_request_edit_farmer>`__ | ||
module extends the OpenSPP Change Request system to specifically handle | ||
requests for adding new farmers to existing groups within the registry. | ||
It leverages the framework provided by the | ||
`spp_change_request <spp_change_request>`__ module and integrates with | ||
other registry modules to streamline the process of adding farmers while | ||
maintaining data integrity and consistency. | ||
|
||
Purpose | ||
------- | ||
|
||
- **Specialized Change Request Type**: Introduce a dedicated change | ||
request type for adding farmers, distinct from other types of | ||
registrant modifications. | ||
- **Streamlined Data Collection**: Provide a tailored form for | ||
capturing essential information about the new farmer, including | ||
personal details, farmer-specific attributes, and desired group | ||
membership details. | ||
- **Group Membership Management**: Integrate with the | ||
`g2p_registry_membership <g2p_registry_membership>`__ module to | ||
seamlessly add the new farmer to the specified group upon approval. | ||
- **Enhanced Validation**: Implement specific validation rules relevant | ||
to adding farmers, ensuring the accuracy and completeness of the | ||
submitted information. | ||
|
||
Module Integration | ||
------------------ | ||
|
||
Dependencies | ||
------------ | ||
|
||
The module relies heavily on the following modules: | ||
|
||
- `spp_change_request <spp_change_request>`__: Inherits the core change | ||
request functionality, including the request workflow, validation | ||
processes, approval mechanisms, and integration with the Document | ||
Management System (`spp_dms <spp_dms>`__). | ||
- `spp_farmer_registry_base <spp_farmer_registry_base>`__: Leverages | ||
the farmer-specific data models and attributes to capture and store | ||
information about the new farmer. | ||
- `g2p_registry_membership <g2p_registry_membership>`__: Integrates | ||
with the membership management system to create the appropriate group | ||
membership record for the new farmer upon change request approval. | ||
- `phone_validation <phone_validation>`__: Utilizes the phone | ||
validation module to ensure phone number entries for the new farmer | ||
adhere to correct formatting. | ||
- `g2p_registry_group <g2p_registry_group>`__: Accesses group | ||
information and functionality to display details about the target | ||
group for the new farmer. | ||
- `g2p_registry_individual <g2p_registry_individual>`__: Leverages | ||
individual registrant management features, inheriting from the | ||
individual registrant model. | ||
- `spp_service_points <spp_service_points>`__: Integrates with service | ||
points, allowing change requests to be initiated and managed through | ||
designated service points. | ||
|
||
Additional Functionality | ||
------------------------ | ||
|
||
- **Custom Change Request Model**: Introduces the | ||
``spp.change.request.edit.farmer`` model, inheriting from the base | ||
``spp.change.request`` model and adding fields specific to adding | ||
farmers, such as farmer-specific details and group membership | ||
information. | ||
- **Tailored Forms**: Provides specialized views for creating, | ||
displaying, and validating ``Edit Farmer`` change requests, including | ||
a dedicated form (``view_change_request_edit_farmer_form``) with | ||
relevant fields and a validation-focused form | ||
(``view_change_request_edit_farmer_validation_form``). | ||
- **Automated Individual and Membership Creation**: Upon validation and | ||
approval of the change request, the module automatically creates: | ||
|
||
- A new individual registrant record (``res.partner``) for the | ||
farmer, populating it with the submitted data. | ||
- A corresponding group membership record | ||
(``g2p.group.membership``), linking the newly created farmer to | ||
the designated group. | ||
|
||
- **Enhanced User Interface**: Adds specific menu items and actions to | ||
the OpenSPP interface, allowing users to efficiently manage | ||
``Edit Farmer`` requests. | ||
|
||
Conclusion | ||
---------- | ||
|
||
The `spp_change_request_edit_farmer <spp_change_request_edit_farmer>`__ | ||
module provides a robust and specialized workflow for adding new farmers | ||
to existing groups within the OpenSPP registry. By seamlessly | ||
integrating with core change management and registry modules, it ensures | ||
data accuracy, consistency, and a streamlined user experience for | ||
managing farmer additions. | ||
|
||
.. IMPORTANT:: | ||
This is an alpha version, the data model and design can change at any time without warning. | ||
Only for development or testing purpose, do not use in production. | ||
`More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OpenSPP/openspp-modules/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OpenSPP/openspp-modules/issues/new?body=module:%20spp_change_request_edit_farmer%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* OpenSPP.org | ||
|
||
Maintainers | ||
----------- | ||
|
||
.. |maintainer-jeremi| image:: https://github.com/jeremi.png?size=40px | ||
:target: https://github.com/jeremi | ||
:alt: jeremi | ||
.. |maintainer-gonzalesedwin1123| image:: https://github.com/gonzalesedwin1123.png?size=40px | ||
:target: https://github.com/gonzalesedwin1123 | ||
:alt: gonzalesedwin1123 | ||
.. |maintainer-emjay0921| image:: https://github.com/emjay0921.png?size=40px | ||
:target: https://github.com/emjay0921 | ||
:alt: emjay0921 | ||
|
||
Current maintainers: | ||
|
||
|maintainer-jeremi| |maintainer-gonzalesedwin1123| |maintainer-emjay0921| | ||
|
||
This module is part of the `OpenSPP/openspp-modules <https://github.com/OpenSPP/openspp-modules/tree/17.0/spp_change_request_edit_farmer>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "OpenSPP Change Request: Edit Farmer", | ||
"summary": "Provides a specialized workflow for updating existing Farmer in the registry.", | ||
"category": "OpenSPP", | ||
"version": "17.0.1.3.0", | ||
"sequence": 1, | ||
"author": "OpenSPP.org", | ||
"website": "https://github.com/OpenSPP/openspp-modules", | ||
"license": "LGPL-3", | ||
"development_status": "Beta", | ||
"maintainers": ["jeremi", "gonzalesedwin1123", "emjay0921"], | ||
"depends": [ | ||
"spp_change_request", | ||
"g2p_registry_individual", | ||
"g2p_registry_group", | ||
"g2p_registry_membership", | ||
"spp_service_points", | ||
"spp_idpass", | ||
"spp_farmer_registry_base", | ||
], | ||
"excludes": [ | ||
"spp_change_request_create_group", | ||
], | ||
"data": [ | ||
"security/change_request_security.xml", | ||
"security/ir.model.access.csv", | ||
"data/dms.xml", | ||
"data/change_request_stage.xml", | ||
"data/change_request_sequence.xml", | ||
"data/change_request_target.xml", | ||
"views/change_request_edit_farmer_view.xml", | ||
"views/change_request_view.xml", | ||
"views/dms_file_view.xml", | ||
], | ||
"assets": {}, | ||
"demo": [], | ||
"images": [], | ||
"application": True, | ||
"installable": True, | ||
"auto_install": False, | ||
} |
23 changes: 23 additions & 0 deletions
23
spp_change_request_edit_farmer/data/change_request_sequence.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Part of OpenSPP. See LICENSE file for full copyright and licensing details. | ||
--> | ||
<odoo noupdate="0"> | ||
|
||
<record id="spp_cr_edit_farmer_val_seq_local" model="spp.change.request.validation.sequence"> | ||
<field name="sequence">10</field> | ||
<field name="stage_id" ref="spp_change_request_edit_farmer.spp_cr_val_stage_local" /> | ||
<field name="request_type">spp.change.request.edit.farmer</field> | ||
<field name="validation_group_id" ref="spp_change_request.group_spp_change_request_local_validator" /> | ||
<field name="validation_group_state">both</field> | ||
</record> | ||
|
||
<record id="spp_cr_edit_farmer_val_seq_hq" model="spp.change.request.validation.sequence"> | ||
<field name="sequence">20</field> | ||
<field name="stage_id" ref="spp_change_request_edit_farmer.spp_cr_val_stage_hq" /> | ||
<field name="request_type">spp.change.request.edit.farmer</field> | ||
<field name="validation_group_id" ref="spp_change_request.group_spp_change_request_hq_validator" /> | ||
<field name="validation_group_state">both</field> | ||
</record> | ||
|
||
</odoo> |
15 changes: 15 additions & 0 deletions
15
spp_change_request_edit_farmer/data/change_request_stage.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Part of OpenSPP. See LICENSE file for full copyright and licensing details. | ||
--> | ||
<odoo noupdate="0"> | ||
|
||
<record id="spp_cr_val_stage_local" model="spp.change.request.validation.stage"> | ||
<field name="name">Local</field> | ||
</record> | ||
|
||
<record id="spp_cr_val_stage_hq" model="spp.change.request.validation.stage"> | ||
<field name="name">HQ</field> | ||
</record> | ||
|
||
</odoo> |
12 changes: 12 additions & 0 deletions
12
spp_change_request_edit_farmer/data/change_request_target.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Part of OpenSPP. See LICENSE file for full copyright and licensing details. | ||
--> | ||
<odoo noupdate="0"> | ||
|
||
<record id="spp_cr_edit_farmer_target" model="spp.change.request.targets"> | ||
<field name="name">spp.change.request.edit.farmer</field> | ||
<field name="target">group</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="0"> | ||
|
||
<!-- Category Documents--> | ||
<record id="spp_dms_edit_farmer" model="spp.dms.category"> | ||
<field name="name">Edit Farmer Request Form</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import change_request | ||
from . import change_request_edit_farmer | ||
from . import change_request_edit_farmer_validation_sequence | ||
from . import dms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import logging | ||
|
||
from odoo import Command, api, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class ChangeRequestBaseCustomDemo(models.Model): | ||
_inherit = "spp.change.request" | ||
|
||
def create_request_detail_demo(self): | ||
""" | ||
A version of spp.change.request create_request_detail function | ||
that does not check the applicant's phone number and | ||
does not load the CR details form | ||
:return: | ||
""" | ||
for rec in self: | ||
if rec.state in ("draft", "pending"): | ||
# Set the request_type_ref_id | ||
res_model = rec.request_type | ||
# Set the dms directory | ||
_logger.debug("Change Request: DMS Directory Creation (%s)" % len(self.dms_directory_ids)) | ||
# self.env.ref(self.env[res_model].DMS_STORAGE) | ||
dmsval = { | ||
"is_root_directory": True, | ||
"name": rec.name, | ||
} | ||
|
||
# Prepare CR type model data | ||
cr_type_vals = { | ||
"registrant_id": rec.registrant_id.id, | ||
"applicant_id": rec.applicant_id.id, | ||
"change_request_id": rec.id, | ||
"dms_directory_ids": [(Command.create(dmsval))], | ||
} | ||
|
||
# Create the change request detail record | ||
ref_id = self.env[res_model].create(cr_type_vals) | ||
directory_id = ref_id.dms_directory_ids[0].id | ||
|
||
self.env["spp.dms.directory"].create( | ||
{ | ||
"name": "Applicant", | ||
"parent_id": directory_id, | ||
"is_root_directory": False, | ||
} | ||
) | ||
|
||
# Upload Scanned IDs to DMS | ||
dms_file_ids = [] | ||
for id_fld in ["id_document_details", "qr_code_details"]: | ||
if rec[id_fld]: | ||
dms_id_doc = rec._get_id_doc_vals(directory_id, id_fld) | ||
if dms_id_doc: | ||
dms_file_ids.append(Command.create(dms_id_doc)) | ||
if dms_file_ids: | ||
ref_id.update({"dms_file_ids": dms_file_ids}) | ||
|
||
ref_id._onchange_registrant_id() | ||
request_type_ref_id = f"{res_model},{ref_id.id}" | ||
_logger.debug("DEBUG! request_type_ref_id: %s", request_type_ref_id) | ||
rec.update( | ||
{ | ||
"request_type_ref_id": request_type_ref_id, | ||
"id_document_details": "", | ||
} | ||
) | ||
|
||
# Temporary solution to phone number fo | ||
# def _check_phone_exist(self): | ||
# pass | ||
|
||
@api.constrains("registrant_id", "applicant_phone") | ||
def _check_applicant_phone(self): | ||
# Temporary solution to phone number format error | ||
pass |
Oops, something went wrong.