تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3382 أدوات العرض

Hi,

Is it possible to add the sales order Customer Reference (client_order_ref) to the Deliver Products tree view on the Warehouse menu using the Edit TreeView option?

On the stock_move table there is a reference to the sales order line - sale_line_id and on the sales order line table there is a reference to the sales order header - order_id where the Customer reference is.  Is it possible to retrieve data from a parent table?

Thanks for any help.

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

Please try like this in your custom module:

in your py file:

from openerp.osv import fields, osv

class stock_move(osv.osv):
_inherit = 'stock.move'
def _get_customer_ref(self, cr, uid, ids,field_name, args, context=None):
sale_orders = self.pool.get('sale.order')
sale_order_line = self.pool.get('sale.order.line')
res = {}
for move in self.browse(cr, uid, ids, context=context):
sale_line = sale_order_line.browse(cr,uid, move.sale_line_id.id, context=None)
order = sale_orders.browse(cr,uid, sale_line.order_id.id, context=None)

res[move.id] = order.client_order_ref
return res
_columns={

'customer_ref':fields.function(_get_customer_ref, type="char", string="Customer Reference")
}

in your xml file:

<openerp>
<data>


<record id="view_move_tree_reception_picking_inherited" model="ir.ui.view">
<field name="name">stock.move.tree2.inherited</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree_reception_picking"/>
<field name="arch" type="xml">
<field name="origin" position="after">
<field name="customer_ref"/>
</field>
</field>
</record>

</data>
</openerp>

Hope this helps you.

الصورة الرمزية
إهمال

How would this change for Odoo 9, as the above does not work and gives the Error details: Field `Customer_ref` does not exist?

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مايو 22
3457
1
أغسطس 21
6534
2
فبراير 18
5820
0
فبراير 23
3668
1
فبراير 23
3069