Skip to content

Commit ff70475

Browse files
committed
feat: move geofences to Configuration tab and add to program wizard
Move the Geographic Scope card from Overview to Configuration tab, matching the card-based UI pattern. Add geofence_ids field to the program creation wizard so geofences can be set during initial setup.
1 parent 88dc6d2 commit ff70475

6 files changed

Lines changed: 104 additions & 25 deletions

File tree

spp_program_geofence/__init__.py

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

spp_program_geofence/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"views/geofence_view.xml",
2121
"views/eligibility_manager_view.xml",
2222
"views/program_view.xml",
23+
"wizard/create_program_wizard.xml",
2324
],
2425
"application": False,
2526
"installable": True,

spp_program_geofence/views/program_view.xml

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<odoo>
3-
<!-- Extend Program Form: add geofences to Overview tab -->
3+
<!-- Extend Program Form: add geofences to Configuration tab -->
44
<record id="view_program_form_geofence" model="ir.ui.view">
55
<field name="name">spp.program.form.geofence</field>
66
<field name="model">spp.program</field>
7-
<field name="inherit_id" ref="spp_programs.view_program_list_form" />
8-
<field name="priority">99</field>
7+
<field name="inherit_id" ref="spp_programs.view_program_form_config_cards" />
8+
<field name="priority">101</field>
99
<field name="arch" type="xml">
1010
<!-- Add stat button for geofence count -->
1111
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
@@ -20,30 +20,62 @@
2020
</button>
2121
</xpath>
2222

23-
<!-- Add geofences to Overview tab -->
23+
<!-- Add Geographic Scope card before the Eligibility section -->
2424
<xpath
25-
expr="//group[@name='additional_overview_section']"
26-
position="attributes"
25+
expr="//page[@name='configuration']//div[hasclass('card')][1]"
26+
position="before"
2727
>
28-
<attribute name="invisible">0</attribute>
29-
</xpath>
30-
<xpath
31-
expr="//group[@name='additional_overview_section']"
32-
position="inside"
33-
>
34-
<separator string="Geographic Scope" colspan="2" />
35-
<field
36-
name="geofence_ids"
37-
nolabel="1"
38-
colspan="2"
39-
readonly="state == 'ended'"
40-
>
41-
<list delete="1" editable="bottom">
42-
<field name="name" readonly="1" />
43-
<field name="geofence_type" optional="hide" readonly="1" />
44-
<field name="area_sqkm" string="Area (sq km)" readonly="1" />
45-
</list>
46-
</field>
28+
<div class="card mb-3 shadow-sm">
29+
<div
30+
class="card-header d-flex justify-content-between align-items-center py-2 bg-info-subtle"
31+
>
32+
<div class="d-flex align-items-center">
33+
<i
34+
class="fa fa-map-marker fa-lg me-3 text-info"
35+
title="Geographic Scope"
36+
/>
37+
<div>
38+
<h5 class="mb-0">Geographic Scope</h5>
39+
<small
40+
class="text-muted"
41+
>Define where this program operates</small>
42+
</div>
43+
</div>
44+
<div class="d-flex align-items-center gap-2">
45+
<span
46+
class="badge rounded-pill bg-success"
47+
invisible="not geofence_ids"
48+
>
49+
<i class="fa fa-check me-1" />
50+
<field
51+
name="geofence_count"
52+
class="d-inline"
53+
/> geofence(s)
54+
</span>
55+
</div>
56+
</div>
57+
<div class="card-body py-3">
58+
<field
59+
name="geofence_ids"
60+
nolabel="1"
61+
readonly="state == 'ended'"
62+
>
63+
<list editable="bottom">
64+
<field name="name" readonly="1" />
65+
<field
66+
name="geofence_type"
67+
optional="hide"
68+
readonly="1"
69+
/>
70+
<field
71+
name="area_sqkm"
72+
string="Area (sq km)"
73+
readonly="1"
74+
/>
75+
</list>
76+
</field>
77+
</div>
78+
</div>
4779
</xpath>
4880
</field>
4981
</record>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
from . import create_program_wizard
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
from odoo import Command, fields, models
3+
4+
5+
class SPPCreateNewProgramWizGeofence(models.TransientModel):
6+
_inherit = "spp.program.create.wizard"
7+
8+
geofence_ids = fields.Many2many(
9+
"spp.gis.geofence",
10+
string="Geofences",
11+
help="Define the geographic scope for this program.",
12+
)
13+
14+
def get_program_vals(self):
15+
vals = super().get_program_vals()
16+
if self.geofence_ids:
17+
vals["geofence_ids"] = [Command.set(self.geofence_ids.ids)]
18+
return vals
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<odoo>
3+
<!-- Add geofences to the program creation wizard (step 1) -->
4+
<record id="create_program_wizard_form_view_geofence" model="ir.ui.view">
5+
<field name="name">Create Program Wizard - Geofence</field>
6+
<field name="model">spp.program.create.wizard</field>
7+
<field name="priority">15</field>
8+
<field name="inherit_id" ref="spp_programs.create_program_wizard_form_view" />
9+
<field name="arch" type="xml">
10+
<xpath expr="//group[@name='quick_options_section']" position="before">
11+
<group name="geofence_section">
12+
<group colspan="2">
13+
<field
14+
name="geofence_ids"
15+
widget="many2many_tags"
16+
string="Geofences"
17+
placeholder="Select geofences..."
18+
options="{'no_create': True, 'no_create_edit': True}"
19+
/>
20+
</group>
21+
</group>
22+
</xpath>
23+
</field>
24+
</record>
25+
</odoo>

0 commit comments

Comments
 (0)