İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

How to avoid unicode transformation of my data passed to a report parser?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
dateqwebformatunicode
2 Cevaplar
6809 Görünümler
Avatar
Pascal Tremblay

Hello all,


I send many date fields to a report with this line in my wizard class :

data['form'] = self.read(cr, uid, ids, ['journal_id', 'date_to', 'date_from','date_deposit'], context=context)[0]


In the log, I see that for this data variable. The dates seem to be in a date format/type :

{'form': {'date_deposit': '2016-02-17', 'date_from': '2016-02-01 00:00:00', 'date_to': '2016-02-15 00:00:00', 'id': 39, 'journal_id': (18, u"Journal Caisse Populaire Desjardins d'Alma - CF (CAD)")}}


When these datas arrive in the report paser, in my render_html method, they are like this. I would say that all data is now in a unicode format :

data : {u'form': {u'journal_id': [18, u"Journal Caisse Populaire Desjardins d'Alma - CF (CAD)"], u'date_from': u'2016-02-01 00:00:00', u'date_to': u'2016-02-15 00:00:00', u'id': 39, u'date_deposit': u'2016-02-17'}}


So, in my qweb report, I can not format my date with my usual line :

 <p t-esc="data.get('date_from')" t-field-options='{"format": "d MMMM y"}'/>


I rather have to format my dates with :

<p t-esc="time.strftime('%d %B %Y',time.strptime(data.get('date_from'),'%Y-%m-%d %H:%M:%S'))"/>


My question :

How could I avoid this unicode transformation of my data variable? My date are not in a date type anymore...



UPDATE #1

I have verified data inthe get_action method. Datas are still ok. No trace of unicode.

    @api.v7
    def get_action(self, cr, uid, ids, report_name, data=None, context=None):
        _logger.error("datawwwww :: %s", str(data))



UPDATE #2

According to the tip of Axel Mendoza, I have tried to convert unicode dates to date format. But, it is still not enough to get the right format in my qweb report with

 <p t-esc="data.get('date_from')" t-field-options='{"format": "d MMMM y"}'/>

I still get this in my qweb pdf :

2016-02-01

I have tried this code in me render_html method :

def render_html(self, data=None):
        date_from_buf = datetime.strptime(data['form'].get('date_from'), "%Y-%m-%d %H:%M:%S")
        date_from = date.strftime(date_from_buf, "%Y-%m-%d" )



Here is the log of my docargs. the date_from seems to be right there:

docargs : {'docs': wizard.create.deposit(53,), 'doc_model': u'wizard.create.deposit', 'date_from': '2016-02-01', 'lines': <bound method report.sale_lapagept.report_qweb_create_deposit_cf.lines of report.sale_lapagept.report_qweb_create_deposit_cf()>, 'date_to': datetime.datetime(2016, 2, 15, 20, 32, 58), 'doc_ids': [], 'data': {u'journal_id': [18, u"Journal Caisse Populaire Desjardins d'Alma - CF (CAD)"], u'date_from': u'2016-02-01 20:32:55', u'date_to': u'2016-02-15 20:32:58', u'id': 53, u'date_deposit': u'2016-02-19'}}


UPDATE #3

With this code :

@api.multi

def render_html(self, data=None): 

     date_from = datetime.strptime(data['form'].get('date_from'), "%Y-%m-%d %H:%M:%S")



I get this log :

docargs : {'docs': wizard.create.deposit(54,), 'doc_model': u'wizard.create.deposit', 'date_from': datetime.datetime(2016, 2, 1, 20, 32, 55), 'lines': <bound method report.sale_lapagept.report_qweb_create_deposit_cf.lines of report.sale_lapagept.report_qweb_create_deposit_cf()>, 'date_to': datetime.datetime(2016, 2, 15, 20, 32, 58), 'doc_ids': [], 'data': {u'journal_id': [18, u"Journal Caisse Populaire Desjardins d'Alma - CF (CAD)"], u'date_from': u'2016-02-01 20:32:55', u'date_to': u'2016-02-15 20:32:58', u'id': 54, u'date_deposit': u'2016-02-19'}}



In the qweb template, I have this code :

    <p t-esc="data.get('date_from')" />

    <p t-esc="o.date_from" t-field-options='{"format": "d MMMM y"}'/>

    <p t-esc="date_from" t-field-options='{"format": "d MMMM y"}'/>

    <p t-esc="data.get('date_from')" t-field-options='{"format": "d MMMM y"}'/>

    <p t-esc="time.strftime('%d %B %Y',time.strptime(data.get('date_from'),'%Y-%m-%d %H:%M:%S'))"/>


And I still get the wrong result with {"format": "d MMMM y"}

2016-02-01 20:32:55

2016-02-01 20:32:55

2016-02-01 20:32:55

2016-02-01 20:32:55

01 février 2016


I will become crazy!


0
Avatar
Vazgeç
Axel Mendoza

So then my other answer works nice!!

Avatar
Axel Mendoza
En İyi Yanıt

In the get_action method the data are not serialized yet, so it's not converted to unicode. The values that you pass using the data are values unrelated to any kind of python data type, normally those values are serialize those values in strings, int and float numbers to be sent it to the browser to be processed by the view action manager to determine what need to be done with the action dict and call the server controller action for the respective type of action, that's when the strings are converted to unicode. So if you wanna the value of the date_from as a datetime value type, you should convert it in the render_html method of your parser before pass it to the render of the report template and the same with all the values that you need to convert it before the report is rendered.

#Update 1

The thing is that the format pattern in t-field-options in qweb is not evaluated using datetime.strftime, it's using babel.dates.format_date function so you need to check on that library method for allowed patterns

or

you could format it by yourself using datetime.strftime before put it on the docargs data

1
Avatar
Vazgeç
Pascal Tremblay
Üretici

I have tried to convert unicode to date format... see UPDATE #2.

Axel Mendoza

You are just doing an extra last step trying to convert the datetime value to string again, just put as a datetime value for the docargs data, t-field-options format operates over datetime values not over strings.

Pascal Tremblay
Üretici

May be docargs are still transformed in string by the render() method called at the end of my render_html() method. I will check this tomorrow

Axel Mendoza

see my ·Update 1

Pascal Tremblay
Üretici

thanks for your patience.

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

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
how can we change date view format from dd/mm/yyyy to mm/dd/yyyy Çözüldü
date format
Avatar
Avatar
Avatar
Avatar
4
Eki 25
80791
QWeb report : calculate number of days late for task deadlines
date qweb
Avatar
Avatar
Avatar
2
Eki 21
8574
How to format data['form']['date_start'] to get the month name in letters? Çözüldü
date qweb format month letters
Avatar
1
Tem 21
10838
Formatting dates in Qweb report: account.report_overdue_document Çözüldü
date qweb format report datetime
Avatar
Avatar
Avatar
Avatar
Avatar
7
Ara 23
23575
How could I format the printing date of a qweb report in the customer language?
language date qweb format today
Avatar
0
Ağu 16
6618
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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