İç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 write for loop in inline_template Odoo15?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
templatemailtemplatejinja2v15inlinetemplate
2 Cevaplar
12795 Görünümler
Avatar
Tri Nanda

When Odoo still using jinja2 template, we can make for loop like example the code bellow:


% for i in range(len(object.invoice_line_ids)):
${i+1}${'.'.ljust(2)}
% endfor


But in Odoo15, the code doesn't work again,

I try to read this document and trying to apply the for loop like qweb code:

https://www.odoo.com/documentation/15.0/developer/reference/frontend/qweb.html#loops


Like the example bellow:

isn't it will be working on CDATA?


When I try to check the result, it showing the code directly, not the loopin result:


I also try to create for loop like the bellow ways:

{% for item in range(10) }}
{ item }
{% endfor }}

% for item in range(10):
${item}
% endfor

{% for item in range(10):}
${item}
{% endfor }

{% for item in range(10)}:
${item}
{% endfor }

{% item for item in range(10) %}

{% for item in range(10) %}
    {{ item }}
{% endfor %}

{% for item in range(10) %}
    {{{ item }}}
{% endfor %}

{{item for item in range(10)}}

{{% item for item in range(10) %}}

{% item for item in range(10) %}

But nothing is working in Odoo15 using the code above.


This is the worked code on Odoo13:
https://paste.opensuse.org/29906326


And I try to upgrade it to Odoo15 with few adjusemtn like bellow snippet of code:
https://paste.opensuse.org/75175196

But still don't work correctly.


My goals on this is, how to print customer invoice to dotmatrix printer, so I using CDATA.


So how to write for loop in inline_template Odoo15?,or is there any source, tutorial, documentations to learn about that things?


Thanks,

Tri Nanda

1
Avatar
Vazgeç
Joseph A. Flerimé

Hello Tri Nanda, did you find the solution to this problem? I have the same issue.

Joseph A. Flerimé

Interesting. Can you share the method, please?
Another question. My document doesn't show the actual format. It shows up as a string with this at the beginning {1: Markup(' Invoice INV/2022/00001\n .... how can I fix it?

Avatar
Tri Nanda
Üretici En İyi Yanıt

I have solved this, instead of doing loop in mail template, I do it in python directly instead, then render it to template.

Here is the example code:

invoice.py

class invoice(models.Model):
_name = 'account.move'
_inherit = 'account.move'

printer_data = fields.Char("Printer Data", readonly=True)

def action_refresh_printer_data(self):
company_name = self.env.company.name.rjust(45) if self.env.company.name else "My Company".rjust(45)
address = self.env.company.street.rjust(65) if self.env.company.street else "Address".rjust(65)
phone = self.env.company.phone if self.env.company.phone else "Phone"
mobile = self.env.company.mobile if self.env.company.mobile else "Mobile"
contact = str('Telp. ' + phone + 'Hp. ' + mobile).rjust(64)
invoice_name = 'INVOICE'.rjust(33) + ' ' + self.name if self.name else ''
stripe_space = ''.rjust(80, '-')
invoice_bill = 'Tagihan Faktur'.rjust(0) + ':'.rjust(4) + self.partner_id.display_name.ljust(
30) if self.partner_id else ''.ljust(30)
date = 'Tanggal'.rjust(13) + ':'.rjust(1) + str(self.invoice_date) if self.invoice_date else ''.ljust(30)
invoice_address = 'Alamat Pengiriman'.rjust(0) + ':'.ljust(0) + self.partner_id.display_name.ljust(
30) if self.partner_id else ''.ljust(30)
cashier = 'Kasir'.rjust(11) + ':'.rjust(3) + self.user_id.name if self.user_id else ''.ljust(20)
street = ''.rjust(19) + self.partner_id.street[:30].ljust(31) if self.partner_id.street else ''.ljust(31)
street2 = ''.rjust(19) + self.partner_id.street2[:30].ljust(31) if self.partner_id.street2 else ''.ljust(31)
mobile = ''.rjust(19) + self.partner_id.mobile[:13].ljust(31) if self.partner_id.mobile else ''.ljust(31)
number = 'No'.ljust(3)
product_name = 'Nama Barang'.ljust(40)

qty = 'Qty'.ljust(0)
price = 'Harga'.rjust(13)
subtotal = 'Subtotal'.rjust(16)

sign = 'Tanda Terima'.rjust(10) + ''.ljust(6) + 'Sopir'.rjust(10) + ''.ljust(8) + 'Hormat Kami'.rjust(10)
total = 'Total:'.rjust(13) + "{:4,.0f}".format(self.total_before_discount).rjust(15)
discount = 'Diskon:'.rjust(60) + "{:4,.0f}".format(self.ks_amount_discount).rjust(
15) if self.ks_amount_discount else 'Diskon:'.rjust(60) + '-'.rjust(11)
amount_residual = ''.rjust(12, '-') + ''.ljust(7) + ''.rjust(12, '-') + ''.rjust(4) + ''.rjust(13,
'-') + 'Sisa:'.rjust(
12) + "{:4,.0f}".format(self.amount_residual).rjust(15)

paid = 'Bayar:'.rjust(60) + "{:4,.0f}".format(json.loads(self.invoice_payments_widget)['content'][0]['amount'] \
if self.invoice_payments_widget != 'false' else 0).rjust(
15) if self.invoice_payments_widget != False else '{}'

data_list = []

for i in range(len(self.invoice_line_ids)):
data_list.append([str(i + 1) + '.'.ljust(2),
self.invoice_line_ids[i].name[:34].ljust(34) if self.invoice_line_ids[
i].name else ''.ljust(34),
str(int(self.invoice_line_ids[i].quantity)).rjust(9) if self.invoice_line_ids[
i].quantity else ''.ljust(9),
"{:4,.0f}".format(self.invoice_line_ids[i].price_unit).rjust(13) if self.invoice_line_ids[
i].price_unit else ''.ljust(13),
"{:4,.0f}".format(self.invoice_line_ids[i].price_subtotal).rjust(16) if
self.invoice_line_ids[i].price_subtotal else ''.ljust(16)])

data = company_name + '\n' + address + '\n' + contact + '\n' + stripe_space + '\n' + invoice_name + '\n' + \
stripe_space + '\n' + invoice_bill + date + '\n' + invoice_address + cashier + '\n' + street + '\n' + \
street2 + '\n' + mobile + '\n' + stripe_space + '\n' + number + product_name + qty + price + subtotal + '\n' + \
stripe_space + '\n'
for count, value in enumerate(data_list):
data2 = ''.join(value)
data = data + data2 + '\n'
data = data + '\n' + stripe_space + '\n' + sign + total + '\n' + discount + '\n' + paid + '\n' + amount_residual

self.printer_data = data

templates.xml

invoice.xml



I also try to sell it on odoo apps:

https://apps.odoo.com/apps/modules/15.0/dotmatrix/


Feel free to contact me if anyone need help.

Thanks,

Tri Nanda

1
Avatar
Vazgeç
Avatar
Joseph A. Flerimé
En İyi Yanıt

I found this link Core changes between v14 -> v15 | Odoo

I don't think the inline_template has support for loops. They use Qweb for the email body.

1
Avatar
Vazgeç
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
Template does not exist Çözüldü
template v15 OWL
Avatar
Avatar
Avatar
Avatar
Avatar
4
May 25
14107
AttributeError: module 'odoo.addons.web.controllers.main' has no attribute 'jinja2' Çözüldü
jinja2 v15 AttributeError odoo.addons.web.controllers.main
Avatar
Avatar
Avatar
2
Ara 24
8697
ODOO 15 EE : export in xslx any reporting Çözüldü
report template v15 xslx
Avatar
Avatar
1
Şub 23
4623
ODOO 15 EE : Use docx template for all the accounting reports
docx report template v15
Avatar
0
Şub 23
2883
How to update text in template with a variable Odoo 15
template js odoosh v15
Avatar
0
Tem 22
3268
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