Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to reference a delivery order line to sales order line?

By
Damian Phang
on 2/7/14, 4:11 AM 1,664 views

When we create a sales order, a delivery order is created automatically which reference to the sales order line. However, when we create a delivery order, there is no option to reference it back to the sales order line. How can this be done manually?

Hello, Did you manage to solve this issue? I have the same problem - in v7 I could refer to the SO Item, but in v8 this seems to be missing. Somehow I can't find a way to refer from stock.pack.operation to sale.order.line and I need that to generate proper delivery order report... In odoo-8.0/openerp/addons/sale/sale.py -> "def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None):" I see "'sale_line_id': line.id ", but there is no such field in the stock.pack.operation model. Why is that? I really don't understand why it worked in v7 and now the field is missing. Looking forward to your feedback! Regards, Pavel

Pavel Pavlov
on 12/13/14, 6:35 AM
0
Pavel Pavlov
On 12/14/14, 4:33 PM

Hello, 

After two about 20h struggle I could not find a nice way do to that.Still I have at least a temporary solution, that solves this problem.
I would really love to get feedback from you on this. Especially how to rewrite it, so that I don't use cr and manual trims. I know this is wrong, but I could get the result in other way.

Regards,
Pavel

class stock_pack_operation(osv.osv):
    _inherit = "stock.pack.operation"
    _columns = {
                'x_sale_line_id': fields.many2one('sale.order.line', 'Custom Field: Reference to the  sale.order.line', required=True)
                }   
    def create(self, cr, uid, vals, context=None):
        tmp = [vals['picking_id']]
        cr.execute('SELECT origin FROM stock_picking WHERE stock_picking.id = %s', tmp)
        origin = cr.fetchone()
        origin = origin[0] 
        origin = int(origin[2:])
        cr.execute('SELECT id FROM sale_order_line WHERE order_id = %s AND product_id=%s', (origin, vals['product_id']))                
        zsli = cr.fetchone()    
        zsli = zsli[0]    
        vals['x_sale_line_id'] = zsli 
        res_id = super(stock_pack_operation, self).create(cr, uid, vals, context=context)
        return res_id

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 2/7/14, 4:11 AM
Seen: 1664 times
Last updated: 10/30/15, 8:56 AM