You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
1.2 KiB

# -*- coding: utf-8 -*-
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
import openerp.addons.decimal_precision as dp
class PosOrderLine(models.Model):
_inherit = 'pos.order.line'
# Columns Section
margin = fields.Float(
'Margin', compute='_compute_multi_margin', store=True,
multi='multi_margin',
digits_compute=dp.get_precision('Product Price'))
purchase_price = fields.Float(
'Cost Price', compute='_compute_multi_margin', store=True,
multi='multi_margin',
digits_compute=dp.get_precision('Product Price'))
# Compute Section
@api.multi
@api.depends('product_id', 'qty', 'price_subtotal')
def _compute_multi_margin(self):
for line in self:
if not line.product_id:
line.purchase_price = 0
line.margin = 0
else:
line.purchase_price = line.product_id.standard_price
line.margin = line.price_subtotal - (
line.product_id.standard_price * line.qty)