# -*- coding: utf-8 -*- ############################################################################## # # datenpol gmbh # Copyright (C) 2013-TODAY datenpol gmbh () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################## from odoo import api, fields, models, _ class SaleOrderLine(models.Model): _inherit = 'sale.order.line' unit_price_incl_discount = fields.Float(string='Preis/ME inkl. Rabatt', compute='_compute_unit_price_incl_discount') hide_discount = fields.Boolean(string='Rabatt verstecken') @api.multi def _compute_unit_price_incl_discount(self): for line in self: unit_price_incl_discount = line.price_unit * (1 - (line.discount or 0.0) / 100.0) line.unit_price_incl_discount = round(unit_price_incl_discount, 2) @api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id', 'hide_discount') def _compute_amount(self): super(SaleOrderLine, self)._compute_amount() for line in self: if line.hide_discount: line.update({ 'price_unit': line.unit_price_incl_discount })