• 项目方法汇总


    带头信息到  明细

     1    def record_line_date(self, cr, uid, ids,date_now,line_id,context=None):
     2         res={}
     3         number=1
     4         if len(ids)>0:
     5             record=[]
     6             for line in line_order:
     7                 if number==1:
     8                     for move_ids in line[2]:
     9                         record.append((1,move_ids,{'date_now':date_now}))
    10                 else:
    11                     if len(line[2])>0:
    12                         line[2]['date_now']=date_now
    13                         record.append(line)
    14                 number+=1
    15             res['line_id']=record
    16         else:
    17             for line in line_id:
    18                 if number>1:
    19                     if len(line[2])>0:
    20                         line[2]['date_now']=date_now
    21                 number+=1
    22             if number>2:
    23                 res['line_id']=line_id
    24         return {'value':res}
     1  def get_dname_dh(self, cr, uid,ids,zdannum,line_id,context=None):  #(通过单头字段,查出数据,加到明细中,可以带多条)
     2             result={}
     3             try:
     4                dayangobj=self.pool.get('prodtion.lc')
     5                dayang_obj=dayangobj.browse(cr,uid,[zdannum],context=None)
     6                b=dayang_obj.fversion
     7                c=dayang_obj.lc_type
     8                if b==False:
     9                    if c==1  or c==3:
    10                        v=str(dayang_obj.name)
    11                        p=v[0:11]
    12                        q=p+'%'
    13                        sql="select t0.id as dname ,t0.uom ,t0.custorm_num,t3.id as machine,t0.market_name,t0.zheshi_ver,t0.price,t0.outquant,(t0.price*t0.sqty) as total,t0.width,t0.product_type,t0.custquire from prodtion_lc t0 LEFT JOIN unit t1 on t0.uom=t1.id LEFT JOIN res_partner t2 on t2.id=t0.custorm_num LEFT JOIN machine_model t3  on t3.id=t0.machine  where t0.fversion='f' and lc_type!=2 and t0.outquant>0  and t0.name like '%s' "%(q)
    14                        cr.execute(sql)
    15                        dict=cr.fetchall()
    16                        order_line_id=line_id
    17                        if dict in order_line_id:
    18                            raise osv.except_osv((u'警告!'),(u'有重复数据'))
    19                        for i in range(len(dict)):
    20                                order_line_id.append({
    21                                             'dannum':dict[i][0],
    22                                             'uom':dict[i][1],
    23                                             'cust_name':dict[i][2],
    24                                             'machine':dict[i][3],
    25                                             'product_type':dict[i][4],
    26                                             'zheshi_ver':dict[i][5],
    27                                             'price':dict[i][6],
    28                                             'sin_num':dict[i][7],
    29                                             'amount':dict[i][8],
    30                                             'width':dict[i][9],
    31                                              'sbiao_type':dict[i][10],
    32                                              'beici':dict[i][11],
    33                                             'kuwei':'成品仓',
    34                                                       })
    35                                result['line_id']=order_line_id
    36                    elif c==2:
    37                        v=str(dayang_obj.name)
    38                        p=v[0:11]
    39                        q=p+'%'
    40                        sql="select t0.id as dname ,t0.uom ,t0.custorm_num,t3.id as machine,t0.market_name,t4.name,t0.price,t0.outquant,(t0.price*t0.sqty) as total,t0.width,t0.product_type ,t0.custquire from prodtion_lc t0 LEFT JOIN unit t1 on t0.uom=t1.id LEFT JOIN res_partner t2 on t2.id=t0.custorm_num LEFT JOIN machine_model t3  on t3.id=t0.machine LEFT join create_versionzhi t4 on t0.zheshi_zhiv=t4.id  where t0.fversion='f' and lc_type=2  and t0.outquant>0  and t0.name like '%s' "%(q)
    41                        cr.execute(sql)
    42                        dict=cr.fetchall()
    43                        order_line_id=line_id
    44                        if dict in order_line_id:
    45                            raise osv.except_osv((u'警告!'),(u'有重复数据'))
    46                        for i in range(len(dict)):
    47                                order_line_id.append({
    48                                             'dannum':dict[i][0],
    49                                             'uom':dict[i][1],
    50                                             'cust_name':dict[i][2],
    51                                             'machine':dict[i][3],
    52                                             'product_type':dict[i][4],
    53                                             'zheshi_ver':dict[i][5],
    54                                             'price':dict[i][6],
    55                                             'sin_num':dict[i][7],
    56                                             'amount':dict[i][8],
    57                                            'width':dict[i][9],
    58                                            'sbiao_type':dict[i][10],
    59                                            'beici':dict[i][11],
    60                                             'kuwei':'成品仓',
    61                                                       })
    62                                result['line_id']=order_line_id
    63                elif b==True:
    64                    sql2="select t0.id, t1.ftvernum,t1.fmarket_mc,t1.foutquant,t1.fprice,(t1.fsqty*t1.fprice)as toljin,t1.fuom,t0.machine,t0.custorm_num,t0.width,t0.product_type,t1.fcustquire from prodtion_lc  t0 lEFT JOIN  fen_vernum  t1 on t0.id=t1.fname where t1.foutquant>0 and t0.id='%d'"%(zdannum)
    65                    cr.execute(sql2)
    66                    dict=cr.fetchall()
    67                    order2_line_id=line_id
    68                    for i in range(len(dict)):
    69                            order2_line_id.append({
    70                                         'dannum':dict[i][0],
    71                                         'zheshi_ver':dict[i][1],
    72                                         'product_type':dict[i][2],
    73                                         'sin_num':dict[i][3],
    74                                         'price':dict[i][4],
    75                                         'amount':dict[i][5],
    76                                         'uom':dict[i][6],
    77                                         'machine':dict[i][7],
    78                                         'cust_name':dict[i][8],
    79                                         'width':dict[i][9],
    80                                        'sbiao_type':dict[i][10],
    81                                         'beici':dict[i][11],
    82                                        'kuwei':'成品仓',
    83                                                   })
    84                            result['line_id']=order2_line_id
    85                return {'value':result}
    86             except Exception, ex:
    87                 return False
    #单号生成
    
     def get_no(self,cr,uid,ids,context=None):
            res={}
            sql='''select case when dh<10 then dt||'0'||dh else (dt||dh) end dname from( select to_char(now(),'yyyymmdd') dt,
                        case when to_char(now(),'yyyymmdd')='170401' then count(p)+2 else count(p)+1 end  dh
                         from (select count(p) from (SELECT count(pname) as p,pname  from(SELECT substring(name from 0 for 13) pname
                        FROM profin_application
                        where to_char(create_date,'yyyymmdd')=to_char(now(),'yyyymmdd')) aa
                        GROUP BY pname) as q) as p) w'''
            cr.execute(sql)
            dict=cr.fetchall()
            if dict : #如果是第一张单据时,此时查询无结果,那么查询的判断的结果是什么? dict:[]
               res['name']='AC'+dict[0][0]
            else:
               newname2='AC'+str(datetime.strptime(fields.date.today(), "%Y-%m-%d").date()).replace('-','')+'01'
               res['name']=newname2
            return {'value':res}
  • 相关阅读:
    mysql-5-aggregation
    mysql-4-functions
    mysql-3-orderby
    技术之心 | 云信和TA们携手打响防疫战
    疫情下的传统商企自救|4个Tips搭建销量过亿直播间
    那些2019年会爆发的泛娱乐黑科技风口
    流量难、获客难、增长难?增长黑客思维“解救”B端业务
    【翻译】Facebook全面推出Watch Party,可多人线上同看直播视频
    深入浅出聊一聊Docker
    C++写日志方法调试
  • 原文地址:https://www.cnblogs.com/1314520xh/p/8280857.html
Copyright © 2020-2023  润新知