This commit is contained in:
eman 2024-10-09 04:15:54 +03:00
parent 5e2e5a947f
commit e3c2041a2f
4 changed files with 112 additions and 55 deletions

View File

@ -8,7 +8,7 @@
'license': 'GPL-3',
'author': 'Expert Ltd',
'depends': ['base', 'takaful_core', 'website', 'account', 'report_xlsx', 'sale', 'product', 'stock', 'hr',
'purchase'],
'purchase','web_google_maps'],
'data': [
'security/security_view.xml',
'security/ir.model.access.csv',

View File

@ -650,43 +650,45 @@ class GrantBenefitProfile(models.Model):
result = geo_obj.geo_find(search, force_country=country)
return result, search
def geo_localize(self):
for location in self.with_context(lang='en_US'):
result = self._geo_localize(
street=location.street,
zip=location.zip,
city=location.city_id.name,
state=location.state_id.name,
country=location.country_id.name,
)
# url = "http://maps.google.com/maps?oi=map&q="
if result:
location.write(
{
'lat': result[0][0],
'lon': result[0][1],
}
)
return True
# if result[1]:
# url += result[1]
# if location.street:
# url += location.street.replace(' ', ',')
# if location.nearby_mosque:
# url += location.nearby_mosque.replace(' ', ',')
#
# return {
# 'type': 'ir.actions.act_url',
# 'target': 'new',
# 'url': url
# }
# def geo_localize(self):
# for location in self.with_context(lang='en_US'):
# result = self._geo_localize(
# street=location.street,
# zip=location.zip,
# city=location.city_id.name,
# state=location.state_id.name,
# country=location.country_id.name,
# )
# url = "http://maps.google.com/maps?oi=map&q="
# if result:
# location.write(
# {
# 'lat': result[0][0],
# 'lon': result[0][1],
# }
# )
# if result[1]:
# url += result[1]
# if location.street:
# url += location.street.replace(' ', ',')
# if location.nearby_mosque:
# url += location.nearby_mosque.replace(' ', ',')
#
# url = location.location_url
# return {
# 'type': 'ir.actions.act_url',
# 'target': 'new',
# 'url': url
# }
def geo_localize(self):
for location in self.with_context(lang='en_US'):
url = location.location_url
return {
'type': 'ir.actions.act_url',
'target': 'new',
'url': url
}
@api.depends('mother_marital', 'mother_income', 'mother_location', 'mother_country_id', 'state')
def check_mother_status(self):

View File

@ -6,7 +6,7 @@
<field name="name">Benefits Dashboard</field>
<field name="res_model">grant.benefit</field>
<!-- <field name="view_type">form</field>-->
<field name="view_mode">kanban,form,tree,activity</field>
<field name="view_mode">kanban,form,tree,activity,google_map</field>
<!-- <field name="domain">[('state','=','draft')]-->
<!-- </field>-->
<field name="help" type="html">

View File

@ -201,8 +201,10 @@
<field name="branch_custom_id" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" required="1"/>
<field name="district_id" attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<!-- <group>-->
<button name="geo_localize" string="Map" type="object"
class="oe_highlight"/>
<!-- <button name="geo_localize" string="Map" type="object"-->
<!-- class="oe_highlight"/>-->
<button name="%(odex_benefit.grant_map)d" type="action" class="oe_stat_button" context="{'search_default_name': name}" icon="fa-map-marker" string="Google Map" attrs="{'invisible': ['|',('lat', '=', 0.0), ('lon', '=', 0.0)]}"/>
<!-- </group>-->
</group>
</group>
@ -574,8 +576,8 @@
<!-- </div>-->
<h3>National address</h3>
<group>
<button name="geo_localize" string="Map" type="object"
class="oe_highlight"/>
<!-- <button name="geo_localize" string="Map" type="object"-->
<!-- class="oe_highlight"/>-->
</group>
<group>
<group>
@ -590,12 +592,12 @@
<field name="house_number"
attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="street" attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="lat"
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="lon"
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<field name="location_url"
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<!-- <field name="lat"-->
<!-- attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>-->
<!-- <field name="lon"-->
<!-- attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>-->
<!-- <field name="location_url"-->
<!-- attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>-->
</group>
<group>
<field name="floor"
@ -624,6 +626,18 @@
<field name="property_instrument_date" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])],'invisible':[('property_type','!=','ownership'),('property_type','!=','charitable'),('property_type','!=','ownership_shared')]}"/>
</group>
</group>
<group colspan="2" col="2">
<separator string="Geolocation" colspan="2"/>
<button string="Geolocalize" name="geo_localize" type="object" icon="fa-check" colspan="2"/>
<div>
<span class="oe_inline"> ( </span>
<span> Lat : </span>
<field name="lat" class="oe_inline" no_label="1" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<span> : Long : </span>
<field name="lon" class="oe_inline" nolabel="1" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
<span>) </span>
</div>
</group>
</sheet>
</form>
</page>
@ -1064,19 +1078,59 @@
</activity>
</field>
</record>
<!-- <record id="view_grant_benefit_graph" model="ir.ui.view">-->
<!-- <field name="name">grant.benefit.graph</field>-->
<!-- <field name="model">grant.benefit</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <graph type="pie">-->
<!-- <field name="family_id" type="row"/>-->
<!-- <field name="gender" type="row"/>-->
<!--&lt;!&ndash; <field name="benefit_category_id" type="row"/>&ndash;&gt;-->
<!-- <field name="total_expenses" type="measure"/>-->
<!-- <field name="total_income" type="measure"/>-->
<!-- </graph>-->
<!-- </field>-->
<!-- </record>-->
<record id="grant_google_map" model="ir.ui.view">
<field name="name">view.grant.benefit.google_map</field>
<field name="model">grant.benefit</field>
<field name="arch" type="xml">
<google_map string="Maps" lat="lat" lng="lon" color="color">
<field name="lat"/>
<field name="lon"/>
<field name="partner_id"/>
<!-- <field name="color"/>-->
<!-- <field name="priority"/>-->
<!-- <field name="tag_ids"/>-->
<field name="user_id"/>
<progressbar field="activity_state" colors='{"planned": "success", "today": "warning", "overdue": "danger"}'/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_content">
<div>
<strong class="o_kanban_record_title">
<span>
<field name="name"/>
</span>
</strong>
</div>
<div>
<span class="o_kanban_record_subtitle">
<field name="partner_id"/>
</span>
</div>
<!-- <div>-->
<!-- <field name="tag_ids"/>-->
<!-- </div>-->
<!-- <div class="o_kanban_record_bottom">-->
<!-- <div class="oe_kanban_bottom_left">-->
<!-- <field name="priority" widget="priority"/>-->
<!-- </div>-->
<!-- <div class="oe_kanban_bottom_right">-->
<!-- <field name="user_id" widget="many2one_avatar_user"/>-->
<!-- </div>-->
<!-- </div>-->
</div>
</t>
</templates>
</google_map>
</field>
</record>
<record id="grant_map" model="ir.actions.act_window">
<field name="name">Google Map</field>
<field name="res_model">grant.benefit</field>
<field name="view_mode">google_map</field>
<field name="view_id" ref="odex_benefit.grant_google_map"/>
<field name="domain">[('id', '=', active_id)]</field>
</record>
<!--External Benefits-->
<record id="external_benefit_view_tree" model="ir.ui.view">
<field name="name">external_benefit_view_tree</field>
@ -1226,6 +1280,7 @@
<field name="city_id"/>
<field name="street"/>
<field name="location"/>
<field name="location"/>
<field name="work"/>
<field name="partner_id" required="0" readonly="1"/>
</group>