when i try to create stock move line in transfer with automation with the following code, error pop up saying "psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block".
The code:
result=[]
result.append(
{'company_id':record.partner_id.id,
'date':record.date,
'location_dest_id':5,
'location_id':8 ,
'product_uom_qty':1,
'product_uom_id':32,
'product_id':465
})
env['stock.move.line'].create(result)
May I ask any idea what is the problem with my code or how can i programmtically create stock move line. Thanks
You set the
company_idto thepartner_idwhich may not be present inres.companytable and if it happens you should see the following error message:This will prevent Odoo from creating a stock move line, try to set the
company_idtoself.env.user.company_id.idNote that since v12 Odoo supports passing a list of values to create function