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
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
1278
Vistas
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
RegistrarsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
may 25
|
2384 | ||
|
1
abr 25
|
3418 | ||
|
1
abr 25
|
4224 | ||
|
1
abr 25
|
1730 | ||
|
4
mar 25
|
6822 |