<?xml version="1.0"?>
<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
    <data>
        <record model="res.group" id="group_sale">
            <field name="name">Sales</field>
        </record>
        <record model="res.group" id="group_sale_admin">
            <field name="name">Sales Administrator</field>
            <field name="parent" ref="group_sale"/>
        </record>
        <record model="res.user-res.group" id="user_admin_group_sale">
            <field name="user" ref="res.user_admin"/>
            <field name="group" ref="group_sale"/>
        </record>
        <record model="res.user-res.group" id="user_admin_group_sale_admin">
            <field name="user" ref="res.user_admin"/>
            <field name="group" ref="group_sale_admin"/>
        </record>

        <record model="ir.ui.icon" id="sale_icon">
            <field name="name">tryton-sale</field>
            <field name="path">icons/tryton-sale.svg</field>
        </record>

        <menuitem
            name="Sales"
            sequence="80"
            id="menu_sale"
            icon="tryton-sale"/>
        <record model="ir.ui.menu-res.group" id="menu_sale_group_sale">
            <field name="menu" ref="menu_sale"/>
            <field name="group" ref="group_sale"/>
        </record>

        <record model="ir.action.wizard" id="wizard_shipment_handle_exception">
            <field name="name">Handle Shipment Exception</field>
            <field name="wiz_name">sale.handle.shipment.exception</field>
            <field name="model">sale.sale</field>
        </record>

        <record model="ir.action.wizard" id="wizard_invoice_handle_exception">
            <field name="name">Handle Invoice Exception</field>
            <field name="wiz_name">sale.handle.invoice.exception</field>
            <field name="model">sale.sale</field>
        </record>

        <record model="ir.ui.view" id="sale_view_form">
            <field name="model">sale.sale</field>
            <field name="type">form</field>
            <field name="name">sale_form</field>
        </record>
        <record model="ir.ui.view" id="sale_view_tree">
            <field name="model">sale.sale</field>
            <field name="type">tree</field>
            <field name="name">sale_tree</field>
        </record>

        <record model="ir.ui.view" id="handle_shipment_exception_ask_view_form">
            <field name="model">sale.handle.shipment.exception.ask</field>
            <field name="type">form</field>
            <field name="name">handle_shipment_exception_ask_form</field>
        </record>

        <record model="ir.ui.view" id="handle_invoice_exception_ask_view_form">
            <field name="model">sale.handle.invoice.exception.ask</field>
            <field name="type">form</field>
            <field name="name">handle_invoice_exception_ask_form</field>
        </record>

        <record model="ir.action.act_window" id="act_shipment_form">
            <field name="name">Shipments</field>
            <field name="res_model">stock.shipment.out</field>
            <field name="domain"
                eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('moves.sale', '=', Eval('active_id')), ('moves.sale', 'in', Eval('active_ids')))]"
                pyson="1"/>
        </record>
        <record model="ir.action.keyword"
                id="act_open_shipment_keyword1">
            <field name="keyword">form_relate</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="act_shipment_form"/>
        </record>
        <record model="ir.action.act_window" id="act_return_form">
            <field name="name">Returns</field>
            <field name="res_model">stock.shipment.out.return</field>
            <field name="domain"
                eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('moves.sale', '=', Eval('active_id')), ('moves.sale', 'in', Eval('active_ids')))]"
                pyson="1"/>
        </record>
        <record model="ir.action.keyword" id="act_open_shipment_return_keyword1">
            <field name="keyword">form_relate</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="act_return_form"/>
        </record>

        <record model="ir.action.act_window" id="act_sale_form">
            <field name="name">Sales</field>
            <field name="res_model">sale.sale</field>
            <field name="search_value"></field>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_form_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="sale_view_tree"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_form_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="sale_view_form"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_form_domain_draft">
            <field name="name">Draft</field>
            <field name="sequence" eval="10"/>
            <field name="domain"
                eval="[('state', '=', 'draft')]"
                pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_form_domain_quotation">
            <field name="name">Quotation</field>
            <field name="sequence" eval="20"/>
            <field name="domain"
                eval="[('state', '=', 'quotation')]"
                pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_form_domain_confirmed">
            <field name="name">Confirmed</field>
            <field name="sequence" eval="30"/>
            <field name="domain"
                eval="[('state', '=', 'confirmed')]"
                pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_form_domain_processing">
            <field name="name">Processing</field>
            <field name="sequence" eval="40"/>
            <field name="domain"
                eval="[('state', '=', 'processing')]"
                pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_form_domain_exception">
            <field name="name">Exception</field>
            <field name="sequence" eval="50"/>
            <field name="domain"
                eval="['OR', ('invoice_state', '=', 'exception'), ('shipment_state', '=', 'exception')]"
                pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_form"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_form_domain_all">
            <field name="name">All</field>
            <field name="sequence" eval="9999"/>
            <field name="domain"></field>
            <field name="act_window" ref="act_sale_form"/>
        </record>

        <menuitem
            parent="menu_sale"
            action="act_sale_form"
            sequence="10"
            id="menu_sale_form"/>

        <record model="ir.action.act_window" id="act_sale_relate">
            <field name="name">Sales</field>
            <field name="res_model">sale.sale</field>
            <field name="domain"
                eval="[
                If(Eval('active_model') == 'party.party',
                ('party', 'in', Eval('active_ids', [])), ()),
                ]"
                pyson="1"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_relate_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="sale_view_tree"/>
            <field name="act_window" ref="act_sale_relate"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_relate_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="sale_view_form"/>
            <field name="act_window" ref="act_sale_relate"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_relate_pending">
            <field name="name">Pending</field>
            <field name="sequence" eval="10"/>
            <field name="domain" eval="[('state', 'not in', ['done', 'cancelled'])]" pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_relate"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_relate_done">
            <field name="name">Done</field>
            <field name="sequence" eval="20"/>
            <field name="domain" eval="[('state', '=', 'done')]" pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_relate"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_relate_all">
            <field name="name">All</field>
            <field name="sequence" eval="9999"/>
            <field name="domain"></field>
            <field name="act_window" ref="act_sale_relate"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_relate_keyword_party">
            <field name="keyword">form_relate</field>
            <field name="model">party.party,-1</field>
            <field name="action" ref="act_sale_relate"/>
        </record>

        <record model="ir.action.act_window" id="act_sale_relate_simple">
            <field name="name">Sales</field>
            <field name="res_model">sale.sale</field>
            <field
                name="domain"
                eval="[
                If(Eval('active_model') == 'account.invoice',
                ('invoices', 'in', Eval('active_ids', [])), ()),
                If(Eval('active_model') == 'stock.shipment.out',
                ('shipments', 'in', Eval('active_ids', [])), ()),
                If(Eval('active_model') == 'stock.shipment.out.return',
                ('shipment_returns', 'in', Eval('active_ids', [])), ()),
                ]"
                pyson="1"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_relate_simple_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="sale_view_tree"/>
            <field name="act_window" ref="act_sale_relate_simple"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_relate_simple_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="sale_view_form"/>
            <field name="act_window" ref="act_sale_relate_simple"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_relate_simple_keyword_invoice">
            <field name="keyword">form_relate</field>
            <field name="model">account.invoice,-1</field>
            <field name="action" ref="act_sale_relate_simple"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_relate_simple_keyword_shipment_out">
            <field name="keyword">form_relate</field>
            <field name="model">stock.shipment.out,-1</field>
            <field name="action" ref="act_sale_relate_simple"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_relate_simple_keyword_shipment_out_return">
            <field name="keyword">form_relate</field>
            <field name="model">stock.shipment.out.return,-1</field>
            <field name="action" ref="act_sale_relate_simple"/>
        </record>

        <record model="ir.model.access" id="access_sale">
            <field name="model">sale.sale</field>
            <field name="perm_read" eval="False"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_delete" eval="False"/>
        </record>
        <record model="ir.model.access" id="access_sale_sale">
            <field name="model">sale.sale</field>
            <field name="group" ref="group_sale"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_delete" eval="True"/>
        </record>

        <record model="ir.model.field.access" id="access_sale_sale_invoices_ignored">
            <field name="model">sale.sale</field>
            <field name="field">invoices_ignored</field>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
        </record>
        <record model="ir.model.field.access" id="access_sale_sale_invoices_ignored_sale_admin">
            <field name="model">sale.sale</field>
            <field name="field">invoices_ignored</field>
            <field name="group" ref="group_sale_admin"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
        </record>

        <record model="ir.rule.group" id="rule_group_sale_companies">
            <field name="name">User in companies</field>
            <field name="model">sale.sale</field>
            <field name="global_p" eval="True"/>
        </record>
        <record model="ir.rule" id="rule_sale_companies">
            <field name="domain"
                eval="[('company', 'in', Eval('companies', []))]"
                pyson="1"/>
            <field name="rule_group" ref="rule_group_sale_companies"/>
        </record>

        <record model="ir.model.button" id="sale_cancel_button">
            <field name="model">sale.sale</field>
            <field name="name">cancel</field>
            <field name="string">Cancel</field>
        </record>

        <record model="ir.model.button" id="sale_draft_button">
            <field name="model">sale.sale</field>
            <field name="name">draft</field>
            <field name="string">Draft</field>
        </record>

        <record model="ir.model.button" id="sale_quote_button">
            <field name="model">sale.sale</field>
            <field name="name">quote</field>
            <field name="string">Quote</field>
        </record>

        <record model="ir.model.button" id="sale_confirm_button">
            <field name="model">sale.sale</field>
            <field name="name">confirm</field>
            <field name="string">Confirm</field>
        </record>

        <record model="ir.model.button" id="sale_process_button">
            <field name="model">sale.sale</field>
            <field name="name">process</field>
            <field name="string">Process</field>
        </record>
        <record model="ir.model.button-res.group" id="sale_process_button_group_sale_admin">
            <field name="button" ref="sale_process_button"/>
            <field name="group" ref="group_sale_admin"/>
        </record>

        <record model="ir.model.button" id="sale_manual_invoice_button">
            <field name="model">sale.sale</field>
            <field name="name">manual_invoice</field>
            <field name="string">Create Invoice</field>
        </record>
        <record model="ir.model.button-res.group" id="sale_manual_invoice_button_group_sale">
            <field name="button" ref="sale_manual_invoice_button"/>
            <field name="group" ref="group_sale"/>
        </record>
        <record model="ir.model.button-res.group" id="sale_manual_invoice_button_group_account">
            <field name="button" ref="sale_manual_invoice_button"/>
            <field name="group" ref="account.group_account"/>
        </record>

        <record model="ir.model.button" id="sale_manual_shipment_button">
            <field name="model">sale.sale</field>
            <field name="name">manual_shipment</field>
            <field name="string">Create Shipment</field>
        </record>
        <record model="ir.model.button-res.group" id="sale_manual_shipment_button_group_sale">
            <field name="button" ref="sale_manual_shipment_button"/>
            <field name="group" ref="group_sale"/>
        </record>
        <record model="ir.model.button-res.group" id="sale_manual_shipment_button_group_stock">
            <field name="button" ref="sale_manual_shipment_button"/>
            <field name="group" ref="stock.group_stock"/>
        </record>

        <record model="ir.model.button" id="sale_modify_header_button">
            <field name="model">sale.sale</field>
            <field name="name">modify_header</field>
            <field name="string">Modify Header</field>
        </record>

        <record model="ir.model.button"
                id="sale_handle_shipment_exception_button">
            <field name="model">sale.sale</field>
            <field name="name">handle_shipment_exception</field>
            <field name="string">Handle Shipment Exception</field>
        </record>

        <record model="ir.model.button"
                id="sale_handle_invoice_exception_button">
            <field name="model">sale.sale</field>
            <field name="name">handle_invoice_exception</field>
            <field name="string">Handle Invoice Exception</field>
        </record>

        <record model="ir.sequence.type" id="sequence_type_sale">
            <field name="name">Sale</field>
        </record>
        <record model="ir.sequence.type-res.group"
            id="sequence_type_sale_group_admin">
            <field name="sequence_type" ref="sequence_type_sale"/>
            <field name="group" ref="res.group_admin"/>
        </record>
        <record model="ir.sequence.type-res.group"
            id="sequence_type_sale_group_sale_admin">
            <field name="sequence_type" ref="sequence_type_sale"/>
            <field name="group" ref="group_sale_admin"/>
        </record>

        <record model="ir.sequence" id="sequence_sale">
            <field name="name">Sale</field>
            <field name="sequence_type" ref="sequence_type_sale"/>
        </record>

        <record model="ir.action.report" id="report_sale">
            <field name="name">Sale</field>
            <field name="model">sale.sale</field>
            <field name="report_name">sale.sale</field>
            <field name="report">sale/sale.fodt</field>
        </record>
        <record model="ir.action.keyword" id="report_sale_keyword">
            <field name="keyword">form_print</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="report_sale"/>
        </record>

        <record model="ir.ui.view" id="sale_line_view_form">
            <field name="model">sale.line</field>
            <field name="type">form</field>
            <field name="name">sale_line_form</field>
        </record>

        <record model="ir.ui.view" id="sale_line_view_tree">
            <field name="model">sale.line</field>
            <field name="type">tree</field>
            <field name="priority" eval="10"/>
            <field name="name">sale_line_tree</field>
        </record>

        <record model="ir.ui.view" id="sale_line_view_tree_sequence">
            <field name="model">sale.line</field>
            <field name="type">tree</field>
            <field name="priority" eval="20"/>
            <field name="name">sale_line_tree_sequence</field>
        </record>

        <record model="ir.model.field.access" id="access_sale_line_moves_ignored">
            <field name="model">sale.line</field>
            <field name="field">moves_ignored</field>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
        </record>
        <record model="ir.model.field.access" id="access_sale_line_moves_ignored_sale_admin">
            <field name="model">sale.line</field>
            <field name="field">moves_ignored</field>
            <field name="group" ref="group_sale_admin"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
        </record>

        <record model="ir.action.act_window" id="act_sale_line_relate">
            <field name="name">Sale Lines</field>
            <field name="res_model">sale.line</field>
            <field
                name="domain"
                eval="[('type', '=', 'line'),
                If(Eval('active_model') == 'sale.sale',
                ('sale', 'in', Eval('active_ids', [])), ()),
                If(Eval('active_model') == 'product.product',
                ('product', 'in', Eval('active_ids', [])), ()),
                If(Eval('active_model') == 'product.template',
                ('product.template.id', 'in', Eval('active_ids', [])), ()),
                If(Eval('active_model') == 'party.party',
                ('customer', 'in', Eval('active_ids', [])), ()),
                ]"
                pyson="1"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_line_relate_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="sale_line_view_tree"/>
            <field name="act_window" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.act_window.view" id="act_sale_line_relate_view2">
            <field name="sequence" eval="20"/>
            <field name="view" ref="sale_line_view_form"/>
            <field name="act_window" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_line_relate_pending">
            <field name="name">Pending</field>
            <field name="sequence" eval="10"/>
            <field name="domain" eval="[('sale_state', 'not in', ['done', 'cancelled'])]" pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_line_relate_done">
            <field name="name">Done</field>
            <field name="sequence" eval="20"/>
            <field name="domain" eval="[('sale_state', '=', 'done')]" pyson="1"/>
            <field name="count" eval="True"/>
            <field name="act_window" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.act_window.domain" id="act_sale_line_relate_all">
            <field name="name">All</field>
            <field name="sequence" eval="9999"/>
            <field name="domain"></field>
            <field name="act_window" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_line_relate_keyword_sale">
            <field name="keyword">form_relate</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_line_relate_keyword_product">
            <field name="keyword">form_relate</field>
            <field name="model">product.product,-1</field>
            <field name="action" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_line_relate_keyword_product_template">
            <field name="keyword">form_relate</field>
            <field name="model">product.template,-1</field>
            <field name="action" ref="act_sale_line_relate"/>
        </record>
        <record model="ir.action.keyword" id="act_sale_line_relate_keyword_party">
            <field name="keyword">form_relate</field>
            <field name="model">party.party,-1</field>
            <field name="action" ref="act_sale_line_relate"/>
        </record>

        <record model="ir.ui.view" id="return_sale_start_view_form">
            <field name="model">sale.return_sale.start</field>
            <field name="type">form</field>
            <field name="name">return_sale_start_form</field>
        </record>

        <record model="ir.action.wizard" id="wizard_return_sale">
            <field name="name">Return Sale</field>
            <field name="wiz_name">sale.return_sale</field>
            <field name="model">sale.sale</field>
        </record>
        <record model="ir.action.keyword" id="act_wizard_return_sale_keyword">
            <field name="keyword">form_action</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="wizard_return_sale"/>
        </record>

        <record model="ir.action.wizard" id="wizard_modify_header">
            <field name="name">Modify Header</field>
            <field name="wiz_name">sale.modify_header</field>
            <field name="model">sale.sale</field>
        </record>
        <record model="ir.ui.view" id="modify_header_form">
            <field name="model">sale.sale</field>
            <field name="inherit" ref="sale.sale_view_form"/>
            <field name="name">modify_header_form</field>
            <field name="domain"
                eval="Eval('context', {}).get('modify_header', False)"
                pyson="1"/>
        </record>

        <record model="ir.action.wizard" id="wizard_sale_open_product">
            <field name="name">Products</field>
            <field name="wiz_name">sale.open_product</field>
            <field name="model">sale.sale</field>
        </record>
        <record model="ir.action.keyword" id="wizard_sale_open_product_keyword1">
            <field name="keyword">form_relate</field>
            <field name="model">sale.sale,-1</field>
            <field name="action" ref="wizard_sale_open_product"/>
        </record>
    </data>

    <data noupdate="1">
        <record model="ir.cron" id="cron_cancel_expired_quotation">
            <field name="method">sale.sale|cancel_expired_quotation</field>
            <field name="interval_number" eval="1"/>
            <field name="interval_type">days</field>
        </record>
    </data>
</tryton>
