Skip to content

Instantly share code, notes, and snippets.

@aek
Created July 10, 2015 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aek/2a6966c05b01083364cf to your computer and use it in GitHub Desktop.
Save aek/2a6966c05b01083364cf to your computer and use it in GitHub Desktop.
from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
class product_dim_price(osv.osv):
_inherit = "product.product"
def _get_dim_price(self, cr, uid, ids, field_name=None, arg=False, context=None):
res = {}
for prod in self.browse(cr, uid, ids, context=context):
res[prod.id] = prod.length * prod.width
return res
_columns = {
'dim_price': function(_get_dim_price, digits_compute=dp.get_precision('Product Unit of Measure'),
type='float', string='Dimension Price'),
}
product_dim_price()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment