Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
La domanda è stata chiusa con motivazione: Fuori tema o non rilevante
da BRAHIM El-houcine - 15/04/2024 05:04:02
2179 Visualizzazioni

I am working with Odoo and facing an issue where changes made to the journal_id in the account.move model's default_get method are not reflected in the UI for credit notes, although the debug shows that the changes are applied. This problem does not occur with invoices when removing a specific condition. Here is the code snippet:

class AccountMove(models.Model):
    _inherit = 'account.move'

    @api.model
    def default_get(self, fields_list):
        res = super().default_get(fields_list)
        journal = self.env.company.credit_notes_journal_id
        context = self._context.get('default_move_type')
        if 'journal_id' in res and journal and context == 'out_refund':
            res['journal_id'] = journal.id
        return res

he journal_id is correctly set when the condition meets for credit notes (out_refund), as verified by debugging. However, the UI does not reflect this change and shows a different journal than the one specified.

I have ensured that:

  • There are no other overrides of default_get causing conflicts.
  • There isn't an unnoticed @api.onchange method that might affect this behavior.
  • This setup works as expected for invoices but not for credit notes.

Question:

Is there a mechanism or method prior to default_get that sets or overrides the value of journal_id before the form view is loaded? Or am I missing an @api.onchange decorator that is required for the UI to reflect the changes made in default_get? Additionally, why does this approach work for invoices but not for credit notes?

Additional Context:

This behavior is consistent across all custom modules; there is no modification of the journal elsewhere. Debugging suggests that this default_get method is the last to execute before the form view is rendered.

Any guidance or insights into this issue would be greatly appreciated. Thank you!


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
feb 24
1351
1
giu 23
6332
0
apr 23
2266
0
feb 23
2026
1
gen 22
2919