Odoo Help


ValueError Expected singleton: sale.order.line when I Create record from sale order line to Project

on 4/22/16, 4:11 AM 1,105 views
Here I want to create New Project from a Sale order line ,for that i create a button (create_project_new)
Each line I need to create a single Project .I can create single Project
from single sale order line.I cant Process multiple sale order lines
Suppose I have 10 order line in Sale order then I need to create 10 Projects.
I tried with multiple lines but got error

ValueErrorExpected singleton: sale.order.line(32, 33, 34)

this is my screen shot


this is my code-------------------------

def create_project_new(self,cr,uid,ids,context):
 invoice_pool = self.pool.get('project.project')
 # product_pool = self.pool.get('product.product')
 default_fields = invoice_pool.fields_get(cr, uid, context=context)
 invoice_default = invoice_pool.default_get(cr, uid, default_fields, context=context)
 for customer in self.browse(cr, uid, ids, context=context):
 temp = customer.order_line.order_id
 for val in temp:
 invoice_data = {
 'name': customer.order_line.product_id.name, }
 invoice_id = invoice_pool.create(cr, uid, invoice_default, context=context)
 return True


def create_project_new(self,cr,uid,ids,context):    self.write(cr,uid,ids,{'state':'create_project'})    # for val_obj in self.browse(cr,uid,ids,context):    invoice_pool = self.pool.get('project.project')        # product_pool = self.pool.get('product.product')    default_fields = invoice_pool.fields_get(cr, uid, context=context)    invoice_default = invoice_pool.default_get(cr, uid, default_fields, context=context)    for customer in self.browse(cr, uid, ids, context=context):        temp = customer.order_line            # raise Warning('You can not add instructor as a attendee'+str(temp))        for val in temp:                # raise Warning('You can not add instructor as a attendee'+str(val))            invoice_data = {                                'name': val.product_id.name,                                }            invoice_default.update(invoice_data)            invoice_id = invoice_pool.create(cr, uid, invoice_default, context=context)    return True


Prakash Sharma

--Prakash Sharma--
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 4/22/16, 4:35 AM

I have find  some the logical error here :

temp = customer.order_line.order_id 


both these two line are wrong,IF  customer will have more than one order line(as you say)  then these two logic will fail.

instead try 

temp = customer.order_line

and now iterate the temp, 

invoice_data = {'name': val.product_id.name,}

this may help you.

Yes corrected with your answer thanj you.......

on 4/22/16, 5:13 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/22/16, 4:11 AM
Seen: 1105 times
Last updated: 4/22/16, 5:12 AM