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

I've some problems to address fields.related correctly.

class custom_purchase_order(osv.Model):

_inherit = 'purchase.order'
_columns = {
'x_custom_field_p_o': fields.char('Custom Field', size=64, readonly=False, ondelete='set null', select=True),
    }
custom_purchase_order()

 


class custom_stock_picking_in(osv.Model):
_inherit = 'stock.picking.in'
_columns = {

    'x_custom_field_s_p_i': fields.related('purchase_id', 'x_custom_field_p_o', type='char', relation='purchase.order', readonly=True, store=True, string='Custom Field from Purchase Order'),
    }
custom_stock_picking_in()

 

I only want to show the value of the custom_field_p_o in Incoming Shipments. (It should match to the Purchase ID / Order ID)

I don't get it work.

ERROR: value = value[field] or False TypeError: 'int' object has no attribute '__getitem__'

아바타
취소

Hi,
You can watch following video to know about related field in Odoo.
https://youtu.be/A-0uQnJr3QA

베스트 답변

Code will be:

x_custom_field_s_p_i = fields.Char(string='Field Name', related='purchase_id.x_custom_field_p_o', readonly=True)

아바타
취소
관련 게시물 답글 화면 활동
1
7월 23
2227
2
3월 15
9530
1
3월 15
3996
2
2월 25
1061
0
5월 24
1403