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č

Export float_time widget data into time format?..

Naroči se

Get notified when there's activity on this post

This question has been flagged
exporttimefloat_time
3 Odgovori
35523 Prikazi
Avatar
Prakash

In openerp 7,  Start Time columns created using float_time widget.

in py file,

start_time: fields.float('Start Time')

in xml file,

<field name="start_time" widget="float_time"/>

Using "Export" options  Start Time output values generated it shows in float format.

Coversion float to float_time code:-

case 'float_time': var pattern = '%02d:%02d'; if (value < 0) { value = Math.abs(value); pattern = '-' + pattern; } var hour = Math.floor(value); var min = Math.round((value % 1) * 60); if (min == 60){ min = 0; hour = hour + 1; } return _.str.sprintf(pattern, hour, min);

In Export options export_data method how to override and apply the above float to float_time conversion formula for all widget="float_time" Field.?,,,,

 

0
Avatar
Opusti
Avatar
Prakash
Avtor Best Answer

In the model override export_data ORM method and float value convert into time.

Example

import math

def float_time_convert(float_val):
factor = float_val < 0 and -1 or 1
val = abs(float_val)
return (factor * int(math.floor(val)), int(round((val % 1) * 60)))

def export_data(self, cr, uid, ids, fields, context=None):
index = range(len(fields))
fields_name = dict(zip(fields,index))
res = super(class_name, self).export_data(cr, uid, ids, fields, context=context)
try:
for index, val in enumerate(res['datas']):
if fields_name.get('float_fieldname1'):
field1index = fields_name.get('float_fieldname1')
float_field1 = float(res['datas'][index][field1index])
hour, minute = self.float_time_convert(float_field1)
res['datas'][index][field1index] = '{0:02d}:{1:02d}'.format(hour, minute)
if fields_name.get('float_fieldname2'):
field2index = fields_name.get('float_fieldname2')
float_field2 = float(res['datas'][index][field2index])
hour, minute = self.float_time_convert(float_field2)
res['datas'][index][field2index] = '{0:02d}:{1:02d}'.format(hour, minute)
except Exception, e:
#print "Export Exception", e
pass
return res

1
Avatar
Opusti
Avatar
Lucas Huber
Best Answer

I did follow the method of Prakash but got an error first. Then I did realise that the float_time_convert call has to be an @api.multi and not an api.one:

File "/opt/odoo/custom/addons9/project_scrum/models/scrum_base.py", line 180, in onchange_duration_hrs
hour, minute = self.float_time_convert(self.duration)
ValueError: need more than 1 value to unpack


my correct code:

@api.multi
def float_time_convert(self, float_val):
    factor = float_val < 0 and -1 or 1 val = abs(float_val)
    return (factor * int(math.floor(val)), int(round((val % 1) * 60)))
...
hour, minute = self.float_time_convert(self.duration)

But then I get a problem with adding Datetime and timedelta

start_datetime = fields.Datetime()
....

end_time = self.start_datetime + datetime.timedelta(hours=hour, minute=minute)

Python does interpret start_datetime not as datetime!

0
Avatar
Opusti
Faris Fathurrahman

i have tried this and it worked. I used datetime.combine with initial date and time.min as the start_datetime

Avatar
Arsalan
Best Answer

I require the same thing.... did you get a way to handle such situation ??

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
Convert Hours and Minute into Float value Solved
time float_time V13
Avatar
Avatar
1
apr. 20
17212
How to subtract two 'float_time' field values?
time float float_time odoo10
Avatar
Avatar
4
jan. 20
7029
Exporting large amount of data
error export time long
Avatar
0
jul. 15
5016
exporteren
export
Avatar
Avatar
1
jul. 25
2498
How can I list/export more than 80 items? Solved
export
Avatar
Avatar
Avatar
3
feb. 25
16057
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