<openerp>
<data>
    <record model="ir.ui.view" id="view_sale_journal_invoice_type_form">
        <field name="name">sale_journal.invoice.type.form</field>
        <field name="model">sale_journal.invoice.type</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Invoice Type">
                <field name="name" select="1"/>
                <field name="active" select="1"/>
                <field name="invoicing_method" select="1"/>
                <newline/>
                <field name="note" colspan="4"/>
            </form>
        </field>
    </record>
    <record model="ir.ui.view" id="view_sale_journal_invoice_type_tree">
        <field name="name">sale_journal.invoice.type.tree</field>
        <field name="model">sale_journal.invoice.type</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Invoice Type">
                <field name="name"/>
                <field name="invoicing_method"/>
            </tree>
        </field>
    </record>
    <record model="ir.actions.act_window" id="action_definition_journal_invoice_type">
        <field name="res_model">sale_journal.invoice.type</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
    
    <menuitem name="Invoicing Methods" id="menu_definition_journal_invoice_type" parent="sale.menu_shop_configuration" action="action_definition_journal_invoice_type"/>

    <record model="ir.ui.view" id="view_sale_journal_form">
        <field name="name">sale_journal.sale.journal.form</field>
        <field name="model">sale_journal.sale.journal</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Sale Journal">
                <notebook>
                <page string="Journal">
                    <separator string="Journal Information" colspan="4"/>
                    <field name="name" select="1"/>
                    <field name="code" select="1"/>
                    <field name="user_id" select="1"/>
                    <field name="date" select="1"/>
                    <field name="date_created" select="1"/>
                    <field name="date_validation" select="1"/>
                    <separator string="States" colspan="4"/>
                    <field name="state"/>
                    <group col="3" colspan="2">
                        <button name="button_open" string="Open Journal" states="draft" type="object"/>
                        <button name="button_close" string="Close Journal" states="open" type="object"/>
                        <button name="button_draft" string="Set to Draft" states="close,open" type="object"/>
                    </group>
                </page>
                <page string="Sales">
                    <button string="Confirm Sales" name="button_sale_confirm" states="draft,open" type="object"/>
                    <button string="Cancel Sales" name="button_sale_cancel" states="draft,open" type="object"/>
                    <newline/>
                    <field name="sale_stats_ids" colspan="4" nolabel="1">
                        <tree string="Sales">
                            <field name="name"/>
                            <field name="quantity"/>
                            <field name="price_total"/>
                            <field name="price_average"/>
                            <field name="count"/>
                            <field name="state"/>
                        </tree>
                    </field>
                </page><page string="Notes">
                    <field name="note" colspan="4" nolabel="1"/>
                </page>
                </notebook>
            </form>
        </field>
    </record>
    <record model="ir.ui.view" id="view_sale_journal_tree">
        <field name="name">sale_journal.sale.journal.tree</field>
        <field name="model">sale_journal.sale.journal</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sale Journal">
                <field name="name" select="1"/>
                <field name="code" select="1"/>
                <field name="user_id" select="1"/>
                <field name="date" select="1"/>
                <field name="state"/>
            </tree>
        </field>
    </record>
    <record model="ir.actions.act_window" id="action_definition_journal">
        <field name="res_model">sale_journal.sale.journal</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
    
    <menuitem name="Sales Journals" id="menu_definition_journal" parent="sale.menu_shop_configuration" action="action_definition_journal"/>

    <record model="ir.actions.act_window" id="action_definition_journal_tree">
        <field name="res_model">sale_journal.sale.journal</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[]</field>
    </record>
    
    <menuitem name="Sales by Journal" id="menu_definition_journal_sales" parent="sale.menu_sale_root" action="action_definition_journal_tree"/>

    <record model="ir.actions.act_window" id="action_definition_journal_tree_my">
        <field name="name">My open journals</field>
        <field name="res_model">sale_journal.sale.journal</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('user_id','=',uid),('state','=','open')]</field>
    </record>
    
    <menuitem name="My Open Journals" id="menu_definition_journal_sales_my_open" parent="menu_definition_journal_sales" action="action_definition_journal_tree_my"/>

    <record model="ir.actions.act_window" id="action_definition_journal_tree_all">
        <field name="name">Open journals</field>
        <field name="res_model">sale_journal.sale.journal</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','open')]</field>
    </record>
    
    <menuitem name="All Open Journals" id="menu_definition_journal_sales_all_open" parent="menu_definition_journal_sales" action="action_definition_journal_tree_all"/>

    <record model="ir.ui.view" id="sale_journal_sale_order">
        <field name="name">sale.order.journal.view.form</field>
        <field name="type">form</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form" />
        <field name="arch" type="xml">
            <field name="invoiced" position="after">
                <field name="journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
            </field>
        </field>
    </record>
    <record model="ir.ui.view" id="sale_journal_sale_order_tree">
        <field name="name">sale.order.journal.view.tree</field>
        <field name="type">tree</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_tree" />
        <field name="arch" type="xml">
            <field name="state" position="after">
                <field name="invoice_type_id"/>
                <field name="journal_id"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_journal_picking_order">
        <field name="name">stock.picking.journal.view.form</field>
        <field name="type">form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form" />
        <field name="arch" type="xml">
            <field name="origin" position="after">
                <field name="journal_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_journal_picking_order_tree">
        <field name="name">stock.picking.journal.view.tree</field>
        <field name="type">tree</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.vpicktree" />
        <field name="arch" type="xml">
            <field name="invoice_state" position="after">
                <field name="journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_journal_picking_order_del">
        <field name="name">stock.picking.journal.view.form</field>
        <field name="type">form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_delivery_form" />
        <field name="arch" type="xml">
            <field name="origin" position="after">
                <field name="journal_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_journal_picking_order_tree_del">
        <field name="name">stock.picking.journal.view.tree</field>
        <field name="type">tree</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_delivery_tree" />
        <field name="arch" type="xml">
            <field name="origin" position="after">
                <field name="journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
            </field>
        </field>
    </record>


    <record model="ir.ui.view" id="sale_journal_picking_order_in">
        <field name="name">stock.picking.journal.view.form</field>
        <field name="type">form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_in_form" />
        <field name="arch" type="xml">
            <field name="origin" position="after">
                <field name="journal_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_journal_picking_order_tree_in">
        <field name="name">stock.picking.journal.view.tree</field>
        <field name="type">tree</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_in_tree" />
        <field name="arch" type="xml">
            <field name="invoice_state" position="after">
                <field name="journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
            </field>
        </field>
    </record>


    <record model="ir.ui.view" id="sale_journal_picking_order_out">
        <field name="name">stock.picking.journal.view.form</field>
        <field name="type">form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_out_form" />
        <field name="arch" type="xml">
            <field name="origin" position="after">
                <field name="journal_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_journal_picking_order_tree_out">
        <field name="name">stock.picking.journal.view.tree</field>
        <field name="type">tree</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_out_tree" />
        <field name="arch" type="xml">
            <field name="invoice_state" position="after">
                <field name="journal_id" select="1"/>
                <field name="invoice_type_id" select="1"/>
                <field name="sale_journal_id" select="1"/>
            </field>
        </field>
    </record>



    <record model="ir.ui.view" id="view_sale_journal_sale_stats_tree">
        <field name="name">sale_journal.sale.stats.tree</field>
        <field name="model">sale_journal.sale.stats</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Sales by Journal">
                <field name="name"/>
                <field name="state"/>
                <field name="journal_id"/>
                <field name="quantity"/>
                <field name="count"/>
                <field name="price_total"/>
                <field name="price_average"/>
            </tree>
        </field>
    </record>
    <record model="ir.ui.view" id="view_sale_journal_sale_stats_form">
        <field name="name">sale_journal.sale.stats.form</field>
        <field name="model">sale_journal.sale.stats</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Sales by Journal">
                <field name="name" select="1"/>
                <field name="state" select="1"/>
                <field name="journal_id" select="1"/>
                <field name="quantity"/>
                <field name="count"/>
                <field name="price_total"/>
                <field name="price_average"/>
            </form>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_sale_sale_stats_open_menu_month">
        <field name="name">Sales by journal (this month)</field>
        <field name="res_model">sale_journal.sale.stats</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
    </record>
    
    <menuitem name="Reporting" id="menu_definition_report_sales" parent="sale.menu_sale_root"/>
    <menuitem name="This Month" id="menu_definition_report_sales_this_month" parent="menu_definition_report_sales"/>
    <menuitem name="Sales by Journal" id="menu_sale_sale_stats_open_menu" parent="menu_definition_report_sales_this_month" action="action_sale_sale_stats_open_menu_month"/>

    <record model="ir.actions.act_window" id="action_sale_sale_stats_open_menu_all">
        <field name="res_model">sale_journal.sale.stats</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
    
    <menuitem name="All Months" id="menu_definition_report_sales_all_month" parent="menu_definition_report_sales"/>
    <menuitem name="Sales by Journal" id="menu_sale_sale_stats_open_all" parent="menu_definition_report_sales_all_month" action="action_sale_sale_stats_open_menu_all"/>

    <act_window name="Monthly sales"
        domain="[('journal_id', '=', active_id)]"
        res_model="sale_journal.sale.stats"
        src_model="sale_journal.sale.journal"
        id="act_sale_journal_sale_journal_2_sale_journal_sale_stats"/>

    <act_window name="Assigned packing"
        domain="[('journal_id', '=', active_id),('state', '=', 'assigned')]"
        res_model="stock.picking"
        src_model="sale_journal.picking.journal"
        id="act_sale_journal_picking_journal_2_stock_picking_assigned"/>

    <act_window name="Confirmed packing"
        domain="[('journal_id', '=', active_id),('state', '=', 'confirmed')]"
        res_model="stock.picking"
        src_model="sale_journal.picking.journal"
        id="act_sale_journal_picking_journal_2_stock_picking_confirmed"/>

    <act_window name="Assigned packing"
        domain="[('sale_journal_id', '=', active_id),('state', '=', 'assigned')]"
        res_model="stock.picking"
        src_model="sale_journal.sale.journal"
        id="act_sale_journal_sale_journal_2_stock_picking_assigned"/>

    <act_window name="Confirmed packing"
        domain="[('sale_journal_id', '=', active_id),('state', '=', 'confirmed')]"
        res_model="stock.picking"
        src_model="sale_journal.sale.journal"
        id="act_sale_journal_sale_journal_2_stock_picking_confirmed"/>

    <act_window name="Draft sales"
        domain="[('journal_id', '=', active_id),('state', '=', 'draft')]"
        res_model="sale.order"
        src_model="sale_journal.sale.journal"
        id="act_sale_journal_sale_journal_2_sale_order_draft"/>

    <act_window name="Approved sales"
        domain="[('journal_id', '=', active_id),('state', '=', 'approved')]"
        res_model="sale.order"
        src_model="sale_journal.sale.journal"
        id="act_sale_journal_sale_journal_2_sale_order_approved"/>

    <record id="view_partner_property_form" model="ir.ui.view">
        <field name="name">res.partner.journal.property.form.inherit</field>
        <field name="model">res.partner</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <page string="Sales &amp; Purchases" position="inside">
                <field name="property_invoice_type"/>
            </page>
        </field>
    </record>


</data>
</openerp>
