Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

tree view for one2Many not populating

Odoberať

Get notified when there's activity on this post

This question has been flagged
one2manyone2many_list
2 Replies
3812 Zobrazenia
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
Zrušiť
Avatar
Elisha Wambiji
Autor 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
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
how get value from one2many field? Solved
one2many one2many_list
Avatar
Avatar
1
aug 19
11287
How to add records to one2many_list either by creating them, or selecting them ? Solved
one2many selection one2many_list
Avatar
Avatar
1
mar 15
5381
Custom functionality with One2many field
one2many one2many_list v18 CommunityEdition
Avatar
Avatar
1
máj 25
1859
how pass value to on2many field from parent form via context
one2many
Avatar
Avatar
1
jan 25
2680
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
10414
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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