Skip to Content
Menu
This question has been flagged
7 Replies
3386 Views

Hii,

On odoo sales order invoice report, how to get item delivery information like warehouse, location and batch in qweb xml for pdf report.

What is relation between invoice lines and stock move etc?


Avatar
Discard
Author

Here is, I have a method calling from Qweb. Passing dictionary object to QWeb.

def get_delivery_details(self, line_id, origin, product_id):

res = {}

stock_move = self.env['stock.move'].search([('origin', '=', origin), ('product_id', '=', product_id.id)])

for move in stock_move.filtered(lambda operation: operation.picking_type_id.name == 'Pick'):

for move_line in move.move_line_ids:

res['qty'] = move_line.qty_done

res['loc'] = move_line.location_id.name

return res

In Qweb I am calling above method

<t t-foreach="line.get_delivery_details(line.id, line.origin, line.product_id)" t-as="delivery">

<span t-esc="delivery.qty"/> -- Not Working

<span t-esc="delivery[0]"/> -- Not Working

</t>

How to get value in this loop....or some better idea?

Best Answer

Try to change like this

Please pass  line_id as object


def get_delivery_details(self, line_id, origin, product_id):

 delv =[]

stock_move = self.env['stock.move'].search([('sale_line_id', 'in', line_id.sale_line_ids.ids), ('product_id', '=', product_id.id),('state','=','done')])

 for move_line in stock_move.mapped('move_line_ids'):

warehouse_id = move_line.move_id.warehouse_id or move_line.move_id.picking_id.picking_type_id.warehouse_id

delv.append({

'location' : move_line.location_id.name,

'dest_location' : move_line.location_dest_id.name,

'parent' : move_line.location_id.location_id.name if move_line.location_id.location_id else move_line.location_id.name,

'qty' : move_line.qty_done,

'lot' : move_line.lot_id.name if move_line.lot_id else '',

'warehouse' : warehouse_id.id if warehouse_id else '',

'expiry' : move_line.lot_id.life_date if move_line.lot_id else ''


})

return delv

IN QWEB

<t t-set="delv_vals" t-value="line.get_delivery_details(line.id, line.origin, line.product_id)"/>

<t t-foreach="delv_vals" t-as="delivery">

<span t-esc="delivery['qty']/>

<span t-esc="delivery['warehouse']/>

<span t-esc="delivery['lot']/>

<span t-esc="delivery['location_id']/>

<span t-esc="delivery['parent']/>

<span t-esc="delivery['expiry']/>

</t>


Avatar
Discard
Author

Hii Vishnu Vanneri,

This is really good. Few more things, how to get

Parent Location

Warehouse Name

Lot (Batch or Serial) name

Lot Expiry Date

Thanks

Author

Hii Vishnu Vanneri,

From QWeb I am passing account_invoice_line object. Here line_id means invoice line id.

Here we dont he sale_line_id that you are using in

stock_move = self.env['stock.move'].search([('sale_line_id', '=', line_id), ('product_id', '=', product_id.id)('state','=','done')])

From where to get sale_line_id on account_invoice_line object??

Author

Hii Vishnu Vanneri, Thanks again.

Two things.

We have two step delivery in warehouse. Pick and Out.

From your query it is showing Out delivery (Dispatch Location)

I want to show the Pick location which is actual location.

and warehouse_id not found.

Thanks,

Please check updated answer.

Author Best Answer

I found this module the best and full filling all my requirements.

https://apps.odoo.com/apps/modules/12.0/stock_picking_invoice_link/

Avatar
Discard