i am trying to create a models in a single .py file, after saved file, restart server and trying to upgrade app, it is showing error as i have used Many2one fields to have below info (country,state & city) in another model, (that model was present and now i am going to add fields country_id, state_id, city_id as Many2one using below models), when go to check Models through Settings -> Technical it is not showing any of these models in below .py file. what i am doing wrong or missing something? please help.
from odoo import models, fields, api
class Countries(models.Model):
_name = 'hp.countries'
_description = "Countries"
name = fields.Text(string="Country Name", required=True)
slug = fields.Char(string="Slug")
country_ids = fields.One2many('hp.states', 'country_id')
class States(models.Model):
_name = 'hp.states'
_description = "States"
name = fields.Text(string="State Name", required=True)
country_id = fields.Many2one('hp.countries', "Country", required=True)
state_ids = fields.One2many('hp.cities', 'state_id')
class Cities(models.Model):
_name = 'hp.cities'
_description = "Cities"
name = fields.Text(string="City Name", required=True)
country_id = fields.Many2one('hp.countries', "Country", required=True)
state_id = fields.Many2one('hp.states', "State", required=True, domain="[('country_id', '=', country_id)]")
regards
Hi,
Have you added security to the newly created models? If not, then please add that.
thanks @Cybrosys Techno
models are not created, already mentioned, if once it will created i can add in security.
hi, problem resolved, there was a typo in my __init__.py file.
regards