<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 2016-2020 Akretion France (http://www.akretion.com/)
  @author: Alexis de Lattre <alexis.delattre@akretion.com>
  License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<odoo>

<record id="product_print_zpl_barcode_form" model="ir.ui.view">
    <field name="name">product_print_zpl_barcode.form</field>
    <field name="model">product.print.zpl.barcode</field>
    <field name="arch" type="xml">
        <form>
            <group name="step1">
                <field name="state" invisible="1"/>
                <field name="company_id" groups="base.group_multi_company"/>
                <field name="company_id" invisible="1"/>
                <field name="pricelist_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>
                <field name="label_size" attrs="{'readonly': [('state', '=', 'step2')]}"/>
                <field name="nomenclature_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>
            </group>
            <group name="step2" states="step2">
                <field name="zpl_file" filename="zpl_filename" />
                <field name="zpl_filename" invisible="1"/>
                <field name="zpl_printer_id" attrs="{'required': [('state', '=', 'step2')]}"/>
            </group>
            <group name="lines">
                <field name="line_ids" colspan="2" nolabel="1">
                    <tree editable="bottom">
                        <field name="currency_id" invisible="1"/>
                        <field name="product_id" optional="hide" force_save="1"/>
                        <field name="product_name"/>
                        <field name="price_uom"/>
                        <field name="rule_id" optional="show"/>
                        <field name="barcode_type" optional="hide"/>
                        <field name="barcode" force_save="1"/>
                        <field name="price" attrs="{'invisible': [('barcode_type', 'not in', ('price', 'weight'))]}"/>
                        <field name="quantity" attrs="{'invisible': [('barcode_type', '=', 'product')]}" optional="show"/>
                        <field name="uom_id" attrs="{'invisible': [('barcode_type', '=', 'product')]}" optional="show"/>
                        <field name="copies" />
                    </tree>
                </field>
            </group>
            <footer>
                <button name="generate" type="object" string="Generate Labels" class="btn-primary" states="step1"/>
                <button special="cancel" string="Cancel" class="btn-default" states="step1"/>
                <button name="print_zpl" type="object" string="Print" class="btn-primary" states="step2"/>
                <button special="cancel" string="Close" class="btn-default" states="step2"/>
            </footer>
        </form>
    </field>
</record>

<record id="product_print_zpl_barcode_action" model="ir.actions.act_window">
    <field name="name">Generate Barcode</field>
    <field name="res_model">product.print.zpl.barcode</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
</record>

</odoo>
