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

    <!-- Server action for mass update from list view -->
    <record id="action_sale_update_from_list_price" model="ir.actions.server">
      <field name="name">Update with List Price</field>
      <field name="model_id" ref="sale.model_sale_order" />
      <field name="binding_model_id" ref="sale.model_sale_order" />
      <field name="binding_view_types">list,form</field>
      <field name="state">code</field>
      <field name="code">records.action_update_lines_from_list_price()</field>
    </record>

    <!-- Button in sale order form -->
    <record id="view_order_form_update_list_price" model="ir.ui.view">
      <field name="name">sale.order.form.update.list.price</field>
      <field name="model">sale.order</field>
      <field name="inherit_id" ref="sale.view_order_form" />
      <field name="arch" type="xml">
        <xpath expr="//button[@name='action_update_prices']" position="after">
          <button
            name="action_update_lines_from_list_price"
            type="object"
            string="Update with List Price"
            class="btn-link mb-1 px-0"
            icon="fa-refresh"
            invisible="invoice_status in ('invoiced','up_to_date') or state == 'cancel'"
          />
        </xpath>
      </field>
    </record>

    <!-- Action menu entry in tree/list view -->
    <record id="view_order_tree_update_list_price" model="ir.ui.view">
      <field name="name">sale.order.tree.update.list.price</field>
      <field name="model">sale.order</field>
      <field name="inherit_id" ref="sale.view_quotation_tree" />
      <field name="arch" type="xml">
        <xpath expr="//list" position="attributes">
          <attribute name="decoration-muted">state == 'cancel'</attribute>
        </xpath>
      </field>
    </record>

  </data>
</odoo>
