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.

1

How to pass product_ids from old sales order to new sales order.

By
Logicious
on 3/3/16, 2:16 AM 373 views

Hello,

Can anyone tell how can i pass product from old sales order into new sales order. I made one reference veriable of sales order as many2one in sales order, from here we can able to select any sales order. when i am creating a sales order i can able to select any previous orders , if i selected any one of them , i need to pass the entire products from that order line into my new sales order. How can i do that.?? i added one button for that, but its not working.


Thanking you,

Logicious

i got a same situation in form , but its for purchase . exact same thing i needed for my sales. i am attaching that for reference.https://www.odoo.com/forum/help-1/question/how-to-fill-purchase-order-line-with-sale-order-line-9924

Logicious
on 3/3/16, 4:40 AM
1
pks
On 3/3/16, 7:30 AM

in this you all ready told that you created on but, you can continue with that,if you refer the module "sale_add_products_wizard" apps, you can easily add that into your function.

i will give you my code , if you can modify it .

def button_submission_submit(self,cr,uid,ids,context=None):

order_line_obj = self.pool.get('sale.order.line')

product_obj = self.pool.get('product.product')

data=self.browse(cr,uid,ids[0]) 

partner = data.partner_id.id  

pricelist = data.pricelist_id.id  

line_ids = data.sale_id.order_line

for line in line_ids:

product_id = line.product_id.id

p = product_obj.browse(cr,uid,product_id)

uom_q = p.uom_id.id

qty_p = line.product_uom_qty 

product = self.pool.get('sale.order.line').product_id_change(cr, uid, ids,

pricelist,

product_id,

qty=qty_p,

uom=uom_q,

partner_id=partner

)

val = {

'name': product['value'].get('name'),

'product_uom_qty': qty_p,

'order_id': ids[0],

'product_id': p.id or False,

'product_uom':uom_q,

'price_unit': product['value'].get('price_unit'), 

order_line_obj.create(cr,uid,val)

return True

@pks thank you , its working fine.

Logicious
on 3/3/16, 7:34 AM

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: 3/3/16, 2:16 AM
Seen: 373 times
Last updated: 7/7/16, 6:23 AM