Odoo Aide

0

0
1 Réponse
2
Avatar

Hilar AK Oman

--Hilar AK--
17374
| 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 AK Oman
20/01/2017 23:22

Hi,

check whether your object is browsable, and you can call function by

env['pos.order'].cost_elab() like self.env['product.uom']._compute_price(line.product_id.uom_id.id, purchase_price, to_uom_id=line.product_uom.id)


class x(Object):

     def y():

         return "teste"

class y(models.Model, x):

     """ here I can access function y as self.y() """

     print self.y()

if still probs, then please give me your example code

In case of odoo lets take an example.


class res_partner(models.Model):
_inherit = "res.partner"
    @api.multi
def google_map_img(zoom=17, width=298, height=298):
partner = self.browse([partner_id])
        params = {
  'center': '%s, %s %s, %s' % (partner.street or '',
        partner.city or '',
        partner.zip or '',
        partner.country_id and partner.country_id.name_get()[0][1] or ''),
        'size': "%sx%s" % (height, width),
  'zoom': zoom,
        'maptype': 'hybrid',
  'sensor': 'false',
  }
        return urlplus('//maps.googleapis.com/maps/api/staticmap', params)

class test(models.Model):
     _name = 'your.name'

     @api.multi
     def test(self):
partner = self.sudo().partner_id
    return partner and partner.google_map_img(zoom, width, height) or None

In case you have no record set try @api.model instead of multi



     

6 Commentaires
FEDERICO LEONI Brésil
21/01/2017 06:32

Can you please elaborate more?

In pure python with the help of psycopg2 is quite easy trigger an action (I'm using a daemon now) but the more I dig into Odoo the more I realize perhaps is better stay with my own setup.

If you think is important I'll update the OP with a draft of my python code.

FEDERICO LEONI Brésil
21/01/2017 07:47

And just for let you know, your example give me an error of invalid syntax after 'like'.

Hilar AK Oman
21/01/2017 08:36

like is not an operator here , i just used to explain an example.

eg: self.env['product.uom']._compute_price(line.product_id.uom_id.id,purchase_price,to_uom_id=line.product_uom.id)

FEDERICO LEONI Brésil
21/01/2017 08:51

Ok, I'll have a look more deeply using your sample code.

But somehow 'self' doesn't works well with pos.order/server action.

See my previous thread here:

https://www.odoo.com/forum/help-1/question/solved-server-actions-how-to-replace-self-write-command-with-new-api-for-odoo-10-113549

Hilar AK Oman
21/01/2017 09:03

I see try @api.model instead of @api.multi

FEDERICO LEONI Brésil
21/01/2017 09:12

Hilar, thank you for your time.

I prefer not to use @api.model, since I would like to use just the new API.

Let me assimilate the concept and Í'll write some lines of code. But again, coding under Odoo should be more simple... Or probably I'm just getting old!

Poser une question
Writer
Keep Informed
1 Abonné(e)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