<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        
        <!--
        Fiscal year
        -->    
        
        <record id="data_fiscalyear" model="account.fiscalyear">
            <field eval="'Fiscal Year X '+time.strftime('%Y')" name="name"/>
            <field eval="'FY'+time.strftime('%Y')" name="code"/>
            <field eval="time.strftime('%Y')+'-01-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-12-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        
        <!--
        Fiscal Periods
        -->    
        
        <record id="period_1" model="account.period">
            <field eval="'01/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 01/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-01-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-01-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_2" model="account.period">
            <field eval="'02/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 02/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-02-01'" name="date_start"/>
            <!-- for the last day of February, we have to compute the day before March 1st -->
            <field eval="(DateTime.today().replace(month=3, day=1) - timedelta(days=1)).strftime('%Y-%m-%d')" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_3" model="account.period">
            <field eval="'03/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 03/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-03-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-03-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_4" model="account.period">
            <field eval="'04/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 04/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-04-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-04-30'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_5" model="account.period">
            <field eval="'05/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 05/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-05-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-05-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_6" model="account.period">
            <field eval="'06/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 06/'+time.strftime('%Y')" name="name"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="True" name="special"/>
            <field eval="time.strftime('%Y')+'-06-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-06-30'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_7" model="account.period">
            <field eval="'07/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 07/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-07-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-07-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_8" model="account.period">
            <field eval="'08/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 08/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-08-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-08-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_9" model="account.period">
            <field eval="'09/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 09/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-09-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-09-30'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_10" model="account.period">
            <field eval="'10/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 10/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-10-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-10-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_11" model="account.period">
            <field eval="'11/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 11/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-11-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-11-30'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        <record id="period_12" model="account.period">
            <field eval="'12/'+time.strftime('%Y')" name="code"/>
            <field eval="'X 12/'+time.strftime('%Y')" name="name"/>
            <field eval="True" name="special"/>
            <field name="fiscalyear_id" ref="data_fiscalyear"/>
            <field eval="time.strftime('%Y')+'-12-01'" name="date_start"/>
            <field eval="time.strftime('%Y')+'-12-31'" name="date_stop"/>
            <field name="company_id" ref="base.main_company"/>
        </record>
        
        <!-- Payment Term -->
        
        <record id="account_payment_term" model="account.payment.term">
            <field name="name">30 Days End of Month</field>
            <field name="note">30 Days End of Month</field>
        </record>
        <record id="account_payment_term_line" model="account.payment.term.line">
            <field name="value">balance</field>
            <field eval="30" name="days"/>
            <field eval="-1" name="days2"/>
            <field eval="account_payment_term" name="payment_id"/>
        </record>
        
        <record id="account_payment_term_advance" model="account.payment.term">
            <field name="name">30% Advance End 30 Days</field>
            <field name="note">30% Advance End 30 Days</field>
        </record>
        <record id="account_payment_term_line_advance1" model="account.payment.term.line">
            <field name="value">procent</field>
            <field eval="0.300000" name="value_amount"/>
            <field eval="0" name="days"/>
            <field eval="0" name="days2"/>
            <field eval="account_payment_term_advance" name="payment_id"/>
        </record>
        <record id="account_payment_term_line_advance2" model="account.payment.term.line">
            <field name="value">balance</field>
            <field eval="30" name="days"/>
            <field eval="-1" name="days2"/>
            <field eval="account_payment_term_advance" name="payment_id"/>
        </record>

        <record id="base.user_demo" model="res.users">
            <field name="groups_id" eval="[(4,ref('account.group_account_user'))]"/> 
        </record>

        <!-- Add payment term on some demo partners -->
        <record id="base.res_partner_2" model="res.partner">
            <field name="property_payment_term" ref="account_payment_term_net"/>
        </record>
        <record id="base.res_partner_12" model="res.partner">
            <field name="property_payment_term" ref="account_payment_term"/>
            <field name="property_supplier_payment_term" ref="account_payment_term"/>
        </record>
        <record id="base.res_partner_4" model="res.partner">
            <field name="property_supplier_payment_term" ref="account_payment_term_net"/>
        </record>
        <record id="base.res_partner_1" model="res.partner">
            <field name="property_supplier_payment_term" ref="account_payment_term"/>
        </record>

    </data>
</openerp>
