Ir al contenido
Menú
Se marcó esta pregunta
Su pregunta ha sido cerrada. por motivo: Fuera de tema o sin relevancia
por BRAHIM El-houcine de 15/04/2024 05:04:02
1937 Vistas

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
feb 24
1185
1
jun 23
6069
0
abr 23
1947
0
feb 23
1863
1
ene 22
2742