콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
질문이 마감되었습니다 이유 : 주제 외 또는 관련없음
작성자 BRAHIM El-houcine 있음 2024년 04월 15일 05시 04분 02초
2313 화면

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!


아바타
취소
관련 게시물 답글 화면 활동
0
2월 24
1446
1
6월 23
6416
0
4월 23
3285
0
2월 23
2195
1
1월 22
2978