You really need to try and follow coding guidelines, it makes it easier to follow. And it is hard to geuss what the issue is when things are written unusually. Below is a slightly more sane edit, although no gaurentees it works. Just to give you an idea.
Code:
from osv import osv, fields
class product_template(osv.osv):
_inherit = 'product.template'
def _get_currency(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) #why pass a list to get a list then take the first element, just pass the id.
if user.company_id: #Isn't company_id mandatory? therefore it should always be true? anyway in multicompany this will fail if user is assigned to one company by default and using another.
return user.company_id.currency_id.id
return self.pool.get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0]#this will fail in multicompany.
You could write the previous 3 lines just as clearly as
return user.company_id and user.company_id.currency_id.id or self.pool.get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0]
although probably unnecessary, esp. if company_id is mandatory on user.
_columns = {
'currency_id': fields.many2one('res.currency', string='Currency'),
}
_defaults = {
'currency_id': _get_currency,
}
product_template()
Anyway on to the issue of readonly. If after cleaning your code up a bit, if it is still not fixed, it might pay to just walk back through it. If you remove the defaults does it work? etc etc. I think also this module will always be buggy as res.currency is defined for each and every company, yet a product is defined for none or 1 companies and security rules allow sharing by default. But then you want it to be the same in each company. This is not a problem of your making btw, it is because of the way OpenERP handles currency. You might need to change security rules on res.currency to have a chance in multicompany, but in single company it should work fine.
Also it makes more sense to define at the template level, rather than product level, as costs and prices are currently defined there.