<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="event_tag_category_view_form" model="ir.ui.view">
        <field name="name">event_tag_category_view_form_inherit_kalachakra</field>
        <field name="model">event.tag.category</field>
        <field name="inherit_id" ref="event.event_tag_category_view_form" />
        <field name="arch" type="xml">
        <xpath expr="//div[@class='oe_title']" position="after">
        <group>  
                <field name="calendar_id"/>
        </group>
            </xpath>
            
        <xpath expr="//field[@name='color']" position="before">
                <field name="hidden"/>
        </xpath>
        </field>
</record>

<record id="kalachakra_event_view_tree" model="ir.ui.view">
        <field name="name">event.view.tree.inherit.kalachakra</field>
        <field name="model">event.event</field>
        <field name="inherit_id" ref="event.view_event_tree" />
        <field name="arch" type="xml">
        <xpath expr="//tree" position="attributes">
            <attribute name="decoration-danger"/>
        </xpath>
        <xpath expr="//field[@name='name']" position="attributes">
        <attribute name="class">tree_evt_name_column</attribute>
        </xpath>
        <xpath expr="//field[@name='seats_used']" position="after">
        
                <field string="calendar event id" name="calendar_event_id" invisible="context.get('booking_event_view')"/>
                
                <field name="online_event" invisible="context.get('booking_event_view')"/>
                <field name="onthespot_event" invisible="context.get('booking_event_view')"/>
                <field name="free_participation" invisible="context.get('booking_event_view')"/>
                <field name="participation_product_id" invisible="context.get('booking_event_view')"/>
                <field name="recurring_event" invisible="context.get('booking_event_view')"/>
                <field name="recurring_event_newsletter_id" invisible="context.get('booking_event_view')"/>
                <field name="find_out_more_link" invisible="context.get('booking_event_view')"/>
                <field name="online_link" invisible="context.get('booking_event_view')"/>
                <field name="online_id" invisible="context.get('booking_event_view')"/>
                <field name="online_password" invisible="context.get('booking_event_view')"/>
        </xpath>
        <xpath expr="//field[@name='date_begin']" position="replace">
        <field name="date_begin"/>
        </xpath>
        <xpath expr="//field[@name='date_end']" position="replace">
        <field name="date_end"/>
        </xpath>
        <xpath expr="//field[@name='address_id']" position="attributes">
        <attribute name="invisible">context.get('booking_event_view')</attribute>
        </xpath>
        <xpath expr="//field[@name='user_id']" position="attributes">
        <attribute name="invisible">context.get('booking_event_view')</attribute>
        </xpath>
 </field>
</record>
<record id="act_event_registration_from_event" model="ir.actions.act_window">
            <field name="res_model">event.registration</field>
            <field name="name">Attendees</field>
            <field name="view_mode">tree,kanban,form,calendar,graph</field>
            <field name="domain">[('event_id', '=', active_id)]</field>
            <field name="context">{'default_event_id': active_id,'booking_view':False}</field>
            <field name="help" type="html">
                <p class="o_view_nocontent_smiling_face">
                    Create an Attendee
                </p>
            </field>
        </record>
<record id="act_booking_event_registration_from_event" model="ir.actions.act_window">
            <field name="res_model">event.registration</field>
            <field name="name">Attendees</field>
            <field name="view_mode">kanban,tree,form,calendar,graph</field>
            <field name="domain">[('event_id', '=', active_id)]</field>
            <field name="context">{'default_event_id': active_id,'booking_view':True}</field>
            <field name="help" type="html">
                <p class="o_view_nocontent_smiling_face">
                    Create an Attendee
                </p>
            </field>
        </record>
<record id="kalachakra_event_view_form" model="ir.ui.view">
        <field name="name">event.view.form.inherit.kalachakra</field>
        <field name="model">event.event</field>
        <field name="inherit_id" ref="event.view_event_form" />
        <field name="arch" type="xml">
        <xpath expr="//div[@name='button_box']" position="replace">
        <field name="website_url" invisible="1"/>
                <field name="is_published" widget="website_redirect_button"/>
        <div class="oe_button_box" name="button_box" attrs="{'invisible':[('booking_event','=',False)]}" groups="base.group_user">
                            
                            <button name="%(act_booking_event_registration_from_event)d"
                                    type="action"
                                    context="{'search_default_expected': True,'booking_view':True}"
                                    class="oe_stat_button"
                                    icon="fa-users"
                                    help="Total Registrations for this Event">
                                <field name="seats_expected" widget="statinfo" string="Attendees"/>
                            </button>
                        </div>
        <div class="oe_button_box" name="button_box" attrs="{'invisible':[('booking_event','=',True)]}" groups="base.group_user">
                            <button name="%(kalachakra.act_event_registration_from_event)d"
                                    type="action"
                                    context="{'search_default_expected': True,'booking_view':False}"
                                    class="oe_stat_button"
                                    icon="fa-users"
                                    help="Total Registrations for this Event">
                                <field name="seats_expected" widget="statinfo" string="Attendees"/>
                            </button>
                        </div>
        
        </xpath>
        <xpath expr="//field[@name='stage_id']" position="before">      
                <button name="add_event_to_google_agenda" type="object" attrs="{'invisible':[('calendar_event_id','!=',False)]}" string="Add event to google agenda" class="btn btn-warning"/>
                <button name="remove_event_from_google_agenda" attrs="{'invisible':[('calendar_event_id','=',False)]}" type="object" string="Remove event from google agenda" class="btn btn-danger"/>
                 <button name="generate_calendar_events" attrs="{'invisible':[('generated_events','=',False)]}"  type="object" string="Add all event to google agenda" class="btn btn-primary"/>

                 <button name="generate_events" attrs="{'invisible':['|',('generated_events','=',True),'|','|',('frequency','=',False),('end_generation_date','=',False),('parent_event_id','!=',False)]}" type="object" string="generate the events" class="btn btn-primary"/>
                  <button name="remove_generated_events" attrs="{'invisible':['|',('generated_events','=',False),'|','|',('frequency','=',False),('end_generation_date','=',False),('parent_event_id','!=',False)]}" type="object" string="remove generated events" class="btn btn-danger"/>
                <button name="add_registration_to_mailing_list" type="object"  string="Add registrants to the mailing list" class="btn btn-primary"/>
                <field name="calendar_event_id" invisible="1"/>
                <field name="parent_event_id" invisible="1"/>
                <field name="frequency" invisible="1"/> 
                <field name="end_generation_date" widget="date" invisible="1"/>
                <field name="generated_events" invisible="1"/>

            </xpath>
        
        <xpath expr="//field[@name='tag_ids']" position="after">
                
                        
                    <field name="online_event" attrs="{'invisible':[('booking_event','=',True)]}"/>
                    <field name="no_online_payment" attrs="{'invisible':[('booking_event','=',True)]}"/>
                    <field name="online_only" attrs="{'invisible':[('booking_event','=',True)]}"/>
                    <field name="free_participation" attrs="{'invisible':[('booking_event','=',True)]}"/>
                    <field name="recurring_event" attrs="{'invisible':[('booking_event','=',True)]}"/>
                    
                    <field name="frequency" attrs="{'invisible':['|',('booking_event','=',True),('recurring_event','=',False)]}"/>
                    <field name="weekly_day" attrs="{'invisible':[('frequency','!=','weekly')]}"/> 
                    <field name="end_generation_date" widget="date" attrs="{'invisible':['|',('booking_event','=',True),('recurring_event','=',False)]}"/> 
                    <field name="parent_event_id" attrs="{'invisible':['|',('booking_event','=',True),('recurring_event','=',False)]}"/>

                    <field name="recurring_event_newsletter_id" attrs="{'invisible':[('booking_event','=',True)]}"/> 
                    <field name="find_out_more_link"/>
                
            </xpath>

        
        <xpath expr="//page[@name='event_communication']" position="before">
            
                <page string="Participations" name="Participations" attrs="{'invisible':['|',('free_participation','=',True),('booking_event','=',True)]}">
                
                <group style="width:40%%">
                <field name="booking_event" invisible="1"/> 
                <field name="participation_product_id" attrs="{'required': [('participation_standard_price','>',0),('booking_event','!=',True)]}"/>
                <field name="participation_standard_price" attrs="{'required': [('free_participation','=', False)]}"/>
                <field name="participation_member_price" attrs="{'required': [('free_participation','=', False)]}"/>
                <field name="participation_super_member_price" attrs="{'required': [('free_participation','=', False)]}"/>
                
                </group>
                </page>
                
                

                <page string="Online options" name="Online" attrs="{'invisible':['|',('online_event','=',False),('booking_event','=',True)]}">
                <group style="width:80%%">
                
                <field name="online_link" attrs="{'required': [('online_event','=', True)]}"/>
                <field name="online_id"/>
                <field name="online_password"/>
                
                </group>
                </page>

                <page string="Media records" name="Media records">
                <group style="width:100%%">
                <field name="teaching_html_content_records_published"/>
                <field name="teaching_html_content_records" type="html" options="{'collaborative': true}"/>
                <field name="display_english_records"/>
                <!-- <field name="only_audio_records"/>
                <field name="only_video_records"/> -->
                <field name="teaching_day_ids">
                <tree>
                <field name="sequence" widget="handle"/>
                <field name="day_teaching"/>
                <field name="description"/>
                    
                
                </tree>
                </field>
                
                </group>
                </page>

            
            </xpath>
        
       

        </field>
</record>


<record id="kalachakra.view_form_inherit_website" model="ir.ui.view">
        <field name="name">event.view.form.inherit.website.kalachakra</field>
        <field name="model">event.event</field>
        <field name="inherit_id" ref="website_event.event_event_view_form" />
        <field name="arch" type="xml">
        <xpath expr="//button[@name='action_open_badge_editor']" position="replace">
                
            </xpath>
        </field>
</record>

<record id="event_search_view" model="ir.ui.view">
        <field name="name">kalachakra.event.search</field>
        <field name="model">event.event</field>
        <field name="inherit_id" ref="event.view_event_search" />
        <field name="arch" type="xml">
            <filter name="myevents" position="before">
                <filter
                    name="filter_booking_event"
                    string="Booking events"
                    domain="[('booking_event', '=', True)]"
                />
                
            </filter>
        </field>
    </record> 


</odoo>
