Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion spp_change_request_v2/strategies/add_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def apply(self, change_request):
membership_vals = {
"group": group.id,
"individual": individual.id,
"start_date": fields.Date.today(),
"start_date": fields.Datetime.now(),
}

# Handle relationship/membership type
Expand Down
46 changes: 33 additions & 13 deletions spp_change_request_v2/views/detail_add_member_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,66 @@
<field name="model">spp.cr.detail.add_member</field>
<field name="arch" type="xml">
<form>
<header>
<button
name="action_submit_for_approval"
string="Submit for Approval"
type="object"
class="btn-primary"
invisible="approval_state != 'draft'"
/>
<button
name="action_submit_for_approval"
string="Resubmit for Review"
type="object"
class="btn-primary"
invisible="approval_state != 'revision'"
/>
<field
name="approval_state"
widget="statusbar"
statusbar_visible="draft,pending,approved,applied"
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Statusbar references non-existent "applied" state in approval_state

Low Severity

The statusbar uses approval_state field with statusbar_visible="draft,pending,approved,applied", but approval_state (from spp.approval.mixin) only has values: draft, pending, revision, approved, rejected. The value applied doesn't exist in this field. The main change request view correctly uses display_state which includes applied. This inconsistency means detail forms will never display the "Completed" status in their statusbar, even when the change request has been applied.

Additional Locations (2)

Fix in Cursor Fix in Web

</header>
Comment on lines +9 to +29
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To improve maintainability and reduce code duplication, consider extracting this common header into a reusable QWeb template. This same header is added to 11 different form views in this PR. By using a template, any future changes to the submission buttons or status bar will only need to be made in one place.

You could define the template in a new or existing XML file (e.g., inside a <templates> tag):

<templates>
    <t t-name="spp_change_request_v2.cr_detail_form_header">
        <header>
            <button
                name="action_submit_for_approval"
                string="Submit for Approval"
                type="object"
                class="btn-primary"
                invisible="approval_state != 'draft'"
            />
            <button
                name="action_submit_for_approval"
                string="Resubmit for Review"
                type="object"
                class="btn-primary"
                invisible="approval_state != 'revision'"
            />
            <field
                name="approval_state"
                widget="statusbar"
                statusbar_visible="draft,pending,approved,applied"
            />
        </header>
    </t>
</templates>

Then, you can replace the <header> block in this file and all other similar detail forms with a single line, as suggested below.

                <t t-call="spp_change_request_v2.cr_detail_form_header"/>

<sheet>
<div class="oe_title">
<h1>Add Member to Group</h1>
</div>

<!-- Target Group -->
<group string="Target Group">
<field name="registrant_id" readonly="1"/>
<field name="change_request_id" invisible="1"/>
<field name="registrant_id" readonly="1" />
<field name="change_request_id" invisible="1" />
</group>

<!-- Member Details -->
<group string="New Member Information">
<group>
<field name="given_name" required="1"/>
<field name="family_name" required="1"/>
<field name="member_name" readonly="1" force_save="1"/>
<field name="given_name" required="1" />
<field name="family_name" required="1" />
<field name="member_name" readonly="1" force_save="1" />
</group>
<group>
<field name="birthdate"/>
<field name="gender_id"/>
<field name="relationship_id"/>
<field name="birthdate" />
<field name="gender_id" />
<field name="relationship_id" />
</group>
</group>

<group string="Contact Information">
<group>
<field name="phone"/>
<field name="id_number"/>
<field name="phone" />
<field name="id_number" />
</group>
</group>

<!-- Result (after apply) -->
<group string="Result" invisible="not created_individual_id">
<field name="created_individual_id"/>
<field name="created_individual_id" />
</group>
</sheet>
<chatter/>
<chatter />
</form>
</field>
</record>

</odoo>
37 changes: 34 additions & 3 deletions spp_change_request_v2/views/detail_change_hoh_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
<field name="model">spp.cr.detail.change_hoh</field>
<field name="arch" type="xml">
<form string="Change Head of Household Details">
<header>
<button
name="action_submit_for_approval"
string="Submit for Approval"
type="object"
class="btn-primary"
invisible="approval_state != 'draft'"
/>
<button
name="action_submit_for_approval"
string="Resubmit for Review"
type="object"
class="btn-primary"
invisible="approval_state != 'revision'"
/>
<field
name="approval_state"
widget="statusbar"
statusbar_visible="draft,pending,approved,applied"
/>
</header>
<sheet>
<group>
<group string="Current Head">
Expand All @@ -19,7 +40,11 @@
domain="[('id', 'in', available_individual_ids)]"
required="1"
/>
<field name="new_head_membership_id" invisible="1" force_save="1"/>
<field
name="new_head_membership_id"
invisible="1"
force_save="1"
/>
</group>
</group>
<group>
Expand All @@ -28,11 +53,17 @@
<field name="effective_date" />
</group>
<group string="Previous Head Reassignment">
<field name="previous_head_new_role_id" options="{'no_create': True}" />
<field
name="previous_head_new_role_id"
options="{'no_create': True}"
/>
</group>
</group>
<group string="Additional Information">
<field name="remarks" placeholder="Enter any additional notes..." />
<field
name="remarks"
placeholder="Enter any additional notes..."
/>
</group>
</sheet>
</form>
Expand Down
39 changes: 33 additions & 6 deletions spp_change_request_v2/views/detail_create_group_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,31 @@
<field name="model">spp.cr.detail.create_group</field>
<field name="arch" type="xml">
<form string="Create New Group Details">
<header>
<button
name="action_submit_for_approval"
string="Submit for Approval"
type="object"
class="btn-primary"
invisible="approval_state != 'draft'"
/>
<button
name="action_submit_for_approval"
string="Resubmit for Review"
type="object"
class="btn-primary"
invisible="approval_state != 'revision'"
/>
<field
name="approval_state"
widget="statusbar"
statusbar_visible="draft,pending,approved,applied"
/>
</header>
<sheet>
<group>
<group string="Group Information">
<field name="group_name" required="1"/>
<field name="group_name" required="1" />
<field name="group_type_id" options="{'no_create': True}" />
</group>
<group string="Contact">
Expand All @@ -26,16 +47,22 @@
</group>
<group invisible="create_new_head">
<group string="Select Existing Individual">
<field name="head_individual_id" options="{'no_create': True}" />
<field
name="head_individual_id"
options="{'no_create': True}"
/>
</group>
</group>
<group invisible="not create_new_head">
<group string="New Head Information">
<field name="head_given_name" required="create_new_head"/>
<field name="head_family_name" required="create_new_head"/>
<field name="head_name" readonly="1" force_save="1"/>
<field name="head_given_name" required="create_new_head" />
<field name="head_family_name" required="create_new_head" />
<field name="head_name" readonly="1" force_save="1" />
<field name="head_birthdate" />
<field name="head_gender_id" options="{'no_create': True}" />
<field
name="head_gender_id"
options="{'no_create': True}"
/>
<field name="head_phone" />
</group>
</group>
Expand Down
42 changes: 31 additions & 11 deletions spp_change_request_v2/views/detail_edit_group_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,65 @@
<field name="model">spp.cr.detail.edit_group</field>
<field name="arch" type="xml">
<form>
<header>
<button
name="action_submit_for_approval"
string="Submit for Approval"
type="object"
class="btn-primary"
invisible="approval_state != 'draft'"
/>
<button
name="action_submit_for_approval"
string="Resubmit for Review"
type="object"
class="btn-primary"
invisible="approval_state != 'revision'"
/>
<field
name="approval_state"
widget="statusbar"
statusbar_visible="draft,pending,approved,applied"
/>
</header>
<sheet>
<div class="oe_title">
<h1>Edit Group Information</h1>
</div>

<group string="Group">
<field name="registrant_id" readonly="1"/>
<field name="change_request_id" invisible="1"/>
<field name="registrant_id" readonly="1" />
<field name="change_request_id" invisible="1" />
</group>

<notebook>
<page string="Group Information">
<group>
<group>
<field name="group_name" required="1"/>
<field name="group_name" required="1" />
</group>
<group>
<field name="phone"/>
<field name="email"/>
<field name="phone" />
<field name="email" />
</group>
</group>
</page>
<page string="Address">
<group>
<group>
<field name="address_line1"/>
<field name="address_line2"/>
<field name="address_line1" />
<field name="address_line2" />
</group>
<group>
<field name="city"/>
<field name="postal_code"/>
<field name="city" />
<field name="postal_code" />
</group>
</group>
</page>
</notebook>
</sheet>
<chatter/>
<chatter />
</form>
</field>
</record>

</odoo>
48 changes: 34 additions & 14 deletions spp_change_request_v2/views/detail_edit_individual_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,68 @@
<field name="model">spp.cr.detail.edit_individual</field>
<field name="arch" type="xml">
<form>
<header>
<button
name="action_submit_for_approval"
string="Submit for Approval"
type="object"
class="btn-primary"
invisible="approval_state != 'draft'"
/>
<button
name="action_submit_for_approval"
string="Resubmit for Review"
type="object"
class="btn-primary"
invisible="approval_state != 'revision'"
/>
<field
name="approval_state"
widget="statusbar"
statusbar_visible="draft,pending,approved,applied"
/>
</header>
<sheet>
<div class="oe_title">
<h1>Edit Individual Information</h1>
</div>

<group string="Individual">
<field name="registrant_id" readonly="1"/>
<field name="change_request_id" invisible="1"/>
<field name="registrant_id" readonly="1" />
<field name="change_request_id" invisible="1" />
</group>

<notebook>
<page string="Personal Information">
<group>
<group>
<field name="given_name" required="1"/>
<field name="family_name" required="1"/>
<field name="birthdate"/>
<field name="gender_id"/>
<field name="given_name" required="1" />
<field name="family_name" required="1" />
<field name="birthdate" />
<field name="gender_id" />
</group>
<group>
<field name="phone"/>
<field name="email"/>
<field name="phone" />
<field name="email" />
</group>
</group>
</page>
<page string="Address">
<group>
<group>
<field name="address_line1"/>
<field name="address_line2"/>
<field name="address_line1" />
<field name="address_line2" />
</group>
<group>
<field name="city"/>
<field name="postal_code"/>
<field name="city" />
<field name="postal_code" />
</group>
</group>
</page>
</notebook>
</sheet>
<chatter/>
<chatter />
</form>
</field>
</record>

</odoo>
Loading
Loading