old_contents: # -*- coding: utf-8 -*-
  # © 2004-2009 Tiny SPRL (<http://tiny.be>).
  # © 2015 Pedro M. Baeza
  # © 2016 ACSONE SA/NV (<http://acsone.eu>)
  # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  from openerp import api, fields, models
  import openerp.addons.decimal_precision as dp
  
  
  class PurchaseOrderLine(models.Model):
      _inherit = "purchase.order.line"
  
      @api.depends('discount')
      def _compute_amount(self):
          prices = {}
          for line in self:
              if line.discount:
                  prices[line.id] = line.price_unit
                  line.price_unit *= (1 - line.discount / 100.0)
          super(PurchaseOrderLine, self)._compute_amount()
          # restore prices
          for line in self:
              if self.discount:
                  line.price_unit = prices[line.id]
  
      discount = fields.Float(
          string='Discount (%)', digits_compute=dp.get_precision('Discount'))
  
      _sql_constraints = [
          ('discount_limit', 'CHECK (discount <= 100.0)',
           'Discount must be lower than 100%.'),
      ]
  
new_contents: # -*- coding: utf-8 -*-
  # © 2004-2009 Tiny SPRL (<http://tiny.be>).
  # © 2015 Pedro M. Baeza
  # © 2016 ACSONE SA/NV (<http://acsone.eu>)
  # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  from openerp import api, fields, models
  import openerp.addons.decimal_precision as dp
  
  
  class PurchaseOrderLine(models.Model):
      _inherit = "purchase.order.line"
  
      @api.depends('discount')
      def _compute_amount(self):
          prices = {}
          for line in self:
              if line.discount:
                  prices[line.id] = line.price_unit
                  line.price_unit *= (1 - line.discount / 100.0)
          super(PurchaseOrderLine, self)._compute_amount()
          # restore prices
          for line in self:
              if line.discount:
                  line.price_unit = prices[line.id]
  
      discount = fields.Float(
          string='Discount (%)', digits_compute=dp.get_precision('Discount'))
  
      _sql_constraints = [
          ('discount_limit', 'CHECK (discount <= 100.0)',
           'Discount must be lower than 100%.'),
      ]
  
subject: Fix issue with multiple lines