From 91a56307bc6ede7b487e53774a688098abff0531 Mon Sep 17 00:00:00 2001 From: robinrolle Date: Mon, 7 Oct 2024 12:04:32 +0200 Subject: [PATCH] [MIG] T1878 intervention_compassion: migration to 17.0 --- intervention_compassion/README.rst | 58 +++ intervention_compassion/__init__.py | 4 +- .../data/intervention_action_rules.xml | 126 ++++-- .../models/compassion_intervention.py | 131 ++---- .../models/generic_intervention.py | 42 +- .../models/global_intervention.py | 7 +- intervention_compassion/readme/DESCRIPTION.md | 4 + .../static/description/index.html | 411 ++++++++++++++++++ .../views/compassion_intervention_view.xml | 202 ++++++--- .../views/global_intervention_view.xml | 2 +- .../views/intervention_search_view.xml | 16 +- .../wizards/intervention_search.py | 4 +- 12 files changed, 785 insertions(+), 222 deletions(-) create mode 100644 intervention_compassion/README.rst create mode 100644 intervention_compassion/readme/DESCRIPTION.md create mode 100644 intervention_compassion/static/description/index.html diff --git a/intervention_compassion/README.rst b/intervention_compassion/README.rst new file mode 100644 index 000000000..39092b3ef --- /dev/null +++ b/intervention_compassion/README.rst @@ -0,0 +1,58 @@ +======================== +Compassion Interventions +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:561e5b2662c002ac896d47c3e21b6f7fc0c9c13f8542f478e066d46a7c44ddde + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Fcompassion--modules-lightgray.png?logo=github + :target: https://github.com/CompassionCH/compassion-modules/tree/17.0/intervention_compassion + :alt: CompassionCH/compassion-modules + +|badge1| |badge2| |badge3| + +Compassion Interventions Management objects. + +Setup compassion intervention model. Manage interventions info and their +states. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Compassion CH + +Maintainers +----------- + +This module is part of the `CompassionCH/compassion-modules `_ project on GitHub. + +You are welcome to contribute. diff --git a/intervention_compassion/__init__.py b/intervention_compassion/__init__.py index 9c9efa5e8..d3e47a5cb 100644 --- a/intervention_compassion/__init__.py +++ b/intervention_compassion/__init__.py @@ -13,7 +13,7 @@ from . import models, wizards -def load_mappings(cr, registry): +def load_mappings(env): path = "intervention_compassion/static/mappings/" files = [ "commitment_mapping.json", @@ -26,4 +26,4 @@ def load_mappings(cr, registry): "intervention_search_mapping.json", ] - load_mapping_files(cr, path, files) + load_mapping_files(env, path, files) diff --git a/intervention_compassion/data/intervention_action_rules.xml b/intervention_compassion/data/intervention_action_rules.xml index e812ceb96..4414f1243 100644 --- a/intervention_compassion/data/intervention_action_rules.xml +++ b/intervention_compassion/data/intervention_action_rules.xml @@ -1,11 +1,14 @@ - - - - - active + + + Intervention: Make active after start date + + code + base_automation + records.write({'state': 'active'}) - + + Intervention: Make active after start date @@ -14,23 +17,27 @@ name="trg_date_id" ref="field_compassion_intervention__start_date" /> - [('state', '=', 'committed')] 0 day - object_write [('state', '=', 'committed'), ('start_date', '!=', False)] + - - - - - close + + + Intervention: Close after end date + + code + base_automation + records.write({'state': 'close'}) - + + Intervention: Close after end date @@ -41,69 +48,92 @@ /> 0 day - object_write + [('end_date', '!=', False)] - - - - - - on_hold + + + Intervention: Check SLA Negotiation done + + code + base_automation + records.write({'state': 'on_hold'}) - + + - Intervention: Check SLA Negociation done + Intervention: Check SLA Negotiation done on_create_or_write [('state', '=', 'sla'), '|', '&', ('service_level', '=', 'Level 2'), ('sla_selection_complete', '=', True), ('sla_negotiation_status', '=', 'GP Accepted Costs')] - object_write - + - - - - sla + + + Intervention: Check SLA Negotiation waiting + + code + base_automation + records.write({'state': 'sla'}) + + - Intervention: Check SLA Negociation waiting + Intervention: Check SLA Negotiation waiting on_create_or_write [('state', '=', 'on_hold'), ('service_level', '=', 'Level 2'), ('sla_selection_complete', '=', False)] - object_write - + >[('state', '=', 'on_hold'), ('service_level', '=', 'Level 2'),('sla_selection_complete', '=', False)] + + + + + + Intervention: Notify before on hold expires + + next_activity + base_automation + + On Hold intervention close to expiration date + An Intervention you are assigned to is close to reaching its expiration date while still On Hold. + generic + user_id + Intervention: Send notification before intervention on hold expire. + >Intervention: Send notification before intervention on hold expires on_time - [('state', '=', 'on_hold')] -7 day - next_activity - - On Hold intervention close to expiration date + [('state', '=', 'on_hold')] An Intervention you are assigned to is close to reach it's expiration date while still On Hold. - generic - user_id + name="action_server_ids" + eval="[(6, 0, [ref('action_notify_before_expire')])]" + /> diff --git a/intervention_compassion/models/compassion_intervention.py b/intervention_compassion/models/compassion_intervention.py index f807d132d..7d10a3f49 100644 --- a/intervention_compassion/models/compassion_intervention.py +++ b/intervention_compassion/models/compassion_intervention.py @@ -48,8 +48,8 @@ class CompassionIntervention(models.Model): default="on_hold", tracking=True, ) - type = fields.Selection(store=True, readonly=True) - parent_intervention_name = fields.Char(string="Parent Intervention", readonly=True) + type = fields.Selection(store=True) + parent_intervention_name = fields.Char(string="Parent Intervention") intervention_status = fields.Selection( [ ("Approved", _("Approved")), @@ -59,17 +59,15 @@ class CompassionIntervention(models.Model): ("Rejected", _("Rejected")), ("Submitted", _("Submitted")), ], - readonly=True, ) - funding_global_partners = fields.Char(readonly=True) - cancel_reason = fields.Char(readonly=True) + funding_global_partners = fields.Char() + cancel_reason = fields.Char() fcp_ids = fields.Many2many( "compassion.project", "fcp_interventions", "intervention_id", "fcp_id", string="FCPs", - readonly=True, ) product_template_id = fields.Many2one( "product.template", "Linked product", readonly=False @@ -78,7 +76,6 @@ class CompassionIntervention(models.Model): "compassion.intervention.subcategory", "compassion_intervention_subcategory_rel", string="Subcategory", - readonly=True, ) # Multicompany @@ -93,27 +90,23 @@ class CompassionIntervention(models.Model): # Schedule Information ###################### - start_date = fields.Date(help="Actual start date", readonly=True) - actual_duration = fields.Integer(help="Actual duration in months", readonly=True) - initial_planned_end_date = fields.Date(readonly=True) - planned_end_date = fields.Date(readonly=True, tracking=True) - end_date = fields.Date(help="Actual end date", readonly=True, tracking=True) + start_date = fields.Date(help="Actual start date") + actual_duration = fields.Integer(help="Actual duration in months") + initial_planned_end_date = fields.Date() + planned_end_date = fields.Date(tracking=True) + end_date = fields.Date(help="Actual end date", tracking=True) # Budget Information (all monetary fields are in US dollars) #################### - estimated_local_contribution = fields.Float(readonly=True) + estimated_local_contribution = fields.Float() impacted_beneficiaries = fields.Integer( - help="Actual number of impacted beneficiaries", readonly=True - ) - local_contribution = fields.Float(readonly=True, help="Actual local contribution") - commitment_amount = fields.Float(readonly=True, tracking=True) - commited_percentage = fields.Float(readonly=True, tracking=True, default=100.0) - total_expense = fields.Char( - "Total expense", compute="_compute_move_line", readonly=True - ) - total_income = fields.Char( - "Total income", compute="_compute_move_line", readonly=True + help="Actual number of impacted beneficiaries" ) + local_contribution = fields.Float(help="Actual local contribution") + commitment_amount = fields.Float(tracking=True) + commited_percentage = fields.Float(tracking=True, default=100.0) + total_expense = fields.Char("Total expense", compute="_compute_move_line") + total_income = fields.Char("Total income", compute="_compute_move_line") total_amendment = fields.Float() total_actual_cost_local = fields.Float("Total cost (local currency)") total_estimated_cost_local = fields.Float("Estimated costs (local currency)") @@ -125,13 +118,13 @@ class CompassionIntervention(models.Model): # Intervention Details Information ################################## - problem_statement = fields.Text(readonly=True) - background_information = fields.Text(readonly=True) - objectives = fields.Text(readonly=True) - success_factors = fields.Text(readonly=True) - solutions = fields.Text(readonly=True) - not_funded_implications = fields.Text(readonly=True) - implementation_risks = fields.Text(readonly=True) + problem_statement = fields.Text() + background_information = fields.Text() + objectives = fields.Text() + success_factors = fields.Text() + solutions = fields.Text() + not_funded_implications = fields.Text() + implementation_risks = fields.Text() # Service Level Negotiation ########################### @@ -144,15 +137,14 @@ class CompassionIntervention(models.Model): ("GP Rejected Costs", _("GP Rejected Costs")), ("FO Rejected GP Preferences", _("FO Rejected GP Preferences")), ], - readonly=True, tracking=True, ) - sla_comments = fields.Char(readonly=True) + sla_comments = fields.Char() fo_proposed_sla_costs = fields.Float( - readonly=True, help="The costs proposed by the National Office for the SLA" + help="The costs proposed by the National Office for the SLA" ) approved_sla_costs = fields.Float( - readonly=True, help="The final approved Service Level Agreement Cost" + help="The final approved Service Level Agreement Cost" ) deliverable_level_1_ids = fields.Many2many( "compassion.intervention.deliverable", @@ -169,7 +161,6 @@ class CompassionIntervention(models.Model): "intervention_id", "deliverable_id", string="Level 2 Deliverables", - readonly=True, ) deliverable_level_3_ids = fields.Many2many( "compassion.intervention.deliverable", @@ -177,13 +168,12 @@ class CompassionIntervention(models.Model): "intervention_id", "deliverable_id", string="Level 3 Deliverables", - readonly=True, ) sla_selection_complete = fields.Boolean() # Hold information ################## - hold_id = fields.Char(readonly=True) + hold_id = fields.Char() service_level = fields.Selection( [ ("Level 1", _("Level 1")), @@ -191,93 +181,52 @@ class CompassionIntervention(models.Model): ("Level 3", _("Level 3")), ], required=True, - readonly=True, - states={ - "on_hold": [("readonly", False)], - "sla": [("readonly", False)], - }, ) hold_amount = fields.Float( - readonly=True, - states={ - "on_hold": [("readonly", False)], - "sla": [("readonly", False)], - }, tracking=True, ) - expiration_date = fields.Date( - readonly=True, - states={ - "on_hold": [("readonly", False)], - "sla": [("readonly", False)], - }, - ) - next_year_opt_in = fields.Boolean( - readonly=True, - states={ - "on_hold": [("readonly", False)], - "sla": [("readonly", False)], - }, - ) + expiration_date = fields.Date() + next_year_opt_in = fields.Boolean() user_id = fields.Many2one( "res.users", "Primary owner", domain=[("share", "=", False)], - readonly=True, - states={ - "on_hold": [("readonly", False)], - "sla": [("readonly", False)], - }, tracking=True, ) - secondary_owner = fields.Char( - readonly=True, - states={ - "on_hold": [("readonly", False)], - "sla": [("readonly", False)], - }, - ) + secondary_owner = fields.Char() # Survival Information ###################### - survival_slots = fields.Integer(readonly=True) - launch_reason = fields.Char(readonly=True) - mother_children_challenges = fields.Char( - "Challenges for mother and children", readonly=True - ) - community_benefits = fields.Char(readonly=True) - mother_average_age = fields.Integer("Avg age of first-time mother", readonly=True) - household_children_average = fields.Integer( - "Avg of children per household", readonly=True - ) - under_five_population = fields.Char("% population under age 5", readonly=True) - birth_medical = fields.Char("% births in medical facility", readonly=True) + survival_slots = fields.Integer() + launch_reason = fields.Char() + mother_children_challenges = fields.Char("Challenges for mother and children") + community_benefits = fields.Char() + mother_average_age = fields.Integer("Avg age of first-time mother") + household_children_average = fields.Integer("Avg of children per household") + under_five_population = fields.Char("% population under age 5") + birth_medical = fields.Char("% births in medical facility") spiritual_activity_ids = fields.Many2many( "fcp.spiritual.activity", "intervention_spiritual_activities", string="Spiritual activities", - readonly=True, ) cognitive_activity_ids = fields.Many2many( "fcp.cognitive.activity", "intervention_cognitive_activities", string="Cognitive activities", - readonly=True, ) physical_activity_ids = fields.Many2many( "fcp.physical.activity", "intervention_physical_activities", string="Physical activities", - readonly=True, ) socio_activity_ids = fields.Many2many( "fcp.sociological.activity", "intervention_socio_activities", string="Sociological activities", - readonly=True, ) - activities_for_parents = fields.Char(readonly=True) - other_activities = fields.Char(readonly=True) + activities_for_parents = fields.Char() + other_activities = fields.Char() def _compute_level1_deliverables(self): for intervention in self: diff --git a/intervention_compassion/models/generic_intervention.py b/intervention_compassion/models/generic_intervention.py index 2282628c2..563d70c56 100644 --- a/intervention_compassion/models/generic_intervention.py +++ b/intervention_compassion/models/generic_intervention.py @@ -27,41 +27,43 @@ class GenericIntervention(models.AbstractModel): # General Information ##################### - name = fields.Char(readonly=True) - intervention_id = fields.Char(required=True, readonly=True) + name = fields.Char() + intervention_id = fields.Char( + required=True, + ) field_office_id = fields.Many2one( - "compassion.field.office", "National Office", readonly=True + "compassion.field.office", + "National Office", ) - description = fields.Text(readonly=True) - additional_marketing_information = fields.Text(readonly=True) + description = fields.Text() + additional_marketing_information = fields.Text() category_id = fields.Many2one( - "compassion.intervention.category", "Category", readonly=True + "compassion.intervention.category", + "Category", ) type = fields.Selection(related="category_id.type") - funding_status = fields.Selection("get_funding_statuses", readonly=True) + funding_status = fields.Selection("get_funding_statuses") # Schedule Information ###################### - is_fo_priority = fields.Boolean("Is National Office priority", readonly=True) - proposed_start_date = fields.Date(readonly=True) - start_no_later_than = fields.Date(readonly=True) - expected_duration = fields.Integer( - readonly=True, help="Expected duration in months" - ) + is_fo_priority = fields.Boolean("Is National Office priority") + proposed_start_date = fields.Date() + start_no_later_than = fields.Date() + expected_duration = fields.Integer(help="Expected duration in months") # Budget Information (all monetary fields are in US dollars) #################### currency_usd = fields.Many2one( "res.currency", compute="_compute_usd", readonly=False ) - estimated_costs = fields.Float(readonly=True) - remaining_amount_to_raise = fields.Float(readonly=True) - pdc_costs = fields.Float(help="Program development costs", readonly=True) - total_cost = fields.Float(readonly=True) - requested_additional_funding = fields.Float(readonly=True) - estimated_impacted_beneficiaries = fields.Integer(readonly=True) - disburse_without_commitment = fields.Boolean(readonly=True) + estimated_costs = fields.Float() + remaining_amount_to_raise = fields.Float() + pdc_costs = fields.Float(help="Program development costs") + total_cost = fields.Float() + requested_additional_funding = fields.Float() + estimated_impacted_beneficiaries = fields.Integer() + disburse_without_commitment = fields.Boolean() @api.model def get_fields(self): diff --git a/intervention_compassion/models/global_intervention.py b/intervention_compassion/models/global_intervention.py index 8f4234453..962ccc192 100644 --- a/intervention_compassion/models/global_intervention.py +++ b/intervention_compassion/models/global_intervention.py @@ -22,10 +22,11 @@ class GlobalIntervention(models.TransientModel): _name = "compassion.global.intervention" _description = "Global Intervention" - parent_intervention = fields.Char(readonly=True) + parent_intervention = fields.Char() amount_on_hold = fields.Float(compute="_compute_amount_on_hold") holding_partner_id = fields.Many2one( - "compassion.global.partner", "Major holding partner", readonly=True + "compassion.global.partner", + "Major holding partner", ) can_be_funded = fields.Boolean(compute="_compute_can_be_funded") fcp_ids = fields.Many2many( @@ -34,13 +35,11 @@ class GlobalIntervention(models.TransientModel): "intervention_id", "fcp_id", string="FCPs", - readonly=True, ) subcategory_ids = fields.Many2many( "compassion.intervention.subcategory", "compassion_global_intervention_subcategory_rel", string="Subcategory", - readonly=True, ) def _compute_amount_on_hold(self): diff --git a/intervention_compassion/readme/DESCRIPTION.md b/intervention_compassion/readme/DESCRIPTION.md new file mode 100644 index 000000000..d818338b6 --- /dev/null +++ b/intervention_compassion/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +Compassion Interventions Management objects. + +Setup compassion intervention model. +Manage interventions info and their states. \ No newline at end of file diff --git a/intervention_compassion/static/description/index.html b/intervention_compassion/static/description/index.html new file mode 100644 index 000000000..a5d08fba4 --- /dev/null +++ b/intervention_compassion/static/description/index.html @@ -0,0 +1,411 @@ + + + + + +Compassion Interventions + + + +
+

Compassion Interventions

+ + +

Beta License: AGPL-3 CompassionCH/compassion-modules

+

Compassion Interventions Management objects.

+

Setup compassion intervention model. Manage interventions info and their +states.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Compassion CH
  • +
+
+
+

Maintainers

+

This module is part of the CompassionCH/compassion-modules project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/intervention_compassion/views/compassion_intervention_view.xml b/intervention_compassion/views/compassion_intervention_view.xml index c6de34b18..dc2a71e92 100644 --- a/intervention_compassion/views/compassion_intervention_view.xml +++ b/intervention_compassion/views/compassion_intervention_view.xml @@ -16,14 +16,14 @@ name="create_commitment" string="Commit Funds" type="object" - states="on_hold" + invisible="state != 'on_hold'" class="oe_highlight" /> @@ -60,6 +61,7 @@ name="total_income" string="Income" widget="statinfo" + readonly="1" /> @@ -81,31 +83,51 @@

- +

- - - - - + + + + + + + - - - - - + + + - - - + + + @@ -114,18 +136,32 @@ - + + /> + /> + + + - - - - @@ -133,6 +169,7 @@ name="estimated_costs" widget="monetary" options="{'currency_field': 'currency_usd'}" + readonly="1" /> - + - - - - - - + + + + + + - - - + + + - + - + @@ -246,72 +318,106 @@ + - - + - - + + + + + - - - - + @@ -415,9 +521,7 @@ options="{'currency_field': 'usd'}" /> -
+

Additional fundings were requested by the National Office for this Intervention:

diff --git a/intervention_compassion/views/global_intervention_view.xml b/intervention_compassion/views/global_intervention_view.xml index 20bcd9444..b51b7b758 100644 --- a/intervention_compassion/views/global_intervention_view.xml +++ b/intervention_compassion/views/global_intervention_view.xml @@ -31,7 +31,7 @@ type="object" string="Put a hold" class="oe_highlight" - attrs="{'invisible': [('can_be_funded', '=', False)]}" + invisible="not can_be_funded" /> diff --git a/intervention_compassion/views/intervention_search_view.xml b/intervention_compassion/views/intervention_search_view.xml index daf7849bb..2c88d217b 100644 --- a/intervention_compassion/views/intervention_search_view.xml +++ b/intervention_compassion/views/intervention_search_view.xml @@ -40,7 +40,10 @@ type="object" class="oe_link oe_inline" /> - +
@@ -106,7 +112,7 @@ name="search_filter_ids" context="{'default_model': 'compassion.global.intervention', 'default_mapping_name': 'search'}" - attrs="{'readonly': [('use_advanced_search', '=', False)]}" + readonly="not use_advanced_search" /> diff --git a/intervention_compassion/wizards/intervention_search.py b/intervention_compassion/wizards/intervention_search.py index e7ea20412..d4b467385 100644 --- a/intervention_compassion/wizards/intervention_search.py +++ b/intervention_compassion/wizards/intervention_search.py @@ -47,12 +47,12 @@ class InterventionSearch(models.TransientModel): # Search helpers ################ type_chooser = fields.Selection("get_types") - type_selected = fields.Char(readonly=True) + type_selected = fields.Char() category_id = fields.Many2one( "compassion.intervention.category", "Category", readonly=False ) status_chooser = fields.Selection("get_statuses") - status_selected = fields.Char(readonly=True) + status_selected = fields.Char() intervention_id = fields.Char() fcp_ids = fields.Many2many( "compassion.project",