Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
5015 Представления

I only find modules or answers for v6 and v8.
Can someone help me on v7?

 

class stock_picking_out(orm.Model):
    _inherit = 'stock.picking.out'  
    
    def _get_sale_client_order_ref(self, cr, uid, ids, field_name, arg, context={}):
        res = {}
        for session in self.browse(cr,uid,ids,context=context):
            if (session.sale_id):
                res[session.id] = session.sale_id.client_order_ref or False
        return res
           
    _columns = {
        "client_order_reference": fields.function(_get_sale_client_order_ref, type='char', size=64,
                                                 method=True, string="Sales Order Customer Reference"
                                                 )
    }
   

Аватар
Отменить
Лучший ответ

Instead of using a function field, you could try with related field
(http://odoo-new-api-guide-line.readthedocs.org/en/latest/fields.html#related-field)

class stock_picking_out(orm.Model):
    _inherit = 'stock.picking.out'  
    _columns = {
        "client_order_reference": fields.related('sale_id', 'client_order_ref', type='char', size=64,
                   string="Sales Order Customer Reference"
         )
    }

NOTE:  If you try to store a related field at stock.picking.out by adding parameter store=True, then you need to define this column at stock.picking also.(This is a special case only applicable for stock.picking, stock.picking.out and stock.picking.in)

Аватар
Отменить
Автор

Thanks for your note to the code has helped.

Related Posts Ответы Просмотры Активность
1
мар. 15
5638
0
мар. 15
3657
0
мар. 15
5190
1
авг. 25
4586
0
дек. 24
9712