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 get attribute from another class

By
Matthieu
on 5/13/16, 5:21 AM 349 views

Hello,

I've got a little problem. I'm currently creating a custom module on Odoo 9 and I want to get an attribute defined in _columns in an inherit of pos_order in another class inherited : account_invoice.


How can I do that ?


Thank you in advance for your help.

if you have the order id in invoice, uisng that id you can browse pos_order record to get that attribute right?

Akhil P Sivan
on 5/13/16, 6:25 AM

Hi Akhil, I agree with you but the problem is the same with browse. Cause to browse in pos_order, we need to do "self.pool.get('pos.order').browse(cr, uid, ids, context=context)" but we still don't have "cr", "uid", "ids" and "context". Thanks for your help and help me if you find a solution.

Matthieu
on 5/13/16, 8:19 AM

Otherwise, self.reference give us the id of the order linked to the current account_invoice and matches with pos_reference from the order of pos_order.

Matthieu
on 5/13/16, 9:05 AM
0
Matthieu
On 5/13/16, 9:01 AM


You should be able to browse pos.order by using self.env['pos.order'].browse(your_id). cr, uid ,ids and context should be set automatically if you use v9 api. If you ever need to used those, you can use self._cr, self._uid and self._context

Niboo SPRL, Jerome Guerriat
on 5/13/16, 5:40 PM

Well, thank you for your answer. It's almost working. I'm currently doing "order = self.env['pos.order'].browse(self.reference)" and the result of this is an object that is "{'env': , '_ids': (u'Main/0007',)}" (when I use the "_logger.info" command). And I tried to get my attribute from different way but each time, I'm getting an error so I think, I'm not doing it right... Thanks a lot for you help !

Matthieu
on 5/17/16, 3:30 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: 5/13/16, 5:21 AM
Seen: 349 times
Last updated: 5/13/16, 9:01 AM