I have created a custom module that adds a field show_separate_invoice to the ir.config.settings. Now how to check the condition if show_separate_invoice is checked or not? And if checked, how to get the custom field journal_to_invoice value from another module(sale.order)
class CustomSettings(models.TransientModel):
_inherit = 'sale.config.settings'
show_separate_invoice = fields.Boolean('separate_invoice')
journal_to_invoice = fields.Many2one('account.journal', string='journal')
@api.model
def get_default_show_separate_invoice(self, fields):
irconfigparam = self.env['ir.config_parameter']
return{
'show_separate_invoice': irconfigparam.get_param('show_separate_invoice', False)
}
@api.multi
def set_default_show_separate_invoice(self):
self.ensure_one()
irconfigparam = self.env['ir.config_parameter']
irconfigparam.set_param('show_separate_invoice', self.show_separate_invoice)
@api.multi
def set_default_journal_to_invoice(self):
return self.env['ir.values'].sudo().set_default('sale.config.settings', 'journal_to_invoice', self.journal_to_invoice.id)
Hey Naksha,
Below links will definitely help you ,
http://ludwiktrammer.github.io/odoo/custom-settings-odoo.html
https://www.odoo.com/forum/help-1/question/how-can-i-save-load-my-own-configuration-settings-30123
http://www.mindissoftware.com/How-to-save-and-load-module-configuration-in-odoo/