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

Get Sales order line details inside create Function

By
Cyrus Waithaka
on 2/1/16, 6:59 PM 376 views

I am building a function to generate a docx report when a sales order is created. So far, I have found an amazing python module to achieve this (docx). To achieve this, I am hooking to the create() function. However, I cant find a way to access the sales order lines inside the create function. Here is my code:

    def create(self, cr, uid, vals, context=None):
if vals.get('name', '/') == '/':
vals['name'] = self.pool.get('ir.sequence').next_by_code(
cr, uid, 'sale.offer') or '/'
order_lines = vals.get('order_line')# How do I get things like order item names and quantities
return super(sale_offer, self).create(cr, uid, vals, context=context)

Any ideas will be highly appreciated.

0
Samantha Cruz
On 2/2/16, 1:41 AM

 Add these codes after order_lines = vals.get('order_line'). Hope  it helps :)

    for line in order_lines:
name = line[-1]['field you want to get']

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

1 follower(s)

Stats

Asked: 2/1/16, 6:59 PM
Seen: 376 times
Last updated: 2/2/16, 1:41 AM