<?xml version="1.0" encoding="utf-8" ?>

<odoo>
    <data>
        <record id="product_brand_id" model="ir.ui.view">
            <field name="name">Brand Name</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
            <field name="arch" type="xml">
                <field name="categ_id" position="after">
                    <field name="brand_id"/>
                </field>
            </field>
        </record>


        <record id="product_brand_action" model="ir.actions.act_window">
            <field name="name">Product Brand</field>
            <field name="res_model">product.brand</field>
            <field name="view_mode">tree,form</field>
        </record>

        <record id="product_brand_view" model="ir.ui.view">
            <field name="name">Product Brand</field>
            <field name="model">product.brand</field>
            <field name="arch" type="xml">
                <form>
                    <sheet>
                        <field name="brand_image"  widget="image" class="oe_avatar"/>
                        <div class="oe_title">
                            <label for="name" class="oe_edit_only" string="Brand Name"/>
                            <h1>
                                <field name="name"/>
                            </h1>
                            <div name="options_active" />
                        </div>
                        <group>
                            <field name="product_count" style="width:40px;"/>
                        </group>


                        <notebook>
                            <page string="Products">
                                <field name="member_ids" widget="many2many" options="{'not_delete': True}">
                                    <kanban quick_create="false" create="true" delete="true">
                                        <field name="id"/>
                                        <field name="name"/>
                                        <templates>
                                            <t t-name="kanban-box">
                                                <div class="oe_kanban_global_click" style="max-width: 200px">
                                                    <div class="o_kanban_record_top">
                                                        <img t-att-src="kanban_image('product.template', 'image_128', record.id.raw_value)" class="oe_avatar oe_kanban_avatar_smallbox o_image_40_cover mb0" alt="Avatar"/>
                                                        <div class="o_kanban_record_headings ml8">
                                                            <strong class="o_kanban_record_title"><field name="name"/></strong>
                                                        </div>
                                                    </div>
                                                </div>
                                            </t>
                                        </templates>
                                    </kanban>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="brand_group_by" model="ir.ui.view">
            <field name="name">product.template.search.inherit</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_search_view"/>
            <field name="arch" type="xml">
                <xpath expr="//search" position="inside">
                      <filter string="Brand" name="Brand" context="{'group_by':'brand_id'}"/>
                </xpath>
            </field>
        </record>

         <menuitem id="brand_product_sale"
                   name="Product Brands"
                   parent="sale.product_menu_catalog"
                   sequence="3"
                   action="product_brand_action"/>
    </data>
</odoo>