Files
odoo_source/addons/sale_margin/views/sale_margin_view.xml
T
nie 8f6815857f [FIX] sale_margin: confusing margin percentage in pivot
Steps to reproduce the bug:
- Activate Margins in Sales > Settings
- Go to the pivot view of quotations
- In Measures, click Margin (%)

Bug:
Margin percentages are aggregated by computing the sum of the margin sub-percentages instead of using the data of the aggregated row (i.e. agg. margin / agg. total).

Explanation:
This is one of the flaws of the pivot view. The best way to solve this would be to create a custom aggregation in PostgreSQL.
This commit is just hiding the measure for now.

opw:2349896

closes odoo/odoo#60354

X-original-commit: 1e3fc6894b13d51a3f6327653afbf8d5a316a21d
Signed-off-by: backspac <backspac@users.noreply.github.com>
2020-10-20 10:18:57 +00:00

59 lines
2.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="sale_margin_sale_order">
<field name="name">sale.order.margin.view.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="after">
<label for="margin" groups="base.group_user"/>
<div class="text-nowrap" groups="base.group_user">
<field name="margin" class="oe_inline"/>
<span class="oe_inline" attrs="{'invisible': [('amount_untaxed', '=', 0)]}">
(<field name="margin_percent" nolabel="1" class="oe_inline" widget="percentage"/>)
</span>
</div>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="sale_margin_sale_order_line">
<field name="name">sale.order.line.margin.view.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="after">
<field name="purchase_price" groups="base.group_user"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="sale_margin_sale_order_line_form">
<field name="name">sale.order.line.tree.margin.view.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="after">
<field name="purchase_price" optional="hide"/>
<field name="margin" optional="hide"/>
<field name="margin_percent"
attrs="{'invisible': [('price_subtotal', '=', 0)]}"
optional="hide" widget="percentage"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="sale_margin_sale_order_pivot">
<field name="name">sale.order.margin.view.pivot</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sale_order_pivot"/>
<field name="arch" type="xml">
<pivot position="inside">
<field name="margin_percent" invisible="1"/>
</pivot>
</field>
</record>
</odoo>