Saturday, April 16, 2022

TypeError: Object of type datetime is not JSON serializable

 

This error "TypeError: Object of type datetime is not JSON serializable" happens when we try to convert data with date time into json dictionary , so to fix this error we have to convert the data to string first then put it in the dictionary and then we can convert the dictionary to json format
...
for example if we want to create api with odoo to return the data for sale order , so we can put the sale order data as bellow 

order_data = {
            'id':order_id.id,
            'name':order_id.name,
            'customer':{'id':order_id.partner_id.id,'name':order_id.partner_id.name},
            'salesperson':{'id':order_id.user_id.id,'name':order_id.user_id.name},
            'date_order':str(order_id.date_order),
            'state':order_id.state,
            'products':order_products,
            'untaxed_amount':order_id.amount_untaxed,
            'total_tax': order_id.amount_tax,
            'total_amount':order_id.amount_total,
     }

return Response(json.dumps(order_data),headers=headers)

ssh

In this blog we will explain some commands to deal with remote server from ubuntu terminal using SSH

1: Connect to remote server using ssh by the command bellow 

     sudo ssh remote_user_name@remote_ip

 

2: Connect to remote server with key.pem using ssh by the command bellow

    sudo ssh remote_user_name@remote_ip -i /path/key.pem

 

3/ copy folder with it's content from the remote server to local device

    sudo scp -r remote_user@remote_server_ip:/opt/example /home/local_folder

    sudo scp -i /path/key.pem -r remote_user@remote_server_ip:/opt/example /home/local_folder

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...