Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2942 Tampilan

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



Avatar
Buang

Hi,
Have you added security to the newly created models? If not, then please add that.

Penulis

thanks @Cybrosys Techno
models are not created, already mentioned, if once it will created i can add in security.

Penulis

hi, problem resolved, there was a typo in my __init__.py file.
regards

Jawaban Terbai

Also what is it showing in the error logs?
It might be a import mistake. Check if the single.py is added to the the __init__.py correctly. 

Thanks & Regards, 

 

Brain Station 23 Ltd. 

Mobile: (+880) 1404055226 

Email: sales@brainstation-23.com 

Web: https://brainstation-23.com/ 

Address: (Building-1) 8th Floor, 2 Bir Uttam AK Khandakar Road, Mohakhali C/A, Dhaka 1212, Bangladesh 

Avatar
Buang
Penulis

thank you @Brain, i already have mentioned in my previous comment that there was a typo in my __init__.py file.
regards

Post Terkait Replies Tampilan Aktivitas
1
Apr 24
1195
2
Jan 24
1086
3
Jul 23
1673
1
Jun 23
1462
1
Mei 25
1240