Skip to content

Commit

Permalink
[FIX] sale_margin: keep old Margin label
Browse files Browse the repository at this point in the history
And use "Margin (%)" for the recently added margin_percent field
computing the margin in % and not in money.
  • Loading branch information
Feyensv committed Jan 14, 2020
1 parent 0d8836f commit b10c9d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions addons/sale_margin/models/sale_order.py
Expand Up @@ -7,10 +7,10 @@ class SaleOrderLine(models.Model):
_inherit = "sale.order.line" _inherit = "sale.order.line"


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


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


@api.depends('order_line.margin', 'amount_untaxed') @api.depends('order_line.margin', 'amount_untaxed')
def _compute_margin(self): def _compute_margin(self):
Expand Down
2 changes: 1 addition & 1 deletion addons/sale_margin/views/sale_margin_view.xml
Expand Up @@ -36,7 +36,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="after"> <xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="after">
<field name="purchase_price" optional="hide"/> <field name="purchase_price" optional="hide"/>
<field name="margin" invisible="1"/> <field name="margin" optional="hide"/>
<field name="margin_percent" <field name="margin_percent"
attrs="{'invisible': [('price_subtotal', '=', 0)]}" attrs="{'invisible': [('price_subtotal', '=', 0)]}"
optional="hide" widget="percentage"/> optional="hide" widget="percentage"/>
Expand Down

0 comments on commit b10c9d9

Please sign in to comment.