I have two models weather_location.weather_location and current_weather.current_weather. In weather_location.weather_location there is One2many field and current_weather.current_weather there is Many2one field. Now, I want to show the fields in kanban view of weather_location.weather_location which are declared in current_weather.current_weather..
Here, Attach the code which i tried:
class location(models.Model):
_name = 'location.location'
name = fields.Char(string="City Name")
location_ids = fields.One2many('weather.weather',
'weather_id', string="Weather Details")
api_address = "http://api.openweathermap.org/data/2.5/weather?appid=6784429f5eff661309aaa5280a143f97&q="
def get_weather_data(self):
url = self.api_address + self.name
json_data = requests.get(url).json()
formatted_data = json_data['weather'][0]['main']
formatted_data1 = json_data['main']['temp']
formatted_data2 = json_data['main']['temp_min']
formatted_data3 = json_data['main']['temp_max']
formatted_data4 = json_data['main']['humidity']
self.env['weather.weather'].create(
{'weather_id':self.id,
'main':formatted_data,
'temp':formatted_data1,
'temp_min':formatted_data2,
'temp_max':formatted_data3,
'humidity':formatted_data4,
})
class current_weather(models.Model):
_name = 'weather.weather'
weather_id = fields.Many2one('location.location',
string="Weather",)
color = fields.Integer()
main = fields.Char(string="Main")
temp = fields.Float(string="Temperature")
temp_min = fields.Float(string="Minimum Temperature")
temp_max = fields.Float(string="Maximum Temperature")
humidity = fields.Float(string="Humidity")
.xml file(kanban view):
<record model="ir.ui.view" id="current_location_Kanban">
<field name="name">current_weather kanban</field>
<field name="model">location.location</field>
<field name="type">kanban</field>
<field name="arch" type="xml">
<kanban default_group_by="name">
<field name="name"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_content">
Main:
<!-- <field name="main"/> -->
<br/>
Temperature:
<!-- <field name="temp"/> -->
<br/>
Minimum Temperature:
<!-- <field name="temp_min"/> -->
<br/>
Maximum Temperature
<!-- <field name="temp_max"/> -->
<br/>
Humidity:
<!-- <field name="humidity"/> -->
</div>
</t>
</templates>
</kanban>
</field>
</record>
By using this only labels are shown not their values. How to access their values