Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
De vraag is gesloten voor reden: Off-topic of niet relevant
door BRAHIM El-houcine met 15-04-2024 05:04:02
1601 Weergaven

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
feb. 24
868
1
jun. 23
5686
0
apr. 23
1601
0
feb. 23
1665
1
jan. 22
2556