首页 > 代码库 > odoo之页面跳转

odoo之页面跳转

<style>p { line-height: 120% } pre.western { font-family: "Courier New", monospace }</style>

击备注时,会由备注id带出他的内容 customer.requirement这是备注内容表

def sale_requirements_change(self, cr, uid, ids, requirements_id=None, context=None):
    result={}
    if requirements_id:
        require_ids=self.pool.get(‘customer.requirement‘).search(cr,uid,[(‘id‘,‘=‘,requirements_id)])
        obj=self.pool.get(‘customer.requirement‘).browse(cr,uid,require_ids,context=None)
        result[‘requirement_text‘]=obj.name
    else:
        result[‘requirement_text‘]=‘‘
return {‘value‘:result}

默认信息写法
_defaults={
    ‘product_qty‘:1,  
    ‘date_planned‘:fields.datetime.now,  交期
    ‘state‘:‘draft‘,
    ‘price‘:0,
}
# 创建发货单
def action_create_wave(self, cr, uid, ids, context=None):
    if not context:
       context = {}
    selfobj=self.browse(cr,uid,ids[0],context=context)
    pickobj=self.pool(‘stock.picking‘)
    pickids=pickobj.search(cr,uid,[(‘origin‘,‘like‘,selfobj.name)])

//销售订单里面的信息,默认带到发货单里面去 ctx={‘default_partner_id‘:selfobj.partner_id.id,‘default_bzfs_type‘:selfobj.packing_type,‘default_delvy_type‘:selfobj.send_invoice_type,‘default_picking_ids‘:pickids,‘default_origin‘:selfobj.name} #增加传递selfobj.send_invoice_type运送方式
mod_obj = self.pool.get(‘ir.model.data‘)
    form_res = mod_obj.get_object_reference(cr, uid, ‘stock_picking_wave‘, ‘view_picking_wave_form‘)
    form_id = form_res and form_res[1] or False
return {
        ‘name‘:u‘发货单新增,
        ‘type‘: ‘ir.actions.act_window‘,
        ‘view_type‘: ‘form‘,
        ‘view_mode‘: ‘form‘,
        ‘res_model‘: ‘stock.picking.wave‘,
        ‘views‘: [(form_id, ‘form‘)],
        ‘view_id‘:form_id,
        ‘context‘:ctx,
    }
#汇总金额的函数
def _get_subtotal(self, cr, uid, ids,  field_name, arg, context=None):
    res = {}
    for order in self.browse(cr, uid, ids, context=context):
        subtotal=0.0
for line in order.line_id:
            subtotal += line.total
        res[order.id] = subtotal
    return res

odoo之页面跳转