Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: request

by
Wolfgang Pichler
- 11/11/2014 08:32:27
please read the docs


it must be more something like this (but not exactly)

def mapqot = [‚partner_id‘:id, ‚client_order_ref‘:“ref“, ‚order_lines‘: [0,0, ['product_id':id1,'product_id':"4“]]

Am 11.11.2014 um 14:22 schrieb Khouaja mohamed aymen <khouaja.aymen@gmail.com>:

i tried with this script 

//get  Customer ID
def arg = [['name','=','Agrolait']]
def id = openerp.execute(dbname, uid, pwd,'res.partner','search',arg)
println id
//Get Product ID
def arg1 = [['name','=','Datacard']]
def id1 = openerp.execute(dbname, uid, pwd,'product.product','search',arg1) 


def mapqot = [[0, 0, ['partner_id':id,'client_order_ref':"Agrolait"]],[0, 0, ['product_id':id1,'product_id':"4"]]]

def partner_id = openerp.execute(dbname, uid, pwd,'sale.order','create',mapqot)
 

but i have this error below




uk.co.wilson.net.xmlrpc.XMLRPCFailException: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/service/wsgi_server.py", line 82, in xmlrpc_return
    result = openerp.netsvc.dispatch_rpc(service, method, params)
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/usr/ lib/pymodules/python2.7/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/addons/sale_stock/sale_stock.py", line 70, in create
    if vals.get('order_policy', False):
AttributeError: 'list' object has no attribute 'get'
 : 'list' object has no attribute 'get'

at uk.co.wilson.net.xmlrpc.XMLRPCMessageProcessor.endElement(XMLRPCMessageProcessor.java:627)

at uk.co.wilson.xml.MinML.parse(MinML.java:312)

at uk.co.wilson.net.xmlrpc.XMLRPCMessageProcessor.parseMessage(XMLRPCMessageProcessor.java:443)

at ConsoleScript24.run(ConsoleScript24:38)


2014-11-11 10:13 GMT+01:00 Wolfgang Pichler <wpichler@callino.at>:

hi,


you cannot specify partner_id with the name as referent - you first have to fetch the real id from the system with a search function.

so do a search on res.partner for the partner - you will get the id

Also you can not specify the product direct with the sale.order - adding products to sale orders means to add sale.order.line entries to an existing sale.order.

so you have to create sale.order - then search the product ids - and create sale.order.line entries.

or use the relational mapping to automatically create the sale.order.line entries with the sale.order line - take a look here at the end to get an idea


br,
Wolfgang

Am 11.11.2014 um 09:57 schrieb Khouaja mohamed aymen <khouaja.aymen@gmail.com>:

thx Mr pichler for ur answer  

below in red color you will find the request i did 

@Grapes(
    @Grab(group='org.codehaus.groovy', module='groovy-xmlrpc', version='0.8')
)         
import groovy.net.xmlrpc.*

//Adresse URL du serveur qui contient OpenERP

//Données d’utilisateur qui permettent l’authentification auprès du serveur  
def username = "admin" //nom d’utilisateur
def pwd = "isicallisto"   //mot de passe
def dbname = "CALLISTO"   //nom de base de donnée du groupe


def serverProxy = new XMLRPCServerProxy(myserver+'common')
def uid = serverProxy.login(dbname, username, pwd)
def openerp =  new XMLRPCServerProxy(myserver+'object')

println("---- Connection Established ----")

/**** First Script Listing All Customers ****/
println()
println("**************** Script 1 ******************")
println()


def mapqot = ['partner_id':"Agrolait",'client_order_ref':"Agrolait",'product_id':"Datacard",'date_order':"2014-11-10",'product_uom_qty':"4"]
def partner_id = openerp.execute(dbname, uid, pwd,'sale.order','create',mapqot) 
 
openerp.execute(dbname, uid, pwd, 'sale.order', 'save',  partner_id[0])


2014-11-11 9:52 GMT+01:00 Wolfgang Pichler <wpichler@callino.at>:

Hi,


you have to show us the request - it seems you have a wrong parameter at the request

br,
Wolfgang

Am 11.11.2014 um 09:42 schrieb Khouaja mohamed aymen <khouaja.aymen@gmail.com>:

Hi , 


im working on openERP 7.0 and im trying to create  an object 'sale.order' in openErp

through an  XML-RPC script launched from the webpage  but i couldn't  when i run 

the script i have this error  in the attached file 


Best regards 

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

<is.txt>

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe