Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

tree view for one2Many not populating

Naroči se

Get notified when there's activity on this post

This question has been flagged
one2manyone2many_list
2 Odgovori
3833 Prikazi
Avatar
Elisha Wambiji

I have a tree view to show logs, but this logs come from a third party solution. I created a transient model to hold the logs. I compute the logs on the fly but the tree is not get populated with the data, nor is the database been updated. 


class VehicleLogs(models.TransientModel):
_name = 'vehicle.logs'
name = fields.Char()
timestamp = fields.Datetime()
speed = fields.Integer()
over_speed = fields.Boolean()
power_wire = fields.Boolean()
signal_wire = fields.Boolean()
vehicle_id = fields.Many2one('vehicle')

class Vehicles(models.Model):
_inherit = 'vehicle'
vehicle_log_ids = fields.One2many('vehicle.logs', 'vehicle_id', compute='_compute_vehicle_logs')

def format_data(self, data):
res = []
data = data[0][:1]
for _ in data:
vals = {'name': _['device_timestamp'], 'speed': int(_['speed']),
'over_speed': True if int(_['speed']) > 84 else False,
'power_wire': _['p_wire'],
'vehicle_id': self.id,
'signal_wire': _['s_wire']}
res.append((0, 0, vals))
return res

@api.multi
def _compute_vehicle_logs(self):
for vehicle in self:
traccar_id = vehicle.traccar_id
_from = (datetime.datetime.now() - datetime.timedelta(hours=1))
_to = datetime.datetime.now()
_from = (datetime.datetime.now() - datetime.timedelta(hours=6))

base_url = self.vendor_id.traccar_url
traccar_username = self.vendor_id.traccar_username
traccar_password = self.vendor_id.traccar_password

res = self.env['report.device_reports.device_report'].get_traccar_positions(base_url, traccar_username,
traccar_password, traccar_id,
_from,
_to)
values = self.format_data(res)
vehicle.vehicle_log_ids = values




<record model="ir.ui.view" id="view_vehicle_form_ext">
<field name="name">vehicle.form.ext</field>
<field name="model">vehicle</field>
<field name="inherit_id" ref="vehicles.view_vehicle_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Device Logs" autofocus="autofocus">
<field name="vehicle_log_ids">
<tree default_order="timestamp desc">
<field name="timestamp"/>
<field name="speed"/>
<field name="over_speed"/>
<field name="power_wire"/>
<field name="signal_wire"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>


0
Avatar
Opusti
Avatar
Elisha Wambiji
Avtor Best Answer

that is why am using it. I dont want to keep storing this data but just have a way of displaying when a user clicks on the record.



0
Avatar
Opusti
Avatar
Gleb
Best Answer

 class odoo.models.TransientModel
Model super-class for transient records, meant to be temporarily persistent, and regularly vacuum-cleaned.

If you want to use field you need to change class from class VehicleLogs(models.TransientModel) to class VehicleLogs(models.Model).

0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
how get value from one2many field? Solved
one2many one2many_list
Avatar
Avatar
1
avg. 19
11319
How to add records to one2many_list either by creating them, or selecting them ? Solved
one2many selection one2many_list
Avatar
Avatar
1
mar. 15
5402
Custom functionality with One2many field
one2many one2many_list v18 CommunityEdition
Avatar
Avatar
1
maj 25
1937
how pass value to on2many field from parent form via context
one2many
Avatar
Avatar
1
jan. 25
2741
How to make tree view place last entered field on the top of tree view? What is the difference between editable="top" and editable="bottom"?
one2many
Avatar
Avatar
Avatar
2
sep. 22
10445
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now