<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="1">
        <!-- 
            Illustrate one aspect of bug #452854:
            Cannot validate invoices with foreign currency
        -->
        
        <!-- Enforce main company currency in EUR -->
        <record id="base.main_company" model="res.company">
            <field name="currency_id" ref="base.EUR"/>
        </record>
        
        <!--  Force currency exchange rate to trigger the issue -->
        <record id="base.rateCHF" model="res.currency.rate">
            <field name="rate" eval="0.6547"/>
        </record>
        
        <!-- Then create invoice in foreign currency to test rounding issue -->
        <record id="invoice_bug452854" model="account.invoice">
            <field name="currency_id" ref="base.CHF" />
            <field name="company_id" ref="base.main_company" />
            <field name="address_invoice_id" ref="base.res_partner_address_tang" />
            <field name="partner_id" ref="base.res_partner_asus" />
            <field name="journal_id" ref="account.sales_journal" />
            <field name="state">draft</field>
            <field name="type">out_invoice</field>
            <field name="account_id" ref="account.a_recv" />
            <field name="name">lp:452854</field>
            <field name="address_contact_id" ref="base.res_partner_address_tang" />
        </record>
        <record id="invoice_bug452854_line_1" model="account.invoice.line">
            <field name="name">Rolex</field>
            <field name="invoice_id" ref="invoice_bug452854" />
            <field name="price_unit" eval="1144" />
            <field name="quantity">1</field>
            <field name="account_id" ref="account.a_sale" />
        </record>
        <record id="invoice_bug452854_line_2" model="account.invoice.line">
            <field name="name">Ricola aux herbes</field>
            <field name="invoice_id" ref="invoice_bug452854" />
            <field name="price_unit" eval="91.73" />
            <field name="quantity">1</field>
            <field name="account_id" ref="account.a_sale" />
        </record>
        <record id="invoice_bug452854_line_3" model="account.invoice.line">
            <field name="name">Toblerone 750g</field>
            <field name="invoice_id" ref="invoice_bug452854" />
            <field name="price_unit" eval="63.00" />
            <field name="quantity">1</field>
            <field name="account_id" ref="account.a_sale" />
        </record>
        <workflow action="invoice_open" model="account.invoice" ref="invoice_bug452854" />
        <assert id="invoice_bug452854" model="account.invoice" severity="error" string="Invoice lp:452854 validated correctly">
            <test expr="state">open</test>
        </assert>
    </data>
</openerp>
