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:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
1321
أدوات العرض
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
3
أغسطس 25
|
2479 | ||
|
1
مايو 25
|
2584 | ||
|
1
أبريل 25
|
3548 | ||
|
1
أبريل 25
|
4396 | ||
|
1
أبريل 25
|
1855 |