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:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
911
Views
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Nov 24
|
2953 | ||
|
5
Nov 24
|
7476 | ||
|
2
Oct 24
|
2888 | ||
|
4
Oct 24
|
1869 | ||
|
2
Oct 24
|
4027 |