feat(odoo): add conversation and partner views

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude AI
2026-01-29 22:45:44 +00:00
parent f1933cf0d0
commit 48db1a94f7
2 changed files with 205 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- Inherit Partner Form -->
<record id="view_partner_form_whatsapp" model="ir.ui.view">
<field name="name">res.partner.form.whatsapp</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<!-- Add WhatsApp button box -->
<xpath expr="//div[@name='button_box']" position="inside">
<button name="action_open_whatsapp_conversations" type="object" class="oe_stat_button" icon="fa-whatsapp">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="whatsapp_conversation_count"/>
</span>
<span class="o_stat_text">WhatsApp</span>
</div>
</button>
</xpath>
<!-- Add WhatsApp action buttons -->
<xpath expr="//div[hasclass('oe_title')]" position="after">
<div class="mb-2" invisible="not mobile and not phone">
<button name="action_send_whatsapp" string="Enviar WhatsApp" type="object" class="btn btn-success" icon="fa-whatsapp"/>
<button name="action_open_whatsapp_chat" string="Abrir Chat" type="object" class="btn btn-outline-success ms-1" icon="fa-comments"/>
</div>
</xpath>
<!-- Add WhatsApp notebook page -->
<xpath expr="//notebook" position="inside">
<page string="WhatsApp" name="whatsapp" invisible="whatsapp_conversation_count == 0">
<field name="whatsapp_conversation_ids" mode="tree" readonly="1">
<tree>
<field name="account_id"/>
<field name="status" widget="badge"/>
<field name="last_message_at"/>
<field name="last_message_preview"/>
<field name="unread_count" widget="badge" decoration-danger="unread_count > 0"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>
<!-- Partner Tree - Add WhatsApp indicator -->
<record id="view_partner_tree_whatsapp" model="ir.ui.view">
<field name="name">res.partner.tree.whatsapp</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='phone']" position="after">
<field name="whatsapp_unread_count" widget="badge" decoration-danger="whatsapp_unread_count > 0" optional="show"/>
</xpath>
</field>
</record>
<!-- Server Action: Send WhatsApp -->
<record id="action_partner_send_whatsapp" model="ir.actions.server">
<field name="name">Enviar WhatsApp</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="binding_model_id" ref="base.model_res_partner"/>
<field name="binding_view_types">list,form</field>
<field name="state">code</field>
<field name="code">
if records:
if len(records) == 1:
action = records.action_send_whatsapp()
else:
action = {
'type': 'ir.actions.act_window',
'name': 'Envío Masivo WhatsApp',
'res_model': 'whatsapp.mass.wizard',
'view_mode': 'form',
'target': 'new',
'context': {'default_partner_ids': records.ids},
}
</field>
</record>
</odoo>

View File

@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- Tree View -->
<record id="view_whatsapp_conversation_tree" model="ir.ui.view">
<field name="name">whatsapp.conversation.tree</field>
<field name="model">whatsapp.conversation</field>
<field name="arch" type="xml">
<tree decoration-bf="unread_count > 0">
<field name="display_name"/>
<field name="phone_number"/>
<field name="status" widget="badge" decoration-info="status == 'bot'" decoration-warning="status == 'waiting'" decoration-success="status == 'active'" decoration-muted="status == 'resolved'"/>
<field name="assigned_user_id" widget="many2one_avatar_user"/>
<field name="last_message_at"/>
<field name="last_message_preview"/>
<field name="unread_count" widget="badge" decoration-danger="unread_count > 0"/>
</tree>
</field>
</record>
<!-- Form View -->
<record id="view_whatsapp_conversation_form" model="ir.ui.view">
<field name="name">whatsapp.conversation.form</field>
<field name="model">whatsapp.conversation</field>
<field name="arch" type="xml">
<form>
<header>
<button name="action_assign_to_me" string="Asignarme" type="object" class="btn-primary" invisible="assigned_user_id"/>
<button name="action_mark_resolved" string="Resolver" type="object" class="btn-secondary" invisible="status == 'resolved'"/>
<field name="status" widget="statusbar" statusbar_visible="bot,waiting,active,resolved"/>
</header>
<sheet>
<group>
<group>
<field name="display_name" readonly="1"/>
<field name="phone_number"/>
<field name="partner_id"/>
</group>
<group>
<field name="account_id"/>
<field name="assigned_user_id"/>
<field name="last_message_at"/>
</group>
</group>
<notebook>
<page string="Mensajes" name="messages">
<field name="message_ids" mode="tree" readonly="1">
<tree>
<field name="create_date"/>
<field name="direction" widget="badge"/>
<field name="content"/>
<field name="status" widget="badge"/>
<field name="sent_by_id"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- Kanban View -->
<record id="view_whatsapp_conversation_kanban" model="ir.ui.view">
<field name="name">whatsapp.conversation.kanban</field>
<field name="model">whatsapp.conversation</field>
<field name="arch" type="xml">
<kanban default_group_by="status">
<field name="display_name"/>
<field name="phone_number"/>
<field name="status"/>
<field name="unread_count"/>
<field name="last_message_preview"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div class="oe_kanban_content">
<div class="o_kanban_record_title">
<strong><field name="display_name"/></strong>
<span t-if="record.unread_count.raw_value > 0" class="badge bg-danger ms-2">
<t t-esc="record.unread_count.value"/>
</span>
</div>
<div class="text-muted">
<field name="phone_number"/>
</div>
<div class="text-truncate">
<field name="last_message_preview"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!-- Search View -->
<record id="view_whatsapp_conversation_search" model="ir.ui.view">
<field name="name">whatsapp.conversation.search</field>
<field name="model">whatsapp.conversation</field>
<field name="arch" type="xml">
<search>
<field name="display_name"/>
<field name="phone_number"/>
<field name="partner_id"/>
<filter name="filter_unread" string="No Leídos" domain="[('unread_count', '>', 0)]"/>
<filter name="filter_active" string="Activas" domain="[('status', 'in', ['bot', 'waiting', 'active'])]"/>
<filter name="filter_mine" string="Mis Conversaciones" domain="[('assigned_user_id', '=', uid)]"/>
<group expand="0" string="Agrupar por">
<filter name="group_status" string="Estado" context="{'group_by': 'status'}"/>
<filter name="group_account" string="Cuenta" context="{'group_by': 'account_id'}"/>
<filter name="group_agent" string="Agente" context="{'group_by': 'assigned_user_id'}"/>
</group>
</search>
</field>
</record>
<!-- Action -->
<record id="action_whatsapp_conversation" model="ir.actions.act_window">
<field name="name">Conversaciones</field>
<field name="res_model">whatsapp.conversation</field>
<field name="view_mode">kanban,tree,form</field>
<field name="context">{'search_default_filter_active': 1}</field>
</record>
</odoo>