Skip to Content
Menu
This question has been flagged
1 Reply
6728 Views

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

Avatar
Discard
Best Answer

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.

Avatar
Discard