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

Creating a purchase order

By
Fabian
on 1/29/16, 3:50 AM 591 views

Hey guys,

I try to creat a purchase order via XML-RPC.

This is my code:

gid=125 # Id of supplierp
id= 64 # ID of product
models.execute_kw(db, uid, passwrd, 'purchase.order', 'create',
     [{'partner_id': gid, 'state':'approves', 'location_id':12,    
        'order_line':[(0,False,{'product_id':pid,'product_qty':20.0, 'price_unit':2,0})]
       }])


The problem is, taht I get the following Error:

>>>

xmlrpclib.Fault: <Fault 2: 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: pricelist_id - pricelist.id]'>

<<<

In the purchase.py file is pricelist_id set as default.

 Does anyone know how to creat a purchase order sucessfull?

1

Hardikgiri Goswami

--Hardikgiri Goswami--
1123
| 2 1 5
Rajkot, India
--Hardikgiri Goswami--

OpenERP/Odoo Customization/Integration Expert / Python Programmer

Skype ID : hardikgiri.goswami

Hardikgiri Goswami
On 1/29/16, 5:35 AM

Hi Fabian,

Following fields are compulsory to pass with XMLRPC.

models.execute_kw(db, uid, password, 'purchase.order', 'create',[{
'partner_id': 1,
'state':'approved',
'pricelist_id': 2, // this is pricelist id default get by the framework in UI not in XMLRPC.
'name': 'PO00100', // this also need to passed from python code.
'location_id':12,
'order_line':[(0,False,{
'name':'abcd', // this must be description of product.
'date_planned':str(datetime.datetime.now()), // Planned date need to pass.
'product_id':1,
'product_qty':20.0,
'price_unit':2.0
})]
}])


Regards,

Hardik

It's working fine! Thanks a lot.

Fabian
on 1/29/16, 6:45 AM

By any chance, do you now how to set the purchase as shipped? Maybe by using models.exec_workflow?

Fabian
on 1/29/16, 7:15 AM

For that, I think you need to create Incoming shipment with same Procurement Group.

Hardikgiri Goswami
on 1/29/16, 7:36 AM

Hey Hardik, if I create a Purchase with your code and click on "Receive Products" is there no linking. I have to create a whole new Transfere. Is there a way to commit the data from the purchase to the Receive Products template?

Fabian
on 2/1/16, 4:55 AM
It is because of product id, The Product we select is "Service" Product. Change the Product with any other and it will appear in the Receive Product too.

On Mon, Feb 1, 2016 at 3:25 PM Fabian <go.public@mailbox.org> wrote:

Hey Hardik, if I create a Purchase with your code and click on "Receive Products" is there no linking. I have to create a whole new Transfere. Is there a way to commit the data from the purchase to the Receive Products template?

--
Fabian

Hardikgiri Goswami
on 2/1/16, 4:58 AM

hmm.... really strange on my installation it seems, that odoo do not commit the product_id... I've creted the product 'ball' ( porduct_id:67) but when i create a purchase via api i don't get the Product 'ball' i get every time the 'test Product'. When i read the purchase order via 'purchase_order','read': i get the message: 'product_id': [67, 'test Product']. Futhermore there is no linking with 'receive Product'

Fabian
on 2/1/16, 5:31 AM

May be we need skype meeting for this xmlrpc explanation. My skype id is hardikgiri.goswami

Hardikgiri Goswami
on 2/1/16, 5:37 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: 1/29/16, 3:50 AM
Seen: 591 times
Last updated: 1/29/16, 6:39 AM