style="display:block;"
t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s'%('QR', doc.get_qr_code(), 120, 120)"/>
@api.model
def get_qr_code(self):
def get_qr_encoding(tag, field):
company_name_byte_array = field.encode('UTF-8')
company_name_tag_encoding = tag.to_bytes(length=1, byteorder='big')
company_name_length_encoding = len(company_name_byte_array).to_bytes(length=1, byteorder='big')
return company_name_tag_encoding + company_name_length_encoding + company_name_byte_array
for record in self:
qr_code_str = ''
seller_name_enc = get_qr_encoding(1, record.company_id.display_name)
company_vat_enc = get_qr_encoding(2, record\.company_id\.vat\ or\ ''\)
\ \ \ \ \ \ \ \ \ \ \ \ \#\ date_order\ =\ fields\.Datetime\.from_string\(record\.create_date\)
\ \ \ \ \ \ \ \ \ \ \ \ if\ record\.invoice_date_supply:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ time_sa\ =\ fields\.Datetime\.context_timestamp\(self\.with_context\(tz='Asia/Riyadh'\),\ record\.invoice_date_supply\)
\ \ \ \ \ \ \ \ \ \ \ \ else:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ time_sa\ =\ fields\.Datetime\.context_timestamp\(self\.with_context\(tz='Asia/Riyadh'\),\ record\.create_date\)
\ \ \ \ \ \ \ \ \ \ \ \ timestamp_enc\ =\ get_qr_encoding\(3,\ time_sa\.isoformat\(\)\)
\ \ \ \ \ \ \ \ \ \ \ \ invoice_total_enc\ =\ get_qr_encoding\(4,\ str\(record\.amount_total\)\)
\ \ \ \ \ \ \ \ \ \ \ \ total_vat_enc\ =\ get_qr_encoding\(5,\ str\(record.currency_id.round(record.amount_total - record.amount_untaxed)))
str_to_encode = seller_name_enc + company_vat_enc + timestamp_enc + invoice_total_enc + total_vat_enc
qr_code_str = base64.b64encode(str_to_encode).decode('UTF-8')
return qr_code_str
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
- Project
- MRP
Bu soru işaretlendi
1297
Görünümler
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 | |
---|---|---|---|---|
|
1
May 25
|
2458 | ||
|
1
Nis 25
|
3475 | ||
|
1
Nis 25
|
4304 | ||
|
1
Nis 25
|
1781 | ||
|
4
Mar 25
|
6892 |