Odoo Help

2

0
3 Answers
3
Avatar

Hilar AK Oman

--Hilar AK--
17451
| 7 6 11
Muscut, Oman
--Hilar AK--
Experienced Odoo / Python Developer with a demonstrated history of working in the information technology and services industry with 3.5+years of experience. Skilled in Python, PostgreSQL, SQL, HTML, JavaScript. Strong engineering professional with a Bachelor of Technology (BTech) focused on Computer Science from the College of Engineering Munnar.

 Blogs:-

https://medium.com/@hilarak
https://hilarlive.wordpress.com/
 StackOverflow:
       https://stackoverflow.com/users/7561347/burmese-pythis-hilar-ak

Hilar A.K

AL Sabla Digital Solutions LLC

Office: +968 24121299 Mobile: +968 71026998
P.O Box  2839, P.C 112, Ruwi, Sultanate of Oman




Hilar AK Oman
10/15/19, 1:29 AM

This is the correct format for using rpc.


var rpc = require('web.rpc')

rpc.query(

     model: //your model,

     method: //your method,

      args: [{

          'arg1': value1,

      }]

 }).then(function (result) { 

            // your code 

  });


on model.py

@api.model
def your_method(self):
     ...

With your example, Try to change this function

nfce_return_invoice: function(name){
rpc.query({
model: 'pos.order',
method: 'search_invoice',
args: [{'name': name}]
},{timeout: 30000}).then(function (invoice) {
return invoice;
});
},


Reference: https://www.odoo.com/forum/help-1/question/how-do-i-properly-pass-args-using-rpc-in-odoo-11-141324#answer-141345


3 Comments
Michael Douglas Brazil
10/15/19, 7:51 AM

The data is coming in then, but they do not return without being a promise, I need them to use in the coupon printing on the pdv

Hilar AK Oman
10/15/19, 7:55 AM
Okay, instead of returning them, call the related function with data as argument. 

On Tue, 15 Oct 2019, 3:52 pm Michael Douglas, <contatomichael@outlook.com.br> wrote:

The data is coming in then, but they do not return without being a promise, I need them to use in the coupon printing on the pdv

Enviado por Odoo S.A. using Odoo.

Michael Douglas Brazil
10/15/19, 8:30 AM

I didn't quite understand what I meant, take a look to see where I'm going wrong https://pastebin.com/Ubh3CacN

3
Avatar

Sudhir Arya (ERP Harbor Consulting Services) India

--Sudhir Arya (ERP Harbor Consulting Services)--
26852
| 8 9 10
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

ERP Harbor Consulting Services

Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services) India
10/15/19, 12:17 AM

I am not expert in JS but I think following code would work:

self.pos.nfce_return_invoice(obj.order.name).then(function (invoice) {
console.log(invoice);
});


1 Comment
Michael Douglas Brazil
10/15/19, 7:55 AM

Inside "THEN" everything works perfectly, the problem is that I need to return the data to another function without promise got it?

0
Avatar

shalin wilson Bahrain

--shalin wilson--
--shalin wilson--

Experienced Odoo professional, passionate about the latest technologies and business solutions.
skilled in  .Net Web technologies and Odoo technical development using Python Xml and Javascript.
familiar with Odoo V8,9,10,11 and Odoo12.

Feel free to contact for help
E-mail : shalinwilson1994@gmail.com
Phone : 9995533527
linkedin : https://www.linkedin.com/in/shalin-wilson-a1318183/

shalin wilson Bahrain
10/15/19, 12:35 AM

check with your method 'search_invoice' and check if it gets the correct data.and also 

check 'invoice' you get in js
you can find the error

3 Comments
Michael Douglas Brazil
10/15/19, 7:56 AM

There is no error, the problem is that it returns a promise and not the data

shalin wilson Bahrain
10/15/19, 8:23 AM

did you get the data as a response from Search_invoice function?

Michael Douglas Brazil
10/15/19, 8:33 AM

Yes, the data has been returned, but I can't get the information out of the "promise" and return the data to the function I need, see my code: https://pastebin.com/Ubh3CacN

Ask a Question
Keep Informed
1 follower(s)
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.

Register
Odoo Training Center

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

Test it now