Hi, I overrode the _default_journal method so that the default journal is set depending on the type of the invoice (refund or invoice), here is the new function:
@api.model
def _default_journal(self):
if self._context.get('default_journal_id', False):
return self.env['account.journal'].browse(self._context.get('default_journal_id'))
inv_type = self._context.get('type', 'out_invoice')
inv_types = inv_type if isinstance(inv_type, list) else [inv_type]
company_id = self._context.get('company_id', self.env.user.company_id.id)
domain = [
('type', 'in', [TYPE2JOURNAL[ty] for ty in inv_types if ty in TYPE2JOURNAL]),
('company_id', '=', company_id),
]
# If we're creating a customer credit note, set default journal to 11 (CCN)
if inv_type == "out_refund":
domain.append(("id", "=", 11))
return self.env['account.journal'].search(domain)
11 is the journal I want for refunds, I checked the returned value with the help of the _logger , and It returns indeed 11 on refunds, but the problem, is that this value is ignored in the view and It selects a value as if I did not change the default function, what am-I missing ? Thank you