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

How to display result WSDL in list view xml odoo?

By
Salma
on 3/8/16, 2:56 AM 567 views

Hi ! please can someone tell me how to parse an WSDL file in python and how to display the result in a tree view ?

Hello, I think your question is too short, you should describle your problem in more details like: How is your WSDL file got read by Odoo? is it in your server file system? To display data in a tree view, after parsing wsdl file, you may create a set of records and display it like other models.

Thanh Loyal
on 3/8/16, 6:03 AM

Hi Thanh Loyal ! Thank you for your response : ) so I connect to the url of my WSDL with the suds library (Python 2.7.9) and this is the code : import suds from suds.client import Client from suds.transport.https import WindowsHttpAuthenticated ntlm = WindowsHttpAuthenticated(username='xxxxx', password='yyyyy') url = 'http://xxxxxxx' client = Client(url, transport=ntlm) print (client) # this will return the methods and types available from the codeunit result = client.service.ReadMultiple() client.service.ReadMultiple() return an array that contain objects and I want to display this list of object in a tree view, that's why I create a new class which its attributs are computed fields that contain the fields of the object returned by the web service . Code : class ProductImpo(models.Model): _name = 'product.impo' ...... Serial_No = fields.Char(string="N° de série", compute='_compute_serial_no') ....... And the function code is : @api.multi def _compute_serial_no(self): i=-1 for record in self: i=i+1 record.Serial_No=result.Stock_Vehicule[i].Serial_No And the view : product.impo.tree product.impo ..... .... For this exemple the array returned contain 14 rows so those 14 rows are displayed in the tree view only if I create manually 14 rows empty just with ID in the table ProductImpo in PostgreSQL so my question is how to create a new row in the table by using python adding rows = len(result.Stock_Vehicule) PS : Stock_Vehicule is the arry returned which is 14 in this example

Salma
on 3/9/16, 2:47 AM
0
Thanh Loyal
On 3/9/16, 3:41 AM

Hi,

Your question is clearer now.

I dont know when your first python code section runs? I usually write functions in a model class or in a controller.

And I think you may follow these steps:

1. Retrieve the model

   1.1 In case of a model class

     product_impo = self.env['product.impo']

   1.2 In case of a controller:

     product_impo = http.request.env['product.impo']


2. Write data that your client retrieved to DB using the above model:

     # for each row in 14 rows

   product_impo.sudo().write({   # think more about sudo() for more secure

     'Serial_No': self.Serial_No # If your method is in a Model class

  })


OR


   product_impo.sudo().write({

     'Serial_No': row.Serial_No # If your method is in a controller

  })

0
Salma
On 3/9/16, 2:48 AM

Hi Thanh Loyal ! Thank you for your response : ) so I connect to the url of my WSDL with the suds library (Python 2.7.9) and this is the code :

import suds

from suds.client import Client

from suds.transport.https import WindowsHttpAuthenticated

 ntlm = WindowsHttpAuthenticated(username='xxxxx', password='yyyyy')

url = 'http://xxxxxxx'

client = Client(url, transport=ntlm)

print (client) # this will return the methods and types available from the codeunit

result = client.service.ReadMultiple()

client.service.ReadMultiple() return an array that contain objects and I want to display this list of object in a tree view, that's why I create a new class which its attributs are computed fields that contain the fields of the object returned by the web service . Code :

class ProductImpo(models.Model):

_name = 'product.impo'

......

Serial_No = fields.Char(string="N° de série", compute='_compute_serial_no')

.......

and the function code is :

@api.multi

def _compute_serial_no(self):

i=-1

for record in self:

i=i+1

record.Serial_No=result.Stock_Vehicule[i].Serial_No

and the view :

<record id="product_impo_tree_view" model="ir.ui.view">

<field name="name">product.impo.tree</field>

<field name="model">product.impo</field>

<field name="arch" type="xml">

<tree string="Disponibilité">

.....

<field name="Serial_No"/>

....

</tree>

</field>

</record>

For this exemple the array returned contain 14 rows so those 14 rows are displayed in the tree view only if I create manually 14 rows empty just with ID in the table ProductImpo in PostgreSQL so my question is how to create a new row in the table by using python adding rows = len(result.Stock_Vehicule)

PS : Stock_Vehicule is the arry returned which is 14 in this example

when I try to retrieve the model I obtain this error : impo_obj = self.env['product.impo'] NameError: name 'self' is not defined and this is the code : class ProductImpo(models.Model): _name = 'product.impo' ..... Serial_No = fields.Char(string="N° de série", compute='_compute_serial_no') ...... impo_obj = self.env['product.impo'] ...... When I try to put it in a function like : def _tester(self): impo_obj = self.env['product.impo'] ...... after that when I call the function self still inknown

Salma
on 3/9/16, 4:11 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/8/16, 2:56 AM
Seen: 567 times
Last updated: 3/9/16, 3:41 AM