Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

tree view for one2Many not populating

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
one2manyone2many_list
2 Răspunsuri
3997 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Elisha Wambiji
Autor Cel mai bun răspuns

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
Imagine profil
Abandonează
Imagine profil
Gleb
Cel mai bun răspuns

 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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
how get value from one2many field? Rezolvat
one2many one2many_list
Imagine profil
Imagine profil
1
aug. 19
11489
How to add records to one2many_list either by creating them, or selecting them ? Rezolvat
one2many selection one2many_list
Imagine profil
Imagine profil
1
mar. 15
5540
Custom functionality with One2many field
one2many one2many_list v18 CommunityEdition
Imagine profil
Imagine profil
1
mai 25
2197
how pass value to on2many field from parent form via context
one2many
Imagine profil
Imagine profil
1
ian. 25
2906
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
Imagine profil
Imagine profil
Imagine profil
2
sept. 22
10595
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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