2017-05-03 1 views
2

Odoo 10Odoo는 다른 모듈의 필드를 검색합니다.

제품에서 판매 주문으로 필드를 복사하려고합니다. 제품의 필드는 default_code입니다. 판매 단위 모듈의 코드 복사가 이미 단가와 세금 등을 받고 있기 때문에 시도했지만 작동하지 않습니다.

from odoo import api, models, fields 

class myfieldsinsaleorder(models.Model): 

    _inherit = 'sale.order.line' 

    squaremtr = fields.Float("SQ Meter Required") 
    boxes = fields.Float("Suggested Boxes") 
    squarebox = fields.Char("Meters Per Box") 

    @api.onchange('product_id', 'default_code', 'price_unit', 'product_uom', 'product_uom_qty', 'tax_id') 
    def _onchange_discount(self): 
     self.discount = 0.0 
     self.squarebox = 'default_code' 

답변

1

필드 대신 문자열을 설정하려면 다음을 시도하십시오.

self.squarebox = self.product_id.default_code 
1

는이를 사용한다 무엇 필드의 값을 default_code 텍스트를 삽입하는 것이 아니라 지금하고 있습니다 :

self.squarebox = self.product_id.default_code 

이 수행 할 때

self.squarebox = 'default_code' 

그 모양은 다음과 같습니다. self.squarebox = 'string not a value of the field'

관련 문제