2016-11-23 3 views
0

(10)이 product.product 모델을 상속 Odoo에서 필드 정의를 무시하고 계산 필드로 설정하기 위해 기존의 standard_price 필드 정의를 대체하지 않습니다상속 모델은 내가 다음 코드 Odoo 10 모듈을 만든

class ProductProduct(models.Model): 
    _inherit = 'product.product' 

    standard_price = fields.Float(
     'Cost', company_dependent=True, 
     digits=dp.get_precision('Product Price'), 
     groups="base.group_user", 
     compute='_compute_set_standard_price') 

    def _compute_set_standard_price(self): 
     ..... 
     # calculation for the value 
     ..... 
     self.standard_price = 121 #this value is an example 

필드 정의를 계산 필드로 대체했지만 standard_price 필드가 0으로 설정되고 계산 방법을 트리거하지 않기 때문에 standard_price이 121로 설정됩니다. Odoo v8의이 코드는 정상적으로 작동합니다.

상속 된 모델의 기존 필드 difinition을 재정의하는 방법은 무엇입니까?

답변

0

장식 자 api.depends을 사용하지 않았습니다. odoo 레코드를 생성하거나 새로운 값에 따라 계산 된 필드를 재 계산하기 위해 사전에 전달되는 분야에 따라 계산 된 필드를 확인하는 레코드를 갱신

@api.depends('field_1', 'field_2') 
def _compute_set_standard_price(self): 
     ..... 
     # calculation for the value 
     ..... 
     self.standard_price = 121 #this value is an example 

. 트리거 odoo가없는 은 값을 계산하지 않습니다