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

I am trying to create one field that can be accesses thru many odoo models,  Here is the model code!


# -*- coding: utf-8 -*-

from odoo import models, fields

class code_adi(models.Model):

    _inherit=['res.currency','res.partner','product.product']

     _order='adi_code asc'

    adi_code = fields.Char(string='Code')

    _sql_constraints = [

         ('name_uniq_code', 'UNIQUE (adi_code)', 'Code must be unique.')

]

when i upgrade my module with an xml file that is empty it works for me, and i am able to see the added field in all inherited models, but once i start inheriting views and trying to access my field ('adi_code'), i get an error saying that my field does not exist. 

Thanks

아바타
취소
베스트 답변

This code is not right , You must inherit any class alone and add this field or write this field in new class and link these three classes with many2one relation with this new class

아바타
취소
베스트 답변

I'm not sure, but I guess you have to add attribute '_name'.

See this : http://www.odoo.com/documentation/9.0/reference/orm.html#inheritance-and-extension


Because class code_adi need to have own table when the class inherit from multiple classes.

아바타
취소
베스트 답변

I have no idea how to do this.

아바타
취소
관련 게시물 답글 화면 활동
3
4월 20
3938
4
9월 19
4914
5
6월 21
17852
1
11월 19
3651
3
12월 22
4523