<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 2020-2021 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_template_form_view" model="ir.ui.view">
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_form_view"/>
    <field name="arch" type="xml">
        <div name="options" position="inside">
            <div id="must_print_barcode">
                <field name="must_print_barcode"/>
                <label for="must_print_barcode"/>
            </div>
        </div>
    </field>
</record>


<record id="product_template_only_form_view" model="ir.ui.view">
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
    <field name="arch" type="xml">
        <header position="inside">
            <button name="generate_barcode_from_product_template" type="object" string="Generate Barcode" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('barcode', '!=', False)]}"/>
            <button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcode" groups="base_report_to_printer.printing_group_user" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('barcode', '=', False)]}"/>
        </header>
    </field>
</record>

<record id="product_template_tree_view" model="ir.ui.view">
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_tree_view"/>
    <field name="arch" type="xml">
        <field name="product_variant_count" position="before">
            <header>
                <button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcodes" groups="base_report_to_printer.printing_group_user"/>
            </header>
        </field>
    </field>
</record>


<record id="product_normal_form_view" model="ir.ui.view">
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view" />
    <field name="arch" type="xml">
        <header position="inside">
            <button name="generate_barcode_from_product_product" type="object" string="Generate Barcode" attrs="{'invisible': [('barcode', '!=', False)]}"/>
            <button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcode" groups="base_report_to_printer.printing_group_user" attrs="{'invisible': [('barcode', '=', False)]}"/>
        </header>
    </field>
</record>

<record id="product_product_tree_view" model="ir.ui.view">
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_product_tree_view"/>
    <field name="arch" type="xml">
        <field name="default_code" position="before">
            <header>
                <button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcodes" groups="base_report_to_printer.printing_group_user"/>
            </header>
        </field>
    </field>
</record>

</odoo>
