Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
4308 Переглядів

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)

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лип. 23
2186
2
бер. 15
9489
1
бер. 15
3957
2
лют. 25
1031
0
трав. 24
1387