<?xml version="1.0" encoding="UTF-8"?>
<odoo>

  <record id="product_template_form_view_rental" model="ir.ui.view">
    <field name="name">product.template.form.inherit.rental</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_form_view"/>
    <field name="arch" type="xml">
      <xpath expr="//div[@name='options']" position='inside'>
        <div>
          <field name="rent_ok"/>
          <label for="rent_ok"/>
        </div>
      </xpath>
      <xpath expr="//notebook/page[@name='sales']" position="attributes">
        <attribute name="attrs">
          {'invisible':[('sale_ok','=',False), ('rent_ok', '=', False)]}
        </attribute>
      </xpath>
      <xpath expr="//notebook/page[@name='sales']" position="after">
        <page string="Rental" name="rental" attrs="{'invisible': [('rent_ok','=',False)]}">
          <group>
            <group string="Rental Pricing" name="pricing">
                <field name="rental_pricing_ids" nolabel="1">
                  <tree editable="bottom">
                    <control>
                        <create name="add_rental_pricing" string="Add a price"/>
                    </control>
                    <field name="product_variant_ids" widget="many2many_tags"
                      groups="product.group_product_variant"
                      domain="[('product_tmpl_id', '=', parent.id)]"
                      attrs="{'column_invisible': [('parent.product_variant_count', '&lt;', 2)]}"/>
                    <field name="duration"/>
                    <field name="unit"/>
                    <field name="price"/>
                    <field name="pricelist_id" groups="product.group_product_pricelist"/>
                    <field name="currency_id" invisible="1"/>
                  </tree>
                </field>
            </group>
            <group string="Reservations" name="extra">
              <field name="extra_hourly" widget="monetary"/>
              <field name="extra_daily" widget="monetary"/>
              <field name="currency_id" invisible="1"/>
            </group>
          </group>
        </page>
      </xpath>
    </field>
  </record>


  <record id="rental_product_template_search_view" model="ir.ui.view">
    <field name="name">product.template.search.inherit.rental</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_search_view"/>
    <field name="arch" type="xml">
      <xpath expr="//filter[@name='filter_to_purchase']" position="after">
        <filter string="Can be Rented" name="filter_to_rent" domain="[('rent_ok', '=', True)]"/>
      </xpath>
    </field>
  </record>

</odoo>
