Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5027 Lượt xem

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"
                                                 )
    }
   

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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)

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for your note to the code has helped.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
5645
0
thg 3 15
3663
0
thg 3 15
5203
1
thg 8 25
4628
0
thg 12 24
9719