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

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
5643
0
бер. 15
3662
0
бер. 15
5202
1
серп. 25
4617
0
груд. 24
9717