I'm trying to create a module that will do some stuff on install. As I understand it, I need to create a model with an init method and place my code there. This is what I have so far;
class geo_subdivision(models.Model):
_name = 'geo_subdivision.geo_subdivision'
def init(self,cr):
res_country = self.env['res.country']
I'm getting;
AttributeError: 'geo_subdivision.geo_subdivision' object has no attribute 'env'
Google has turned up a lot of conflicting information and trying everything suggested elsewhere has gotten me nowhere.
If my appraoch correct? Is this even the correct method to use for my purpose?
I should mention; I'm on Odoo 9.
@Bharat;
Tried your suggestion.
I get;
ImportError: cannot import name models
Changing back to my original import;
from openerp import models, fields, api
I get;
AttributeError: 'module' object has no attribute 'model_cr'
i updated my answer that's same as yours and it is works for me well.
Using exactly what you have below gives me;
AttributeError: 'geo_subdivision.geo_subdivision' object has no attribute 'env'
Basically, back to what I started with.
I did finally figure this out and the answer was as Yousif has posted. Unfortunately the site won't allow me to post answers, so I could post my findings.