purchase.py 713 B

123456789101112131415161718
  1. from openerp.osv import fields, osv
  2. import openerp.addons.decimal_precision as dp
  3. class purchase_order_line(osv.osv):
  4. _inherit = 'purchase.order.line'
  5. def _get_orig_price_unit(self, cr, uid, ids, field_name, arg, context=None):
  6. res={}
  7. purchase_lines = self.browse(cr, uid, ids, context=context)
  8. for line in purchase_lines:
  9. if not line.discount:
  10. res[line.id] = line.price_unit
  11. return res
  12. _columns = {
  13. 'orig_price_unit': fields.function(_get_orig_price_unit, string='Orig. Precio Unit.', type='float',digits_compute= dp.get_precision('Product Price'), store=True),
  14. 'discount': fields.char('Descuento', readonly=True),
  15. }