<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2019 Tecnativa - Ernesto Tejeda
     Copyright 2024 Moduon Team S.L. <info@moduon.team>
     License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
    <record id="sale_order_line_price_history_view_form" model="ir.ui.view">
        <field name="name">sale.order.line.price.history.view.form</field>
        <field name="model">sale.order.line.price.history</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <group>
                        <field name="partner_id" />
                        <field name="product_id" readonly="1" />
                        <field name="include_commercial_partner" />
                        <field name="include_quotations" />
                        <field name="sale_order_line_id" invisible="1" />
                    </group>
                    <group string="Sale history">
                        <field name="line_ids" nolabel="1" readonly="1" colspan="2">
                            <form>
                                <header>
                                    <field name="order_state" widget="statusbar" />
                                </header>
                                <sheet>
                                    <group>
                                        <field
                                            name="sale_order_line_id"
                                            invisible="1"
                                        />
                                        <field
                                            name="history_sale_order_line_id"
                                            invisible="1"
                                        />
                                        <field name="order_id" />
                                        <field name="partner_id" />
                                        <field name="sale_order_date_order" />
                                        <field name="product_uom_qty" />
                                        <field name="price_unit" />
                                        <label
                                            for="discount"
                                            groups="sale.group_discount_per_so_line"
                                        />
                                        <div
                                            name="discount"
                                            groups="sale.group_discount_per_so_line"
                                        >
                                            <field
                                            name="discount"
                                            class="oe_inline"
                                        /> %%
                                        </div>
                                    </group>
                                </sheet>
                                <footer />
                            </form>
                            <list decoration-info="order_state in ('draft', 'sent')">
                                <field name="order_id" />
                                <field name="order_state" column_invisible="1" />
                                <field
                                    name="partner_id"
                                    column_invisible="parent.partner_id"
                                />
                                <field name="sale_order_date_order" />
                                <field name="product_uom_qty" />
                                <field name="price_unit" />
                                <field
                                    name="discount"
                                    groups="sale.group_discount_per_so_line"
                                />
                                <field
                                    name="target_sale_order_line_id"
                                    string=" "
                                    widget="set_price_to_line_widget"
                                    help="Price History"
                                />
                            </list>
                        </field>
                    </group>
                </sheet>
                <footer>
                    <button special="cancel" string="Close" />
                </footer>
            </form>
        </field>
    </record>
    <record id="sale_order_line_price_history_action" model="ir.actions.act_window">
        <field name="name">Price history per customer</field>
        <field name="res_model">sale.order.line.price.history</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>
</odoo>
