I'm working under odoo v8, and i'm trying to pass the client_order_ref from sale orders to delivery orders. I could create a new field on delivery orders, called client_order_ref, but I can't pass the value of this field from sale order to delivery order, my custom field is always empty.
Code of my module:
from openerp.osv import fields, osv
class stock_picking(osv.osv):
_inherit = "stock.picking"
_columns = {
'client_order_ref': fields.char('Reference/Description', copy=True),
}class sale_order(osv.osv):
_inherit = "sale.order"def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None):
date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, context=context)
return {
'client_order_ref': order.client_order_ref, # I tried with 'blabla' instead order.client_order_ref and field is still empty
'name': line.name,
'origin': order.name,
'date_planned': date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': (line.product_uos and line.product_uos_qty) or line.product_uom_qty,
'product_uos': (line.product_uos and line.product_uos.id) or line.product_uom.id,
'company_id': order.company_id.id,
'group_id': group_id,
'invoice_state': (order.order_policy == 'picking') and '2binvoiced' or 'none',
'sale_line_id': line.id
}
The code of my view
<openerp>
<data>
<record id="client_order_ref_stock_view_picking_form" model="ir.ui.view">
<field name="name">client.order.ref.stock.view.picking.form</field>
<field name="model">stock.picking</field>
<field name="type">form</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<field name="origin" position="before">
<field name="client_order_ref"/>
</field>
</field>
</record>
</data>
</openerp>
I tried this with the same result, the custom flied still is empty: def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None): vals = super(sale_order, self)._prepare_order_line_procurement(cr, uid, order, line, group_i$ vals.update({'client_order_ref': 'blabla'}) return vals