Odoo Aide

0

Access 'sale.config.settings' value from 'sale.order'

Par
Mohammed Amal
sur 24/04/2017 23:46 875 Vues

I want get value in Default invoicing(default_invoicing_policy) in sales settings(sale.config.settings). 

I tried get_default but its returning a none value

My code :

class MyTestClass(models.Model):
_inherit = 'sale.order'

@api.multi
def my_method(self):
res = super(MyTestClass, self).my_method()
ir_values = self.env['ir.values']
def_inv = ir_values.get_default('sale.config.settings', 'default_invoice_policy')
print def_inv
        return res

here it is printing none

3
Asmita Chavan
Le 25/04/2017 03:47

You can check default_invoice_policy field definition,

default_invoice_policy = fields.Selection([
('order', 'Invoice ordered quantities'),
('delivery', 'Invoice delivered quantities')
], 'Default Invoicing',
default='order',
default_model='product.template')

In this field definition, default_model is set as product.template, so this value is not set under model 'sale.config.settings', but it is set under model 'product.template' with name invoice_policy,

So, you have to retrieve value using,

def_inv = ir_values.get_default('product.template', 'invoice_policy')

same applies for picking policy too, picking policy value is set under sale.order model.

In ir.values you can observed that no value is set with name which starts with default_ , there is always substitute field added in another model, to set that value.

A propos de cette communauté

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

Outils de question

1 Abonné(e)s

Statistiques

Posée: 24/04/2017 23:46
Vu: 875 temps
Dernière mise à jour: 29/04/2017 22:14