We're developing modules for our company and since we use CAD currency I want to enable it in the system. How can I do that from a module?
EDIT:
I can believe this is taking so long to accomplish this little task!
I get the following error:
ParseError: "Invalid field 'name' in leaf "<osv.ExtendedLeaf: ('name', '=', 'CAD') on res_currency (ctx: )>"" while parsing file:///C:/Users/laflammm/Desktop/GitHub/addons_tc/canadian_data/data/res_currency.xml:4, near
<function model="res.currency" name="_enable_currencies"/>
I don't get it... when I check the fields of res.currency, I only see those:
{
'create_uid': <openerp.osv.fields.many2one object at 0x0000000009A8D138>,
'create_date': <openerp.osv.fields.datetime object at 0x0000000009A8C3C8>,
'id': <openerp.osv.fields.integer object at 0x0000000009A8C588>,
'write_date': <openerp.osv.fields.datetime object at 0x0000000009A8C4A8>,
'write_uid': <openerp.osv.fields.many2one object at 0x0000000009A8D228>
}
Where are the name, rounding, symbol, position and active fields?? In the fields from res.currency are from the base modules. What's going on??
I have the following files:
res_currency.py
from import openerp models
class Currency(models.Model):
_name = "res.currency"
def _enable_currencies(self, cr, uid, ids=Nonecontext=None, ):
cad_currency_ids = self.search(cr, uid, [('name', '=', 'CAD')])
if cad_currency_ids:
self.write(cr, uid, cad_currency_ids, {'active' : 'True'})
res_currency.xml
<openerp>
<data>
<function model="res.currency" name="_enable_currencies"/>
</data>
</openerp>
__openerp__.py
{
'name' :"Canadian data" ,
'description':"Create the canadian provinces and territories plus activate CAD currency." ,
'author' :"Transcontinental" ,
'category' :'' ,
'version' :'1.1' ,
'depends' : [],
'data' : [
'res_currency.xml',
],
'auto_install': False,
'installable': True,
}
__init__.py
import res_currency
See my updated answer.
Your module should depends on base module.