This question has been flagged
3 Replies
5698 Views

I am having some difficulty with this, i am trying to get the description from the sales order per product line on the delivery note:

The delivery note calls the following function:

def get_product_desc(self,move_line):
    desc = move_line.product_id.name
    if move_line.product_id.default_code:
        desc = '[' + move_line.product_id.default_code + ']' + ' ' + desc
    return desc

I would have thought that just adding + move_line.product_id.XXX and creating a field in the move line names xxx would have done it? But I cannot for the life of me figure out how to add the field to the move_line ?

Your help would be appreciated

Avatar
Discard

Do you want to put the information onto a report? Which report? Do you mean the name or the description of the product? which version do you use?

Author

Using version 7, I want to get the info into the delivery note created from rhe sales order through create deliveries. I need to get the Description from the sales order line in there. i.e we have some products where the code is meaningless and on the order we add text in the sales line.

Best Answer

I do not know where do you use the function but if you want to return the description of the sale.order.line then you can use:

def get_product_desc(self,move_line):
    if move_line.sale_line_id:
        return move_line.sale_line_id.name
    return False

I assume that move_line is not only the id, but a whole object.

Avatar
Discard
Best Answer

product_id just holds the identifier for the product, no more details.

you have to do something more like this:

def get_product_desc(self,product_id):
    product_product = self.pool.get('product.product')
    product = product_product.browse(cr, uid, product_id, context=context_partner)
    desc = product.name
    if product.default_code:
        desc = '[' + product.default_code + ']' + ' ' + desc
    return desc
Avatar
Discard
Author

I see where your coming from with that but I still cant get it working,

Author Best Answer

I tried

def get_product_desc(self,move_line):
    product_product = self.pool.get('product.product')
    product = product_product.browse(cr, uid, move_line.product_id, context=context_partner)
    # desc = move_line.product_id.name 
    desc = product.name
    if product.default_code:
        desc = '[' + product.default_code + ']' + ' ' + desc
    return desc

again the move_line is passed from the picking.py and called in the report, i still think I would need to add the description into the move_line

Still stuck but thanks

Avatar
Discard

if product.default_code: desc = '[' + product.default_code + ']' + ' ' + desc return desc

Author

def get_product_desc(self,move_line): product_product = self.pool.get('product.product') product = product_product.browse(cr, uid, move_line.product_id, context=context_partner) desc = product.name if product.default_code: desc = '[' + product.default_code + ']' + ' ' + desc return desc