I have created a custom sale settings under sale.config.settings, to select a journal when the custom field show_separate_invoice is checked. The fields are visible in the UI, but when I choose a value for the is show_separate_invoice, and click on apply, the fields again become blank. What else am I missing?
.py
class CustomSettings(models.TransientModel):
_inherit = 'sale.config.settings'
show_separate_invoice = fields.Boolean('separate_invoice', help='Show separate invoice based on product type', default=False store=True)
journal_to_invoice = fields.Many2one('account.journal', string='journal', store=True)
.xml
<record id="custom_invoice_settings" model="ir.ui.view">
<field name="name">sale.settings.inherited</field>
<field name="model">sale.config.settings</field>
<field name="inherit_id" ref="sales_team.view_sale_config_settings"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='main']" position="inside">
<group string="Invoicing">
<field name="show_separate_invoice"/>
<field name="journal_to_invoice" domain="[('type', '=', 'sale')]" attrs="{'invisible':[('show_separate_invoice','=',False)],'required':[('show_separate_invoice','=',True)]}"/>
</group>
</xpath>
</field>
</record>