Exemple #1
0
def dl_bcn(dl_obj,append_domain = []):
    filename = u'Báo cáo ngày_%s' %fields.Date.from_string(dl_obj.date).strftime('%d_%m_%Y')
    name = "%s%s" % (filename, '.xls')
    set_cols_width = [4,21,8,40,20,40,30,30]
    set_cols_width = map(get_width,set_cols_width)
    font_height = dl_obj.font_height
    center_style = xlwt.easyxf(generate_easyxf(height=font_height,vert = 'center',horiz='center'))
    bold_center_style = xlwt.easyxf(generate_easyxf(height=font_height, vert = 'center',horiz = 'center',bold=True))
    fixups =[  
                 ('trung_tam1',{'range':[0,0,0,3],'val':u'TRUNG TÂM HẠ TẦNG MẠNG MIỀN NAM', 'style':xlwt.easyxf(generate_easyxf(bold=True,height=12, vert = 'center',horiz = 'center'))}),
                 ('trung_tam2',{'range':[1,1,0,3],'val':u'ĐÀI VIỄN THÔNG HCM', 'style':xlwt.easyxf(generate_easyxf(bold=True,underline=True,height=12, vert = 'center',horiz = 'center'))}),
                 ('chxhcnvn',{'range':[0,0,4,7],'val':u'CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM', 'style':xlwt.easyxf(generate_easyxf(bold=True,height=12, vert = 'center',horiz = 'center'))}),
                 ('dltdhp',{'range':[1,1,4,7],'val':u'Độc lập - Tự do - Hạnh Phúc', 'style':xlwt.easyxf(generate_easyxf(bold=True,underline=True,height=12, vert = 'center',horiz = 'center'))}),
                 ('bbg',{'range':[3,3,0,7],'val':u'BÁO CÁO THÔNG TIN', 'style':bold_center_18_style,'height':1119,'off_set':1}),
                 ('hom_nay',{'range':[4,4,0,7],'val':None, 'val_func': hom_nay_,'style':center_style }),
                 ('table',{'range':['auto', 0],'val':None,'func':table_bcn_ ,'offset':3 }),
                 ('thuebao_title',{'range':['auto', 0],'val':None,'val':u'C. TÌNH HÌNH THUÊ BAO CẬP NHẬT MẠNG DI ĐỘNG (lúc 19h00):','style':bold_style,'offset':1 }),
                 ('thuebaotable',{'range':['auto', 0],'val':None,'func':thuebaotable_ ,'offset':2}),
                 ('pho_dai_vthcm',{'range':['auto', 'auto',1,3],'val':u'Phó đài VT HCM','style':bold_center_style}),
                 ('tphcm',{'range':['auto', 'auto', 7,9],'offset':0, 'val':u'Tp. Hồ Chí Minh, Ngày %s'%Convert_date_orm_to_str(dl_obj.date),'style':bold_center_style}),
                 ('ten_pho_dai_vthcm',{'range':['auto', 'auto',1,3],'offset':5,'val':u'Nguyễn Văn Xuân','style':bold_center_style}),
                 ('ten_nguoi_bc',{'range':['auto', 'auto',7,9],'offset':0,'val':dl_obj.env.user.name,'style':bold_center_style}),
                 ]
    wb = write_all_row(fixups,dl_obj,set_cols_width)
        
    return wb,name
Exemple #2
0
def table_bcn_(worksheet,f_name,fixups,needdata,row_index,dl_obj, **kargs):
#     cates = kargs ['cates'] 
    
    font_height = dl_obj.font_height
    bold_style = xlwt.easyxf(generate_easyxf(height=font_height,bold=True)) 
    bold_italic_style = xlwt.easyxf(generate_easyxf( bold=True, height=font_height, italic=True))
    Export_Para_cvi = generate_Export_Para_cvi(dl_obj)
    Export_Para_cvi_copy1 = deepcopy(Export_Para_cvi)
    is_show_loai_record = dl_obj.env['ir.config_parameter'].sudo().get_param('dai_tgg.' + 'is_show_loai_record')
    Export_Para_cvi_copy1['FIELDNAME_FIELDATTR']['loai_record']['skip_field'] = not is_show_loai_record
    Export_Para_cvi_copy1['FIELDNAME_FIELDATTR']['categ_id']['skip_field'] = not is_show_loai_record
    nhoms = request.env['product.category'].search([('stt_for_report','!=',False)],order='stt_for_report asc')
    row_index_begin = row_index
    dl_model_para = {}
    for loai_record,attrs in LOAI_REC_.items():
            dl_model_para ['loai_record'] = loai_record
            noi_dung_1= attrs['noi_dung']
            row_index +=1
            write_before_title(
                {'worksheet' :worksheet,
                'row_index_before_title' :row_index,
                'col_index_before_title' :0,
                'noi_dung':noi_dung_1,
                'style':bold_style}
                ) # ghi A. sự cố , B. công việc
            row_index +=2
            if loai_record ==u'Công Việc':
                domain_loai_record = [('loai_record','in',[u'Công Việc',u'Sự Vụ']),('loai_cvi','!=',u'Chia Điểm Con')]
            else:
                domain_loai_record = [('loai_record','=',loai_record)]
            for cate in nhoms:# categ_id # ghi các đầu nhóm 1. IP , 2TRD
                Export_Para_cvi_copy = deepcopy(Export_Para_cvi_copy1)
                domain =[('categ_id','=',cate.id),(('is_bc','=',True))] + domain_loai_record
                n_row = download_model(dl_obj,
                             Export_Para=Export_Para_cvi_copy,
                             append_domain=domain,
                             workbook=None,
                             worksheet=worksheet,
                             ROW_TITLE = row_index ,
                             return_more_thing_for_bcn = True,
                            write_before_title = write_before_title,
                            
                            kargs_write_before_title = {'worksheet' :worksheet,
                                                                        'row_index_before_title' :row_index ,
                                                                        'col_index_before_title' :0,
                                                                        'noi_dung':u'%s/%s'%(cate.stt_for_report,cate.name),
                                                                        'style':bold_italic_style},
                             
                             dl_model_para =dl_model_para,
                             no_gray = True,
                             OFFSET_COLUMN = 0,
                             write_title_even_not_recs_for_title=True,
                             is_set_width = False,
                             
                                                               
                             )
                row_index += n_row
    return row_index- row_index_begin + 1
Exemple #3
0
def generate_Export_Para_cvi(dl_obj):
    font_height = dl_obj.font_height
    center_border_style = xlwt.easyxf(
        generate_easyxf(height=font_height,
                        borders='left thin, right thin, top thin, bottom thin',
                        vert='center',
                        horiz='center'))
    FIELDNAME_FIELDATTR_cvi = OrderedDict([
        ('stt_not_model', {
            'style': center_border_style,
            'is_not_model_field': True,
            'string': u'STT',
            'func': stt_
        }),
        ('department_id', {}),
        ('loai_record', {
            'style': center_border_style
        }),
        ('categ_id', {}),
        ('thiet_bi_id', {}),
        ('tvcv_id', {
            'string':
            lambda dl_model_para: u'Loại sự cố'
            if dl_model_para['loai_record'] == u'Sự Cố' else u'Loại CV/Sự vụ'
        }),
        ('noi_dung', {}),
        ('nguyen_nhan', {
            'string':
            u'Nguyên nhân',
            'skip_field':
            lambda dl_model_para: dl_model_para['loai_record'] != u'Sự Cố'
        }),
        ('gio_bat_dau', {
            'style':
            center_border_style,
            'func':
            lambda val, n: convert_odoo_datetime_to_vn_str(
                val, format='%d/%m/%Y %H:%M:%S')
        }),
        ('gio_ket_thuc', {
            'style':
            center_border_style,
            'func':
            lambda val, n: convert_odoo_datetime_to_vn_str(
                val, format='%d/%m/%Y %H:%M:%S')
        }),
    ])
    Export_Para_cvi = {
        'exported_model': 'cvi',
        'FIELDNAME_FIELDATTR': FIELDNAME_FIELDATTR_cvi,
        'gen_domain': gen_domain_cvi,
        'search_para': {
            'order': 'loai_record asc'
        },  #desc
    }
    return Export_Para_cvi
Exemple #4
0
def download_model_new_ml(dl_obj, Export_Para=None,workbook=None,
                          append_domain=None,sheet_name=None,worksheet=None,
                          row_index=15,
                          font_height=12):
    exported_model= Export_Para['exported_model']
    FIELDNAME_FIELDATTR= Export_Para['FIELDNAME_FIELDATTR']
    FIELDNAME_FIELDATTR = OrderedDict(FIELDNAME_FIELDATTR)
    gen_domain= Export_Para.get('gen_domain')
    if worksheet ==None:
        if workbook==None:
            workbook = xlwt.Workbook()
        sheet_name =  u'Sheet 1' if sheet_name ==None else sheet_name
        worksheet = workbook.add_sheet(sheet_name,cell_overwrite_ok=True)
        worksheet.header_str = 'not thing'
        worksheet.footer_str = 'not thing'

    needdata = {'a_instance_dict':{'move_line_ids.stt_not_model':{'val':0}}}
    needdata['dl_obj'] = dl_obj
    if gen_domain:
        domain = gen_domain(dl_obj)
    else:
        domain = []
    if append_domain:
        domain.extend(append_domain)  
    order = Export_Para.get('search_para',{})
    print ('order',order)
    all_objs = request.env[exported_model].search(domain,**order)
    model_fields = request.env[exported_model]._fields
    
    add_title(worksheet, FIELDNAME_FIELDATTR, 
              model_fields, ROW_TITLE=row_index,
               offset_column=0,
               is_set_width = False,
               font_height=font_height
               )
    nrow = 0
    row_index +=1
    wrap_center_vert_border_style = xlwt.easyxf(generate_easyxf(height=font_height,vert = 'center',borders='left thin, right thin, top thin, bottom thin',align_wrap=True))
    for move in all_objs:#request.env['cvi'].search([]):
        rowspan = len(move.move_line_ids)
        for ml_index, ml in enumerate(move.move_line_ids):
            nrow +=1
            add_1_row_new_ml(worksheet, move , FIELDNAME_FIELDATTR, 
                             row_index, offset_column=0,
                             needdata=needdata,
                             save_ndata=True, ml=ml,
                             ml_index=ml_index,
                             rowspan=rowspan,
                             font_height=font_height,
                             wrap_center_vert_border_style = wrap_center_vert_border_style

                             )
            row_index +=1
    return nrow
Exemple #5
0
def dl_p3_per_user(dl_obj,user_id,wb = None,tram=None):
    font_height =dl_obj.font_height
    bold_style = xlwt.easyxf(generate_easyxf(height=font_height,bold=True))
    center_style = xlwt.easyxf(generate_easyxf(height=font_height,vert = 'center',horiz='center'))
    def sum_(worksheet,f_name,fixups,needdata,row_index,dl_obj, **kargs):
        begin_row = needdata['instance_dict']['table']['begin_row'] +2
        end_row = needdata['instance_dict']['table']['end_row']
        if end_row > begin_row:
            worksheet.write(row_index, 4, xlwt.Formula('SUM(%s%s:%s%s)'%('P',begin_row + 1,'P',end_row+1)),center_style)
        return 1# 1 row
    def table_detail_p3_(worksheet,f_name,fixups,needdata,row_index,dl_obj, **kargs):
        Export_Para_cvi_copy = deepcopy(Export_Para_cvi)
        n_row = download_model(dl_obj,
                     Export_Para=Export_Para_cvi_copy,
                     append_domain=kargs['append_domain_user_id'],
                     workbook=None,
                     worksheet=worksheet,
                     ROW_TITLE = row_index + 1,
                     return_more_thing_for_bcn = True,
                     no_gray = True,
                     OFFSET_COLUMN = 1,
                                                   
                 )
        return n_row

    fixups =[  
                 ('trung_tam1',{'range':[0,0,0,3],'val':u'TRUNG TÂM HẠ TẦNG MẠNG MIỀN NAM', 'style':xlwt.easyxf(generate_easyxf(bold=True,height=11, vert = 'center',horiz = 'center'))}),
                 ('trung_tam2',{'range':[1,1,0,3],'val':u'ĐÀI VIỄN THÔNG HCM', 'style':xlwt.easyxf(generate_easyxf(bold=True,underline=True,height=12, vert = 'center',horiz = 'center'))}),
                 ('diem_tong_nhan_vien_cham_title',{'range':[5, 3],'val':u'Điểm Tổng Nhân Viên Chấm'}),
                 ('ho_ten_title',{'range':[3, 3],'val':u'Họ Tên','style':bold_style}),
                 ('ho_ten',{'range':[3, 4],'val':user_id.name}),
                 ('tram_tilte',{'range':[4, 3],'val':u'Trạm'}),
                 ('tram',{'range':[4, 4],'val':tram,'style':bold_style}),
                 ('table',{'range':[9, 0],'val':None,'func':table_detail_p3_ ,'offset':3 ,'kargs':{'append_domain_user_id':[('user_id','=',user_id.id)]}}),
                 ('sum',{'range':[5, 4],'func':sum_ })
                 ] 
    wb = write_all_row(fixups,dl_obj,None,wb = wb,ws_name=user_id.name,font_height=font_height )
    return wb
Exemple #6
0
 def ong_ba_(ws,f_name,fixups,needdata,row,dl_obj,source_member_ids='source_member_ids'):
     vert_center_style = xlwt.easyxf(generate_easyxf(vert = 'center',height=font_height_another))
     nrow = 0
     for c,i in enumerate(getattr(dl_obj,source_member_ids)):
         nrow +=1
         ws.write_merge(row + c,row + c,1,2,u'Ông/bà: %s'%i.name,vert_center_style)
         chuc_vu_don_vis =[]
         if i.job_id.name:
             chuc_vu_don_vis.append(i.job_id.name)
         if i.parent_id.name:
             chuc_vu_don_vis.append(i.parent_id.name)
         if chuc_vu_don_vis: 
             ws.write_merge(row + c,row + c,3,7,u'C/v: %s'%(u' '.join(chuc_vu_don_vis)),vert_center_style)
     return nrow
Exemple #7
0
def download_ml_for_bb(dl_obj,workbook=None,
                       append_domain=None,
                       sheet_name=None,
                       worksheet=None,
                       row_index=0,
                       IS_SET_TT_COL=False,
                       all_tot_and_ghom_all_tot=False,
                       font_height=12):
    center_border_style = xlwt.easyxf(generate_easyxf(height=font_height,borders='left thin, right thin, top thin, bottom thin',vert = 'center',horiz = 'center'))
    FIELDNAME_FIELDATTR_ML = [
         ('move_line_ids.stt_not_model',{'is_not_model_field':True,'string':u'STT', 'func':stt_ml_,'is_same':True,
                                         'is_use_kargs_co_san':True,'style':center_border_style }),#'is_same':False 
         ('product_id',{'func':lambda v,n,m,ml: v.name,'string':u'Tên vật tư' }),
         ('product_id_pn',{'transfer_field':'product_id','func':lambda v,n,m,ml: v.pn,'string':u'Mã vật tư'}),
         ('quantity_done',{'is_same':is_same_,'func':quantity_done_,'string':u'S/L','style':center_border_style}),
         ('product_uom',{'func':lambda v,n,m,ml: v.name,'string':u'ĐVT'}),
         ('move_line_ids.lot_id',{'func':lambda v,n,m,ml: v.name,'string':u'Serial Number'}),
         ('move_line_ids.tinh_trang',{'string':u'T/T','func':tinh_trang_, 'skip_field':not IS_SET_TT_COL or  all_tot_and_ghom_all_tot    }),
         ('move_line_ids.ghi_chu',{'string':u'Ghi chú',
                                   'is_same':is_same_ghi_chu_,
                                   'kargs_for_is_same':{'all_tot':all_tot_and_ghom_all_tot, 'IS_SET_TT_COL':IS_SET_TT_COL},
                                   'func':ghi_chu_,
                                   'kargs':{'empty':dl_obj.empty_ghi_chu_in_bb,
                                            'all_tot':all_tot_and_ghom_all_tot,
                                             'IS_SET_TT_COL':IS_SET_TT_COL},
                                             }),
        ]
    Export_Para_ml = {
        'exported_model':'stock.move',
        'FIELDNAME_FIELDATTR':FIELDNAME_FIELDATTR_ML,
        'gen_domain':gen_domain_sml,
        'search_para':{'order': 'id asc'},#desc
        }
    
    return download_model_new_ml(dl_obj, Export_Para=Export_Para_ml, append_domain=append_domain,
                                 workbook=workbook,
                                 sheet_name=sheet_name,
                                 worksheet=worksheet,
                                 row_index=row_index,
                                 font_height = font_height) + 1
Exemple #8
0
def write_xl_bb(dl_obj):
    font_height_another = dl_obj.font_height_another
    wrap_normal_style = xlwt.easyxf(generate_easyxf(height=font_height_another,align_wrap=True))  
    bold_center_style = xlwt.easyxf(generate_easyxf(height=font_height_another, vert = 'center',horiz = 'center',bold=True))
    bold_center_18_style = xlwt.easyxf(generate_easyxf(bold=True,height=18 + (font_height_another-12) , vert = 'center',horiz = 'center'))
    font_height_table =dl_obj.font_height

    def ong_ba_(ws,f_name,fixups,needdata,row,dl_obj,source_member_ids='source_member_ids'):
        vert_center_style = xlwt.easyxf(generate_easyxf(vert = 'center',height=font_height_another))
        nrow = 0
        for c,i in enumerate(getattr(dl_obj,source_member_ids)):
            nrow +=1
            ws.write_merge(row + c,row + c,1,2,u'Ông/bà: %s'%i.name,vert_center_style)
            chuc_vu_don_vis =[]
            if i.job_id.name:
                chuc_vu_don_vis.append(i.job_id.name)
            if i.parent_id.name:
                chuc_vu_don_vis.append(i.parent_id.name)
            if chuc_vu_don_vis: 
                ws.write_merge(row + c,row + c,3,7,u'C/v: %s'%(u' '.join(chuc_vu_don_vis)),vert_center_style)
        return nrow

    all_tot_and_ghom_all_tot = set(dl_obj.move_line_ids.mapped('tinh_trang')) ==set(['tot']) and   dl_obj.is_ghom_tot
    IS_SET_TT_COL = dl_obj.is_set_tt_col
#     IS_SET_TT_COL and not all_tot_and_ghom_all_tot

#     cols = []
#     set_cols_width = ['sl', 'pr', 'pn', 'sl', 'dvt', 'sn', 'tt','gc']
    if  IS_SET_TT_COL and not all_tot_and_ghom_all_tot :
        set_cols_width = [4,21,16,4,7,16,8,14]
    else:
        set_cols_width = [4,21,16,4,7,19,19,0]
    set_cols_width = map(get_width,set_cols_width)
    
    fixups =[  
                    ('trung_tam1',{'range':[0,0,0,2],'val':u'TRUNG TÂM HẠ TẦNG MẠNG MIỀN NAM', 'style':xlwt.easyxf(generate_easyxf(bold=True,height=11, vert = 'center',horiz = 'center'))}),
                    ('trung_tam2',{'range':[1,1,0,2],'val':u'ĐÀI VIỄN THÔNG HCM', 'style':xlwt.easyxf(generate_easyxf(bold=True,underline=True,height=12, vert = 'center',horiz = 'center'))}),
                    ('chxhcnvn',{'range':[0,0,3,7],'val':u'CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM', 'style':xlwt.easyxf(generate_easyxf(bold=True,height=12, vert = 'center',horiz = 'center'))}),
                    ('dltdhp',{'range':[1,1,3,7],'val':u'Độc lập - Tự do - Hạnh Phúc', 'style':xlwt.easyxf(generate_easyxf(bold=True,underline=True,height=12, vert = 'center',horiz = 'center'))}),
                    ('so',{'range':[2,2,0,2],'val':u'Số: %s/%s-%s'%(dl_obj.stt_trong_bien_ban_in,dl_obj.ban_giao_or_nghiem_thu,dl_obj.department_id.short_name), 'style':xlwt.easyxf(generate_easyxf(height=12, vert = 'center',horiz = 'center'))}),
                    ('bbg',{'range':[3,3,0,7],'val':u'BIÊN BẢN BÀN GIAO VẬT TƯ', 'style':bold_center_18_style,'height':1119,'off_set':1}),
                    ('to_trinh',{'range':[5,5,0,7],'val':None, 'val_func': to_trinh_ ,'height':600,'style':wrap_normal_style}),
                    ('hom_nay',{'range':[6,0],'val':None, 'val_func': hom_nay_ }),
#                     ('ddbg',{'range':[8,0],'val':u'Đại diện bên giao%s'%(' (%s)'%dl_obj.location_id.partner_id_of_stock_for_report.name if dl_obj.location_id.partner_id_of_stock_for_report  else '' )}),
                    ('ddbg',{'range':[8,0],'val':None, 'val_func':ddbg_}),
                    ('ong_ba',{'range':['auto', 0],'val':None, 'func':ong_ba_}),
#                     ('ddbn',{'range':['auto',0],'val':u'Đại diện bên nhận%s'%(' (%s)'%dl_obj.location_dest_id.partner_id_of_stock_for_report.name if dl_obj.location_dest_id.partner_id_of_stock_for_report  else '' ),'offset':2}),
                    ('ddbn',{'range':['auto',0],'val':None, 'val_func':ddbg_,'val_kargs':{'location_id':'location_dest_id','doi_tac_giao_id':'doi_tac_nhan_id'}}),
                    
                    ('ong_ba2',{'range':['auto', 0], 'val':None,  'func':ong_ba_,'kargs':{'source_member_ids':'dest_member_ids'}}),
                    ('ly_do',{'range': ['auto', 'auto', 0,7],'val':None,'val_func':ly_do_,}),
                    ('bg',{'range': ['auto', 0],'val':u'Chúng tôi đã tiến hành bàn giao vật tư bên dưới.'}),
                    
                    
                    
                    ('table',{'range':['auto', 0],'val':None,'func':table_bien_ban_ ,'offset':2 ,
                              'kargs': {'IS_SET_TT_COL':IS_SET_TT_COL,'all_tot_and_ghom_all_tot':all_tot_and_ghom_all_tot,'font_height':font_height_table}}),
                    
                    
                    
                    ('tinh_trang_vat_tu',{'range': ['auto', 0],'val':None,'val_func':tinh_trang_vat_tu_,'offset':2}),
                    ('so_ban_in',{'range': ['auto', 0],'val':u'Biên bản được lập thành %s bản. Bên giao giữ %s bản. Bên nhận giữ %s bản'%(dl_obj.so_ban_in,dl_obj.ben_giao_giu,dl_obj.ben_nhan_giu),'offset':1}),
                  
                    ('dai_dien_ben_giao',{'range': ['auto','auto',0,2],'val':u'ĐẠI DIỆN BÊN GIAO','offset':3, 'style':bold_center_style}),
                    ('dai_dien_ben_nhan',{'range': ['auto','auto',4,7],'val':u'ĐẠI DIỆN BÊN NHẬN','offset':0, 'style':bold_center_style}),
                    
                    ('job_ben_giao',{'range': ['auto','auto',0,2],'val':None,'offset':1,'val_func':ky_ten_cac_ben_,'val_kargs':{'type':'job_id.name','empty_force':True},'style':center_style}),
                    ('job_ben_nhan',{'range': ['auto','auto',4,7],'val':None,'offset':0,'val_func':ky_ten_cac_ben_, 'val_kargs':{'source_member_ids':'dest_member_ids','type':'job_id.name','empty_force':True},'style':center_style}),
                    ('ky_ten_ben_giao',{'range': ['auto','auto',0,2],'val':None,'offset':5,'val_func':ky_ten_cac_ben_, 'style':bold_center_style}),
                    ('ky_ten_ben_nhan',{'range': ['auto','auto',4,7],'val':None,'offset':0,
                                        'val_func':ky_ten_cac_ben_,'val_kargs':{'source_member_ids':'dest_member_ids'}, 'style':bold_center_style}),
                   
                    
                    ('dai_dien_ben_t3',{'range': ['auto','auto',0,2],'val':None,'offset':3, 'style':bold_center_style,'val_func':dai_dien_ben_t3_,'val_kargs':{'title_ben_thu_3':'title_ben_thu_3'}}),
                    ('dai_dien_ben_t4',{'range': ['auto','auto',4,7],'val':None,'offset':offset_job_ben_t4_,'offset_kargs':{'field_name':'dai_dien_ben_t3','offset_default':3}, 'style':bold_center_style,'val_func':dai_dien_ben_t3_,'val_kargs':{'title_ben_thu_3':'title_ben_thu_4'}}),
                    
                    ('job_ben_t3',{'range': ['auto','auto',0,2],'val':None,'offset':1,'val_func':ky_ten_cac_ben_,'val_kargs':{'type':'job_id.name','source_member_ids':'ben_thu_3_ids','empty_force':True},'style':center_style}),
                    ('job_ben_t4',{'range': ['auto','auto',4,7],'val':None,'val_func':ky_ten_cac_ben_, 'offset':offset_job_ben_t4_,'val_kargs':{'source_member_ids':'ben_thu_4_ids','type':'job_id.name','empty_force':True},'style':center_style}),
                    
                    ('ky_ten_ben_t3',{'range': ['auto','auto',0,2],'val':None,'offset':5,'val_func':ky_ten_cac_ben_, 'style':bold_center_style,'val_kargs':{'source_member_ids':'ben_thu_3_ids'}}),
                    ('ky_ten_ben_t4',{'range': ['auto','auto',4,7],'val':None,'offset':offset_job_ben_t4_,'offset_kargs':{'field_name':'ky_ten_ben_t3','offset_default':5},
                                        'val_func':ky_ten_cac_ben_, 'style':bold_center_style,'val_kargs':{'source_member_ids':'ben_thu_4_ids'}
                                        }, ),
                    ('xac_nhan_lanh_dao',{'range': ['auto','auto',0,7],'val':None,'val_func': xac_nhan_lanh_dao_,'offset':2, 'style':bold_center_style}),
                    ('ld_dai_id',{'range': ['auto','auto',0,7],'val':None,'offset':5, 'style':bold_center_style,
                                   'val_func':ky_ten_cac_ben_, 'style':bold_center_style,'val_kargs':{'source_member_ids':'lanh_dao_id','is_not_show':dl_obj.is_not_show_y_kien_ld,'fix_name':u'Nguyễn Văn Xuân'}
                                  }),
             ]
    
    
    
    wb = write_all_row(fixups,dl_obj,set_cols_width,font_height=font_height_another)
    filename = '%s_%s_%s'%(dl_obj.department_id.short_name,dl_obj.ban_giao_or_nghiem_thu,dl_obj.stt_trong_bien_ban_in)
    name = "%s%s" % (filename, '.xls')
    return wb,name
Exemple #9
0
# -*- coding: utf-8 -*-
#######################ML################################
import xlwt
from openerp.http import request
# from odoo.addons.tonkho.models.dl_models.dl_model import add_title
from odoo.addons.downloadwizard.models.dl_models.dl_model import  add_title
from collections import  OrderedDict
from odoo.addons.downloadwizard.models.dl_models.dl_model import generate_easyxf, wrap_center_vert_border_style,\
center_border_style


# wrap_center_vert_border_style = xlwt.easyxf("font:  name Times New Roman, height 240 ;align: wrap on , vert centre; borders: left thin,right thin, top thin, bottom thin")
wrap_center_vert_border_style = xlwt.easyxf(generate_easyxf(height=12,vert = 'center',borders='left thin, right thin, top thin, bottom thin',align_wrap=True))
def add_1_row_new_ml(worksheet, move ,FIELDNAME_FIELDATTR, row_index, offset_column=0, 
                            needdata=None,save_ndata=False,ml=False,
                            ml_index=False,rowspan=False,
                            font_height=12,wrap_center_vert_border_style=wrap_center_vert_border_style):
    
    
    if save_ndata:
        a_instance_dict =  needdata.get('a_instance_dict', {})
    else:
        a_instance_dict = {}
    writen_column_number = 0
    col_index = 0
    col_index += offset_column
    for f_name,FIELDATTR in FIELDNAME_FIELDATTR.items():
#         f_name,FIELDATTR =  field_from_my_FIELDNAME_FIELDATTR
        is_not_model_field = FIELDATTR.get('is_not_model_field')
        skip_field = FIELDATTR.get('skip_field')
        one_field_val = a_instance_dict.setdefault(f_name,{})
Exemple #10
0
# -*- coding: utf-8 -*-
#######################ML################################
import xlwt
from openerp.http import request
# from odoo.addons.tonkho.models.dl_models.dl_model import add_title
from odoo.addons.downloadwizard.models.dl_models.dl_model import add_title
from collections import OrderedDict
from odoo.addons.downloadwizard.models.dl_models.dl_model import generate_easyxf, wrap_center_vert_border_style,\
center_border_style

# wrap_center_vert_border_style = xlwt.easyxf("font:  name Times New Roman, height 240 ;align: wrap on , vert centre; borders: left thin,right thin, top thin, bottom thin")
wrap_center_vert_border_style = xlwt.easyxf(
    generate_easyxf(height=12,
                    vert='center',
                    borders='left thin, right thin, top thin, bottom thin',
                    align_wrap=True))


def add_1_row_new_ml(
        worksheet,
        move,
        FIELDNAME_FIELDATTR,
        row_index,
        offset_column=0,
        needdata=None,
        save_ndata=False,
        ml=False,
        ml_index=False,
        rowspan=False,
        font_height=12,
        wrap_center_vert_border_style=wrap_center_vert_border_style):