Skip to content
Permalink
Browse files

[FIX] sale_margin: keep old Margin label

And use "Margin (%)" for the recently added margin_percent field
computing the margin in % and not in money.
  • Loading branch information
Feyensv committed Jan 10, 2020
1 parent 5a13364 commit 223d222ac8110944c999b2b3c2dbea74c48b3345
Showing with 5 additions and 5 deletions.
  1. +4 −4 addons/sale_margin/models/sale_order.py
  2. +1 −1 addons/sale_margin/views/sale_margin_view.xml
@@ -7,10 +7,10 @@ class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

margin = fields.Float(
"Profit", compute='_compute_margin',
"Margin", compute='_compute_margin',
digits='Product Price', store=True, groups="base.group_user")
margin_percent = fields.Float(
'Margin', compute='_compute_margin', store=True, groups="base.group_user")
"Margin (%)", compute='_compute_margin', store=True, groups="base.group_user")
purchase_price = fields.Float(
string='Cost', compute="_compute_purchase_price",
digits='Product Price', store=True, readonly=False,
@@ -52,8 +52,8 @@ def _compute_margin(self):
class SaleOrder(models.Model):
_inherit = "sale.order"

margin = fields.Monetary("Profit", compute='_compute_margin', store=True)
margin_percent = fields.Float("Margin", compute='_compute_margin', store=True)
margin = fields.Monetary("Margin", compute='_compute_margin', store=True)
margin_percent = fields.Float("Margin (%)", compute='_compute_margin', store=True)

@api.depends('order_line.margin', 'amount_untaxed')
def _compute_margin(self):
@@ -36,7 +36,7 @@
<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" invisible="1"/>
<field name="margin" optional="show"/>
<field name="margin_percent"
attrs="{'invisible': [('price_subtotal', '=', 0)]}"
optional="hide" widget="percentage"/>

0 comments on commit 223d222

Please sign in to comment.
You can’t perform that action at this time.