二、动作按钮里面也可以由字段判断:
def action_select_sale_order_line(self,cr,uid,ids,date_begin,date_end,context=None):
res={}
record=[]
seq=1
selfobj=self.browse(cr,uid,ids,context)
# date_begin=selfobj.date_begin
# date_end=selfobj.date_end
if date_begin and date_end:
if date_begin<date_end:
sql="select id,product_id,partner_id,product_qty,date_planned,COALESCE(memo,'') memo from sale_origin_line where date_planned>='%s' and date_planned<='%s'"%(date_begin,date_end)
cr.execute(sql)
dict=cr.dictfetchall()
if dict:
for line in dict:
record.append({'sequence':seq,'partner_id':line['partner_id'],'sale_order_ids':line['id'],'product_id':line['product_id'],'qty':line['product_qty'],'date_planned':line['date_planned'],'lnote':line['memo']})
seq+=1
return {'value':{'lines':record}}
一、一般的按钮动作的写法:
####整张外部订单取消,对应取消未发货的内部销售订单
def action_cancel_sale_order(self,cr,uid,ids,context=None):
assert len(ids)==1
sale_origin_obj=self.browse(cr,uid,ids,context)
a=sale_origin_obj.name
sql="select id from stock_picking where order_name='%s'"%(str(a))
cr.execute(sql)
dict=cr.fetchall()
count=len(dict)
if count >0:
raise osv.except_osv((u'警告!'),(u'已存在发货单不可取消,请点完结'))
sale_origin_obj.state='cancel'
for line in sale_origin_obj.line_id:
line.state='cancel'