<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="view_docx_template_tree" model="ir.ui.view">
            <field name="name">docx.template.tree</field>
            <field name="model">docx.template</field>
            <field name="arch" type="xml">
                <list string="DOCX-шаблоны договоров">
                    <field name="name"/>
                    <field name="docx_output_type"/>
                    <field name="docx_model_id"/>
                </list>
            </field>
        </record>

        <record id="view_docx_template_form" model="ir.ui.view">
            <field name="name">docx.template.form</field>
            <field name="model">docx.template</field>
            <field name="arch" type="xml">
                <form string="DOCX-шаблон договора">

                    <header>
                        <button name="action_validate_docx_template"
                                type="object"
                                string="Валидация"
                                class="oe_highlight"/>
                    </header>
                    <sheet>
                        <div class="oe_button_box" name="button_box">
                            <button name="action_bind_to_actions"
                                    type="object"
                                    icon="fa-bolt"
                                    string="Добавить печать в действия"
                                    invisible="not docx_model_id or binding_model_id"/>

                            <button name="action_unbind_from_actions"
                                    type="object"
                                    icon="fa-times"
                                    string="Убрать печать из действий"
                                    invisible="not binding_model_id"/>
                        </div>
                        <group>
                            <field name="name"/>
                            <field name="docx_output_type"/>
                            <field name="docx_model_id"
                                   context="{'from_docx_template': True}"
                                   options="{'no_quick_create': True, 'no_create': True}"/>
                        </group>
                        <group string="DOCX-шаблон">
                            <field name="report_docx_template"
                                   filename="print_report_name"/>
                            <field name="print_report_name" invisible="1"/>
                            <field name="filename_pattern"/>
                            <field name="global_template"/>
                        </group>
                        <notebook>
                            <page string="Кастомные переменные">
                                <field name="docx_custom_field_ids">
                                    <list editable="bottom">
                                        <field name="technical_name"/>
                                        <field name="name"/>
                                        <field name="value_python"/>
                                    </list>
                                    <form>
                                        <group>
                                            <field name="technical_name"/>
                                            <field name="name"/>
                                            <field name="value_python"/>
                                        </group>
                                    </form>
                                </field>
                            </page>
                            <page string="Доступные переменные">
                                <group>
                                    <field name="hint_model_id"
                                       string="Модель для подсказки"
                                       context="{'from_docx_template': True}"
                                       options="{'no_create': True, 'no_quick_create': True}"/>
                                </group>



                                <field name="available_field_ids" readonly="1">
                                    <list>
                                        <field name="name"
                                               string="Техническое имя"/>
                                        <field name="field_description"
                                               string="Название поля"/>
                                        <field name="docx_type_label"
                                               string="Тип поля"/>
                                    </list>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="action_contract_docx_template" model="ir.actions.act_window">
            <field name="name">Шаблоны</field>
            <field name="res_model">docx.template</field>
            <field name="view_mode">list,form</field>
        </record>

        <menuitem id="menu_contract_docx_template"
                  name="Шаблоны для отчетов"
                  action="action_contract_docx_template"
                  sequence="50"/>
    </data>
</odoo>
