콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5638 화면

Odoo 11


For an extension module I have same fields and logic for sale.order and account invoice. I would like to have them in a mixin, however, I did not find a solution:

* if I use a plain python class and plain python multiple inheritance (class SaleOrder(MyMixin, models.Model)) it first works, but overriding decorated methods does not. E.g. @api.depends is just executed in MyMixin, overriding a helper method in the subclasses has no effect. I can, however, leave those methods undefined in MyMixin and just define them in the subclasses (what I do now with a bit of duplication). There is also another small issue with this solution: customizing the create method leads to a wrong JSON return: instead of the ID, sale.order(ID,) is returned, leading to a Postgres error on read.

* if i inherit from models.AbstractModel, related and computed fields in MyMixin do not work, because they rely on fields (e.g. partner_id) in sale.order and account.invoice. It throws the error KeyError: 'partner_id'

I tried more approaches (multiple inheritance with inherit = [] etc.) without luck, but I wonder how if there is an intended way to solve this. Also, I want to ask if using the plain python class MyMixin could have other undesired side effects.


아바타
취소
관련 게시물 답글 화면 활동
0
5월 25
1104
0
11월 24
690
2
7월 20
5097
2
1월 25
3308
0
11월 24
2658