换货 的实现
-
客户要求退货后直接生成退回单,在OpenERP7.0上做了简单的开发:
<record id="ssf_view_stock_return_picking_form" model="ir.ui.view">
<field name="name">ssf.ssf_view_stock_return_picking_form</field>
<field name="model">stock.return.picking</field>
<field name="inherit_id" ref="stock.view_stock_return_picking_form"/>
<field name="arch" type="xml">
<button string="Cancel" position="after">
<button name="create_change" string="换货" type="object" class="oe_highlight"/>
</button>
</field>
</record>
class stock_return_picking(osv.osv_memory):
_inherit = 'stock.return.picking'
def create_change(self, cr, uid, ids, context=None):
res = self.create_returns(cr, uid, ids, context=context)
# it is build like this:
# 'domain': "[('id', 'in', ["+str(new_picking)+"])]",
new_id = int(eval(res['domain'])[0][2][0])
ctx = context.copy()
ctx.update({'active_id':new_id})
change = self.create_returns(cr, uid, ids, context=ctx)
return res