<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record model="ir.ui.view" id="helpdesk_ticket_morsa_inherit">
            <field name="name">helpdesk.ticket.form.inherit</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.helpdesk_ticket_form_view"/>
            <field name="priority" eval="17"/>
            <field name="arch" type="xml">
                <xpath expr="//header" position="replace">
                    <header>
                        <button name="assign_me" type="object" string="Assignar a mi" class="oe_highlight"/>
                        <button name="action_approve" type="object" string="Siguiente etapa" class="oe_highlight" attrs="{'invisible':['|','|',('cancel_stage_boolean','=',True),('done_stage_boolean','=',True),('closed_stage_boolean','=',True)]}"/>
                        <button name="action_reply" type="object" string="Respuesta" class="oe_highlight" attrs="{'invisible':[('open_boolean','=',True)]}"/>
                        <button name="action_done" type="object" string="Resolver Ticket" class="oe_highlight" attrs="{'invisible':['|','|',('done_button_boolean','=',True),('open_boolean','=',True),('is_purchase','=',True)]}"/>
                        <button name="change_ticket_team" type="object" string="Resolver Ticket" class="oe_highlight" attrs="{'invisible':[('is_purchase','=',False)]}"/>
                        <button name="action_closed" type="object" string="Cerrar Ticket" class="oe_highlight" attrs="{'invisible':['|',('done_stage_boolean','=',False),('open_boolean','=',False)]}"/>
                        <button name="action_cancel" type="object" string="Cancelar Ticket" class="oe_highlight" attrs="{'invisible':[('cancel_button_boolean','=',False)]}"/>
                        <button name="action_open" type="object" string="Re-Abrir Ticket" class="oe_highlight" attrs="{'invisible':[('open_boolean','=',False)]}"/>
                        <button name="preview_ticket" type="object" string="Vista previa"/>
                        <field name="stage_id" widget="statusbar"/>
                    </header>
                </xpath>


                <xpath expr="//div[@class='oe_title']" position="replace">
                    <h1><field name="name" readonly="1"/></h1>
                    <field name="active" invisible="1"/>
                    <field name="category_bool" invisible="1"/>
                    <field name="sub_category_bool" invisible="1"/>
                    <field name="rating_bool" invisible="1"/>
                    <field name="sh_status_boolean" invisible="1"/>
                    <field name="done_stage_boolean" invisible="1"/>
                    <field name="cancel_stage_boolean" invisible="1"/>
                    <field name="closed_stage_boolean" invisible="1"/>
                    <field name="ticket_from_website" invisible="1"/>
                    <field name="ticket_from_portal" invisible="1"/>
                    <field name="reopen_stage_boolean" invisible="1"/>
                    <field name="cancel_button_boolean" invisible="1"/>
                    <field name="done_button_boolean" invisible="1"/>
                    <field name="open_boolean" invisible="1"/>
                    <field name="sh_days_to_reach" invisible="1"/>
                    <field name="sh_days_to_late" invisible="1"/>
                    <field name="sh_ticket_report_url" invisible="1"/>
                    <field name="portal_ticket_url_wp" invisible="1"/>
                    <field name="state" invisible="1"/>
                    <field name="is_support" invisible="1"/>
                    <field name="is_erp" invisible="1"/>
                    <field name="is_emergency" invisible="1"/>
                    <field name="is_purchase" invisible="1"/>
                    <field name="in_proggres_stage" invisible="1"/>
                    <field name="team_members" widget="many2manytags" invisible="1"/>
                    <label for="description" string="Descripción del problema"/>
                    <h3>
                        <field name="description" placeholder="Descripción" attrs="{'invisible':[('is_support', '=', True)]}"/>
                        <field name="support_description" placeholder="Descripción" attrs="{'invisible':[('is_support', '=', False)]}"/>
                    </h3>
                    <label for="descripcion_solution"/>
                    <h3>
                        <field name="descripcion_solution" attrs="{'required':[('is_support', '=', True),('in_proggres_stage', '=', True)]}"/>
                    </h3>
                </xpath>
                <xpath expr="//group[1]" position="replace"></xpath>
                <xpath expr="//page[1]" position="replace">
                    <page string="Información General">
                        <group>
                            <group>
                                <field name="ticket_type" required="1"/>
                                <field name="team_id" invisible="1"/>
                                <field name="team_head" invisible="1"/>
                                <field name="team_admin_id" invisible="1"/>
                                <field name="user_id"/>
                                <field name="category_id"/>
                                <field name="priority"/>
                                <field name="ticket_reason"/>
                                <field name="incidence_type" attrs="{'invisible':[('is_emergency', '=', False)]}"/>
                                <field name="erp_type" widget="radio" attrs="{'invisible':[('is_erp', '=', False)]}" options="{'horizontal': true}"/>
                                <field name="erp_id" attrs="{'invisible':[('is_erp', '=', False)]}"/>
                                <field name="warehouse_id" attrs="{'invisible':[('is_erp', '=', False)]}"/>
                            </group>
                            <group>
                                <field name="tag_ids" invisible="1"/>
                                <field name="subject_id" invisible="1"/>
                                <field name="sub_category_id" invisible="1"/>
                                <field name="partner_id"/>
                                <field name="user_branch_id"/>
                                <field name="user_region_id"/>
                                <field name="mobile_no"/>
                                <field name="person_name" invisible="1"/>
                                <field name="email" invisible="1"/>
                                <field name="system_id" attrs="{'invisible':[('is_support', '=', False),('is_erp', '=', False),('is_emergency', '=', False)]}"/>
                                <field name="requires_configuration" attrs="{'invisible':[('is_purchase', '=', False)]}"/>
                                <field name="module_route" attrs="{'invisible':['|',('is_erp', '=', False),('erp_type','not in',['mejora','reporte'])]}"/>
                                <field name="process_text" attrs="{'invisible':['|',('is_erp', '=', False),('erp_type','not in',['mejora','reporte'])]}"/>
                                <field name="required_validation" attrs="{'invisible':['|',('is_erp', '=', False),('erp_type','not in',['mejora','reporte'])]}"/>
                                <field name="common_scenery" attrs="{'invisible':['|',('is_erp', '=', False),('erp_type','not in',['mejora','reporte'])]}"/>
                                <field name="module_impact" attrs="{'invisible':['|',('is_erp', '=', False),('erp_type','not in',['mejora','reporte'])]}"/>
                            </group>
                        </group>
                        
                    </page>
                </xpath>
                
                <xpath expr="//field[@name='customer_comment']" position="before">
                    <field name="problem_solved_on_time" readonly="1"/>
                    <field name="good_service_actitude" readonly="1"/>
                    <field name="begin_before_ten_min" readonly="1"/>
                </xpath>

                <xpath expr="//page[5]" position="inside">
                    <group>
                        <group string="Fechas de Movimientos">
                            <field name="create_date"/>
                            <field name="write_date"/>
                            <field name="sh_due_date"/>
                            <field name="replied_date"/>
                        </group>    
                        <group string="SLA INFO">
                            <field name="sh_sla_deadline" attrs="{'invisible':[('sh_sla_deadline','=',False)]}"/>
                            <field name="sh_sla_policy_ids" invisible="1"/>
                            <field name="sh_ticket_alarm_ids" widget="many2many_tags"/>
                        </group>
                    </group>
                    
                </xpath>

                <xpath expr="//field[@name='helpdesk_stage_history_line']" position="attributes">
                    <attribute name="readonly">1</attribute>
                    <attribute name="force_save">1</attribute>
                </xpath>

                <xpath expr="//field[@name='priority_new']" position="attributes">
                    <attribute name="readonly">1</attribute>
                    <attribute name="force_save">1</attribute>
                </xpath>
                <xpath expr="//field[@name='customer_comment']" position="attributes">
                    <attribute name="readonly">1</attribute>
                    <attribute name="force_save">1</attribute>
                </xpath>
                
                <xpath expr="//notebook" position="inside">
                    <page string="Movimiento de usuarios">
                        <div class="row">
                            <div class="col-12">
                                <field name="user_changes_ids" force_save="1" readonly="1">
                                    <tree>
                                        <field name="create_date" string="Fecha de creación"/>
                                        <field name="user_id"/>
                                        <field name="user_second_id"/>
                                    </tree>
                                </field>
                            </div>
                        </div>
                       
                    </page>
                </xpath>
                
                <xpath expr="//page[2]//group" position="replace">
                    <div class="row">
                        <field name="attachment_ids" widget="many2many_binary"/>
                    </div>
                  
                </xpath>

            </field>
        </record>


        <record id="helpdesk_sh_sale_form_inherit" model="ir.ui.view">
            <field name="name">helpdesk.ticket.form.inherit.sale</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.sh_helpdesk_tickets_so_inherited_view_form" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='sh_sale_order_ids']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
            </field>
        </record>
        
        <record id="helpdesk_sh_purchase_form_inherit" model="ir.ui.view">
            <field name="name">helpdesk.ticket.form.inherit.purchase</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.sh_helpdesk_tickets_po_inherited_view_form" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='sh_purchase_order_ids']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
            </field>
        </record> 

        <record id="helpdesk_sh_invoice_form_inherit" model="ir.ui.view">
            <field name="name">helpdesk.ticket.form.inherit.invoice</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.sh_helpdesk_tickets_invoice_inherited_view_form" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='sh_invoice_ids']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
            </field>
        </record> 

        <record id="helpdesk_sh_crm_form_inherit" model="ir.ui.view">
            <field name="name">helpdesk.ticket.form.inherit.crm</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.sh_helpdesk_tickets_crm_inherited_view_form" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='sh_lead_ids']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
               
            </field>
        </record>


        <record id="helpdesk_ticket_kanban_inherit_quick_create" model="ir.ui.view">
            <field name="name">helpdesk.ticket.kanban.inherit</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.helpdesk_ticket_kanban"/>
            <field name="arch" type="xml">
                <xpath expr="//kanban" position="attributes">
                    <attribute name="on_create">quick_create</attribute>
                    <attribute name="quick_create_view">helpdesk_morsa.quick_create_helpdesk_ticket</attribute>
                </xpath>
                <field name="user_id" position="after">
                    <field name="erp_id"/>
                    <field name="incidence_type"/>
                    <field name="warehouse_id"/>
                    <field name="call_before_10"/>
                </field>
                
                <xpath expr="//div[@t-attf-class='#{kanban_color(record.color.raw_value)} oe_kanban_global_click']" position="attributes">
                    <attribute t-else="" name="t-attf-class">{{'oe_kanban_color_' + kanban_getcolor(record.color.raw_value) }} oe_kanban_card oe_kanban_global_click</attribute>
                    <t t-if="kanban_getcolor(record.color.raw_value) == 9 ">
                        <attribute name="style">background-color:red;</attribute>
                    </t>
                    <t t-else="">
                        <attribute name="style"></attribute>
                    </t>
                </xpath>

                <xpath expr="//div[@class='badge badge-pill badge-primary float-right']" position="replace"></xpath>

                <xpath expr="//div[@class='badge badge-pill badge-success float-right']" position="replace"></xpath>
                
                <xpath expr="//field[@name='state']" position="replace">
                    <div class="badge badge-pill float-right">
                        <field name="user_id"/>
                    </div>
                </xpath>

                

            </field>
        </record>

        
        <record id="helpdesk_ticket_kanban_replace_button" model="ir.ui.view">
            <field name="name">helpdesk.ticket.kanban.replace.button</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.sh_helpdesk_ticket_time_inherit_kanban_view" />
            <field name="arch" type="xml">
                <xpath expr="//button[@name='action_ticket_start']" position="replace">
                    <button name="open_form_change_user" type="object" string="Asignarme" class="btn-primary">Asignarme</button>
                </xpath>
                <xpath expr="//button[@name='action_ticket_end']" position="replace">
                   
                </xpath>
            </field>
        </record>
        

        <record id="quick_create_helpdesk_ticket" model="ir.ui.view">
            <field name="name">helpdesk.ticket.quick_create</field>
            <field name="model">helpdesk.ticket</field>
            <field name="arch" type="xml">
                <form string="">
                    <group>
                        <field name="team_id" required="1" string="Tipo de ticket"/>
                        <field name="ticket_type" required="1" invisible="1"/>
                        <field name="partner_id" required="1"/>
                        <field name="is_support" invisible="1"/>
                        <field name="is_erp" invisible="1"/>
                        <field name="is_emergency" invisible="1"/>
                        <field name="is_purchase" invisible="1"/>
                        <field name="erp_type" widget="radio" attrs="{'invisible':[('is_erp', '=', False)]}" options="{'horizontal': true}"/>
                        <field name="erp_id" attrs="{'invisible':[('is_erp', '=', False)]}"/>
                        <field name="warehouse_id" attrs="{'invisible':[('is_erp', '=', False)]}"/>
                        <field name="incidence_type" attrs="{'invisible':[('is_emergency', '=', False)]}"/>
                    </group>
                </form>
            </field>
        </record>


        <record id="helpdesk_ticket_inherit_tree_hide" model="ir.ui.view">
            <field name="name">helpdesk.ticket.tree.inherit</field>
            <field name="model">helpdesk.ticket</field>
            <field name="inherit_id" ref="sh_all_in_one_helpdesk.helpdesk_ticket_tree_view"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='team_id']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//field[@name='team_head']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//field[@name='subject_id']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//field[@name='sub_category_id']" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//field[@name='category_id']" position="after">
                    <field name="description"/>
                </xpath>
            </field>
        </record>

    </data>
</odoo>