299 lines
14 KiB
XML
299 lines
14 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<!-- List View -->
|
|
<record id="view_dsrpt_contact_list" model="ir.ui.view">
|
|
<field name="name">dsrpt.contact.list</field>
|
|
<field name="model">dsrpt.contact</field>
|
|
<field name="arch" type="xml">
|
|
<list string="Contacts">
|
|
<field name="name"/>
|
|
<field name="user_id" optional="show"/>
|
|
<field name="next_contact" widget="date" optional="show"/>
|
|
<field name="communication_ids" widget="many2many_tags" optional="show"
|
|
context="{'tree_view_ref': 'dsrpt_address_book.view_dsrpt_contact_communication_tree_simple'}"/>
|
|
<field name="create_date" optional="hide"/>
|
|
<field name="write_date" optional="hide"/>
|
|
</list>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Form View -->
|
|
<record id="view_dsrpt_contact_form" model="ir.ui.view">
|
|
<field name="name">dsrpt.contact.form</field>
|
|
<field name="model">dsrpt.contact</field>
|
|
<field name="arch" type="xml">
|
|
<form string="Contact">
|
|
<sheet>
|
|
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" invisible="active"/>
|
|
<div class="oe_button_box" name="button_box">
|
|
<button name="action_view_events" type="object" class="oe_stat_button" icon="fa-calendar">
|
|
<field name="event_count" widget="statinfo" string="Events"/>
|
|
</button>
|
|
<!-- Calls button moved to dsrpt_calls module -->
|
|
</div>
|
|
<div class="oe_title">
|
|
<h1>
|
|
<field name="name" placeholder="Contact Name..."/>
|
|
</h1>
|
|
</div>
|
|
<!-- Top row: Basic info (left) and Notes (right) -->
|
|
<group col="2">
|
|
<group>
|
|
<field name="user_id"/>
|
|
<field name="source_id"/>
|
|
<field name="next_contact" readonly="1"/>
|
|
</group>
|
|
<group string="Notes">
|
|
<field name="note" nolabel="1" placeholder="Add notes about this contact..."/>
|
|
</group>
|
|
</group>
|
|
<field name="active" invisible="1"/>
|
|
|
|
<!-- Second row: Events (left) and Requests (right) -->
|
|
<group col="2" name="middle_section">
|
|
<group string="Events">
|
|
<field name="event_ids" nolabel="1" context="{'default_contact_id': id}">
|
|
<kanban>
|
|
<field name="date_start"/>
|
|
<field name="notes"/>
|
|
<field name="duration"/>
|
|
<field name="user_id"/>
|
|
<templates>
|
|
<t t-name="card">
|
|
<div class="oe_kanban_card oe_kanban_global_click" style="margin-bottom: 8px;">
|
|
<div class="o_kanban_record_body">
|
|
<!-- Date and time in bold -->
|
|
<div class="o_kanban_record_title mb-2">
|
|
<strong>
|
|
<t t-esc="luxon.DateTime.fromISO(record.date_start.raw_value).setLocale('en').toFormat('d MMMM yyyy')"/> •
|
|
<t t-esc="luxon.DateTime.fromISO(record.date_start.raw_value).toFormat('HH:mm')"/>
|
|
</strong>
|
|
</div>
|
|
|
|
<!-- Description full width -->
|
|
<div class="mb-2">
|
|
<field name="notes"/>
|
|
</div>
|
|
|
|
<!-- User avatar -->
|
|
<div t-if="record.user_id.raw_value" class="d-flex align-items-center">
|
|
<img t-attf-src="/web/image/res.users/{{record.user_id.raw_value}}/avatar_128"
|
|
class="o_kanban_image_fill_left"
|
|
width="24" height="24"
|
|
style="border-radius: 50%;"/>
|
|
<span class="ml-1 text-muted">
|
|
<field name="user_id"/>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</templates>
|
|
</kanban>
|
|
</field>
|
|
</group>
|
|
<!-- Requests group will be added by realty_sales module -->
|
|
<group name="requests_placeholder"/>
|
|
</group>
|
|
|
|
<!-- Third row: Addresses (full width) -->
|
|
<group col="1" string="Addresses">
|
|
<field name="address_ids" nolabel="1" context="{'default_contact_id': id}">
|
|
<list editable="bottom">
|
|
<field name="description"/>
|
|
<field name="latitude"/>
|
|
<field name="longitude"/>
|
|
</list>
|
|
</field>
|
|
</group>
|
|
|
|
<!-- Fourth row: Communications (full width) -->
|
|
<group col="1" string="Communications">
|
|
<field name="communication_ids" nolabel="1" context="{'default_contact_id': id}">
|
|
<list editable="bottom">
|
|
<field name="communication_type_id" options="{'no_create': True}"/>
|
|
<field name="value"/>
|
|
<field name="is_preferred" widget="boolean_toggle"/>
|
|
</list>
|
|
</field>
|
|
</group>
|
|
|
|
<!-- Fifth row: Calls (full width) - will be added by dsrpt_calls module -->
|
|
<group col="1" name="calls_section"/>
|
|
</sheet>
|
|
<chatter/>
|
|
</form>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Search View -->
|
|
<record id="view_dsrpt_contact_search" model="ir.ui.view">
|
|
<field name="name">dsrpt.contact.search</field>
|
|
<field name="model">dsrpt.contact</field>
|
|
<field name="arch" type="xml">
|
|
<search>
|
|
<field name="name"/>
|
|
<field name="phone_numbers" string="Phone"
|
|
filter_domain="[('phone_numbers', 'ilike', self)]"/>
|
|
<field name="communication_ids" string="Communication"
|
|
filter_domain="[('communication_ids.value', 'ilike', self)]"/>
|
|
|
|
<separator/>
|
|
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
|
|
<separator/>
|
|
<filter string="Create Date" name="group_create_date" context="{'group_by': 'create_date'}"/>
|
|
</search>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Simple tree for Many2many tags widget -->
|
|
<record id="view_dsrpt_contact_communication_tree_simple" model="ir.ui.view">
|
|
<field name="name">dsrpt.contact.communication.tree.simple</field>
|
|
<field name="model">dsrpt.contact.communication</field>
|
|
<field name="arch" type="xml">
|
|
<list>
|
|
<field name="communication_type_id"/>
|
|
<field name="value"/>
|
|
<field name="is_preferred"/>
|
|
</list>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Action -->
|
|
<record id="action_dsrpt_contact" model="ir.actions.act_window">
|
|
<field name="name">Contacts</field>
|
|
<field name="res_model">dsrpt.contact</field>
|
|
<field name="view_mode">list,form</field>
|
|
<field name="search_view_id" ref="view_dsrpt_contact_search"/>
|
|
<field name="context">{}</field>
|
|
<field name="help" type="html">
|
|
<p class="o_view_nocontent_smiling_face">
|
|
Create your first contact!
|
|
</p>
|
|
<p>
|
|
Manage your contacts and their communication methods in one place.
|
|
</p>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Server Actions -->
|
|
|
|
<!-- Server Action: Send Need Qualification Event -->
|
|
<record id="action_server_send_transcription_added" model="ir.actions.server">
|
|
<field name="name">Send Need Qualification Event</field>
|
|
<field name="model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_view_types">list,form</field>
|
|
<field name="state">code</field>
|
|
<field name="code">
|
|
# Send transcription added event for selected contacts
|
|
if records:
|
|
for record in records:
|
|
# Trigger event - listeners will decide what to do
|
|
# Send need events based on contact status
|
|
if record.status == 'awaiting_qualification':
|
|
record._event('on_need_qualification').notify(record)
|
|
else:
|
|
record._event('on_need_request_summary_update').notify(record)
|
|
record._event('on_need_calendar_event').notify(record)
|
|
|
|
# Show notification
|
|
# Count events sent
|
|
qualification_count = len([r for r in records if r.status == 'awaiting_qualification'])
|
|
other_count = len(records) - qualification_count
|
|
|
|
message_parts = []
|
|
if qualification_count:
|
|
message_parts.append(f"{qualification_count} qualification events")
|
|
if other_count:
|
|
message_parts.append(f"{other_count} summary/calendar events")
|
|
|
|
message = f"Need events sent: {', '.join(message_parts) if message_parts else 'none'}"
|
|
action = {
|
|
'type': 'ir.actions.client',
|
|
'tag': 'display_notification',
|
|
'params': {
|
|
'title': 'Event Sent',
|
|
'message': message,
|
|
'type': 'success',
|
|
'sticky': False,
|
|
}
|
|
}
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Server Action: Send Need Summary/Calendar Events -->
|
|
<record id="action_server_send_context_update" model="ir.actions.server">
|
|
<field name="name">Send Need Summary/Calendar Events</field>
|
|
<field name="model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_view_types">list,form</field>
|
|
<field name="state">code</field>
|
|
<field name="code">
|
|
# Send context update event for selected contacts
|
|
if records:
|
|
for record in records:
|
|
# Trigger event - ContextUpdatedListener will handle it
|
|
# Send need events for non-qualifying contacts
|
|
if record.status != 'awaiting_qualification':
|
|
record._event('on_need_request_summary_update').notify(record)
|
|
record._event('on_need_calendar_event').notify(record)
|
|
|
|
# Show notification
|
|
qualified_count = len([r for r in records if r.status == 'awaiting_qualification'])
|
|
processed_count = len(records) - qualified_count
|
|
|
|
message = f"Need events sent for {processed_count} contacts ({qualified_count} skipped - awaiting qualification)"
|
|
action = {
|
|
'type': 'ir.actions.client',
|
|
'tag': 'display_notification',
|
|
'params': {
|
|
'title': 'Event Sent',
|
|
'message': message,
|
|
'type': 'success',
|
|
'sticky': False,
|
|
}
|
|
}
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Server Action: Change Employee for Contacts -->
|
|
<record id="action_server_change_employee_contacts" model="ir.actions.server">
|
|
<field name="name">Change Employee</field>
|
|
<field name="model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_view_types">list</field>
|
|
<field name="state">code</field>
|
|
<field name="code">
|
|
if records:
|
|
action = {
|
|
'name': 'Change Employee',
|
|
'type': 'ir.actions.act_window',
|
|
'res_model': 'change.employee.wizard',
|
|
'view_mode': 'form',
|
|
'target': 'new',
|
|
'context': {
|
|
'active_model': 'dsrpt.contact',
|
|
'active_ids': records.ids,
|
|
'default_model_name': 'dsrpt.contact',
|
|
'default_field_name': 'user_id'
|
|
}
|
|
}
|
|
action = action
|
|
</field>
|
|
</record>
|
|
|
|
<!-- Server Action: Recompute Next Contact -->
|
|
<record id="action_server_recompute_next_contact" model="ir.actions.server">
|
|
<field name="name">Recompute "Next Contact"</field>
|
|
<field name="model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_model_id" ref="dsrpt_address_book.model_dsrpt_contact"/>
|
|
<field name="binding_view_types">list</field>
|
|
<field name="state">code</field>
|
|
<field name="code">
|
|
if records:
|
|
action = records[0].recompute_next_contact_all()
|
|
</field>
|
|
</record>
|
|
</odoo>
|