Another way is to use scripts, which will add the prices to the correct pricelist (and ignoring all prices on the product). This way, you can specify the period the price(s) is/are valid, so you can keep track of the history.
Script
To use the script, I have installed openerp-client-lib
I use a CSV-file, which has at least the productcode (unique), and the new price
import openerplib
import datetime
################################################################################
## default values
################################################################################
# To store data
h = "192.168.1.1"
db= "database_name"
u = "admin"
p = "adminpw"
line = '-' *45 + '\n'
file_prijslijst = 'pricelist.csv'
f_error = 'importError.csv'
f_result = 'importResult.txt'
namePartner = 'name of the partner/pricelist'
################################################################################
## VARIOUS ROUTINES
################################################################################
def printHeading():
f_res.write(line)
dateX = str(datetime.datetime.now())
f_res.write('-' * 10 + dateX+'\n')
def initConnection(h, db, u, p):
printHeading()
f_res.write('Connecting to %s \nuser: %s\ndatabase: %s\n' %(h, u, db))
return openerplib.get_connection(
hostname=h, database=db, login=u, password=p)
def addValsToDB(c, m, vals):
printHeading()
f_res.write('Adding data to %s\n' %(m))
print 'Adding data to', m
model = c.get_model(m)
result = []
i = 0
for v in vals:
result.append(model.create(v))
i += 1
x, y = divmod(i, 100)
if y == 0:
f_res.write('Added already %d records to %s\n' %(x*100, m))
print 'Added already %d records to %s' %(x*100, m)
f_res.write('Number of records added: %d\n' %(len(result)))
print 'Number of records added: %d' %(len(result))
return result
################################################################################
## Start of the script
################################################################################
f_res = open(f_result,'w')
f_fout = open(f_error, 'w')
connection = initConnection(h, db, u, p)
f_fout.write('Code;Omschrijving\n')
################################################################################
## PRODUCT.PRICELIST
## PRODUCT.PRICELIST.VERSION
## PRODUCT.PRICELIST.ITEM
################################################################################
f_lijst = open(file_prijslijst)
heading = f_lijst.readline()
# pricelist for namePartner
m = "product.pricelist"
print 'Creating', m, namePartner
vals = []
vals.append({
'name': namePartner,
'company_id': 1,
'version_id': [],
'currency_id': 1, #this is EURO
'commrate': 0,
'active': True,
'type': 'sale'
})
myPriceList = addValsToDB(connection, m, vals)
myPriceList = myPriceList[0] #to get the ID, instead of [id]
# Pricelist Version
m = "product.pricelist.version"
vals = []
vals.append({
'items_id': [],
'name': namePartner + ' - version',
'date_end': '2013-12-31',
'date_start': '2013-01-01',
'active': True,
'pricelist_id': myPriceList,
})
res = addValsToDB(connection, m, vals)
# Pricelist item
m = "product.pricelist.item"
prod_obj = connection.get_model('product.product')
vals = []
for l in f_lijst:
res = l.replace('\n','').split(';')
#zoek productID, adhv code
prodID = prod_obj.search([('default_code', '=', res[1])])
if prodID == []:
# print 'ERROR, niet te vinden:', l
f_fout.write('ERROR;product %s-%s, %s niet te vinden\n' %(res[1], res[2],res[4]))
continue
vals.append({
'price_round': 0.0,
'price_discount': -1.0,
'base_pricelist_id': 1,
'sequence': 25,
'price_max_margin': 0.0,
'product_tmpl_id': False,
'product_id': prodID[0], #Product to use
'base': 1,
'price_version_id': myPriceList,
'min_quantity': 0,
'price_surcharge': float(res[8]), # 0.0, #From the file
'price_min_margin': 0.0,
'categ_id': False,
'name': '%s-%s, %s' %(res[1], res[2], res[4]),
})
# add a reference to DEFAULT pricelist, so articles which are not defined are used from DEFAULT
vals.append({
'price_round': 0.0,
'price_discount': 0.0,
'base_pricelist_id': 1, #DEFAULT
'sequence': 50,
'price_max_margin': 0.0,
'product_tmpl_id': False,
'base': -1,
'price_version_id': myPriceList,
'min_quantity': 0,
'price_surcharge': 0,
'price_min_margin': 0.0,
'categ_id': False,
'name': 'Alle andere producten',
})
res = addValsToDB(connection, m, vals)
f_lijst.close()
################################################################################
## END OF THE SCRIPT
################################################################################
f_res.write(line)
printHeading()
f_res.close()
f_fout.close()
print line
print 'Einde'
# vim:expandtab:smartindent:tabstop=2:softtabstop=2:shiftwidth=2: