def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) color = '' if datas['form']['data']['color']: color = 'COLOUR CODE : ' + datas['form']['data']['color'] result = { 'no' : datas['form']['data']['no'], 'urgent' : datas['form']['data']['urgent'], 'weight' : datas['form']['data']['weight'], 'measurement' : datas['form']['data']['measurement'], 'name' : datas['form']['data']['name'], 'attention' : datas['form']['data']['attention'], 'date' : time.strftime(' %B %Y', time.strptime(datas['form']['data']['date'],'%Y-%m-%d %H:%M:%S')), 'reference': datas['form']['data']['reference'], 'purchase' : 'Purchase Order No.' + datas['form']['data']['purchase'] + ', Tgl. ' + time.strftime('%d/%m/%Y', time.strptime(datas['form']['data']['pur_date'],'%Y-%m-%d')), 'color': color, 'qty': datas['form']['data']['qty'], 'product': datas['form']['data']['product'], 'totalitem': 'Total : Item', 'totalbox': 'Total : Box', } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('ad_delivery_note','report','paketA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) result = { 'name' : datas['form']['data']['name'], 'date' : time.strftime('%d %B %Y', time.strptime(datas['form']['data']['kontrakdate'],'%Y-%m-%d')), 'tanggal' : time.strftime('%d %B %Y', time.strptime(datas['form']['data']['date'],'%Y-%m-%d')), 'kirim' : time.strftime('%d %B %Y', time.strptime(datas['form']['data']['delivery_date'],'%Y-%m-%d')), 'order': datas['form']['data']['kontrak'], 'qty': datas['form']['data']['qty'], 'partner': datas['form']['data']['partner_id'][1], 'product': datas['form']['data']['product'].encode('latin9'), 'creator': datas['form']['data']['creator'], 'checker': datas['form']['data']['checker'], 'approver': datas['form']['data']['approver'] } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('sbm_spk_internal','report','perintahA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) kwitansi = '-' if datas['form']['data']['kwitansi']: kwitansi = datas['form']['data']['kwitansi'] result = { 'name' : 'INV : ' + kwitansi, 'fakturpajak' : datas['form']['data']['faktur_pajak_no'], 'supra' : datas['form']['data']['company_id'][1], 'alamatsupra' : datas['form']['data']['alamatsupra'], 'npwpsupra' : datas['form']['data']['npwpsupra'], 'customer' : datas['form']['data']['partner_id'][1], 'alamatcustomer' : datas['form']['data']['alamatcustomer'], 'npwpcustomer' : datas['form']['data']['npwpcustomer'], 'no' : datas['form']['data']['no'], 'qty': datas['form']['data']['qty'], 'product': datas['form']['data']['product'].encode('latin9'), 'valas' : datas['form']['data']['valas'], 'rupiah' : datas['form']['data']['rupiah'], 'vtotal' : datas['form']['data']['vtotal'], 'vdiskon' : datas['form']['data']['vdiskon'], 'vkenapajak' : datas['form']['data']['vtotal'], 'vpajak' : datas['form']['data']['vpajak'], 'rtotal' : datas['form']['data']['rtotal'], 'rdiskon' : datas['form']['data']['rdiskon'], 'rkenapajak' : datas['form']['data']['rtotal'], 'rpajak' : datas['form']['data']['rpajak'], 'kmk' : datas['form']['data']['kmk'], 'kurs' : datas['form']['data']['kurs'], 'matauang' : '1 ' + datas['form']['data']['currency_id'][1], 'currency' : datas['form']['data']['currency_id'][1], 'tanggal' : time.strftime('%d-%m-%Y', time.strptime(datas['form']['data']['date_invoice'],'%Y-%m-%d')), 'orang' : datas['form']['data']['approver'][1], } filepdf = 'fakturpajakrupiah.pdf' if result['currency'] != 'IDR' : result['rtotal'] = False filepdf = 'fakturpajakvalas.pdf' tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('ad_account_finance', 'report', filepdf), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) color = '' if datas['form']['data']['color']: color = 'COLOUR CODE : ' + datas['form']['data']['color'] result = { 'no': datas['form']['data']['no'], 'urgent': datas['form']['data']['urgent'], 'weight': datas['form']['data']['weight'], 'measurement': datas['form']['data']['measurement'], 'name': datas['form']['data']['name'], 'attention': datas['form']['data']['attention'], 'date': time.strftime( ' %B %Y', time.strptime(datas['form']['data']['date'], '%Y-%m-%d %H:%M:%S')), 'reference': datas['form']['data']['reference'], 'purchase': 'Purchase Order No.' + datas['form']['data']['purchase'] + ', Tgl. ' + time.strftime( '%d/%m/%Y', time.strptime(datas['form']['data']['pur_date'], '%Y-%m-%d')), 'color': color, 'qty': datas['form']['data']['qty'], 'product': datas['form']['data']['product'], 'totalitem': 'Total : Item', 'totalbox': 'Total : Box', } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('ad_delivery_note', 'report', 'paketA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) kwitansi = '-' if datas['form']['data']['kwitansi']: kwitansi = datas['form']['data']['kwitansi'] result = { 'name': kwitansi, 'customer': datas['form']['data']['partner_id'][1], 'alamatcustomer': datas['form']['data']['alamatcustomer'], 'no': datas['form']['data']['no'], 'qty': datas['form']['data']['qty'], 'product': datas['form']['data']['product'].encode('latin9'), 'price': datas['form']['data']['price'], 'subtotal': datas['form']['data']['subtotal'], 'rsubtotal': datas['form']['data']['rsubtotal'], 'rpajak': datas['form']['data']['rpajak'], 'rtotal': datas['form']['data']['rtotal'], 'terbilang': datas['form']['data']['terbilang'], 'tanggal': time.strftime( '%d.%m.%Y', time.strptime(datas['form']['data']['date_invoice'], '%Y-%m-%d')), 'orang': datas['form']['data']['approver'][1], } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('ad_account_finance', 'report', 'invoice.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) result = { 'name': datas['form']['data']['name'], 'date': time.strftime( '%d %B %Y', time.strptime(datas['form']['data']['kontrakdate'], '%Y-%m-%d')), 'tanggal': time.strftime( '%d %B %Y', time.strptime(datas['form']['data']['date'], '%Y-%m-%d')), 'kirim': time.strftime( '%d %B %Y', time.strptime(datas['form']['data']['delivery_date'], '%Y-%m-%d')), 'order': datas['form']['data']['kontrak'], 'qty': datas['form']['data']['qty'], 'partner': datas['form']['data']['partner_id'][1], 'product': datas['form']['data']['product'].encode('latin9'), 'creator': datas['form']['data']['creator'], 'checker': datas['form']['data']['checker'], 'approver': datas['form']['data']['approver'] } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('ad_perintah_kerja', 'report', 'perintahA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) result = { 'name' : datas['form']['data']['name'], 'date' : time.strftime('%d %B %Y', time.strptime(datas['form']['data']['tanggal'],'%Y-%m-%d')), 'order': datas['form']['data']['poc'], 'qty': datas['form']['data']['qty'], 'partner': datas['form']['data']['partner_id'][1]+'\n'+datas['form']['data']['street']+'\n'+datas['form']['data']['jalan']+'\n'+datas['form']['data']['phone'], 'product_name': datas['form']['data']['product_name'].encode('utf-8'), 'product_code': datas['form']['data']['product_code'] } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('ad_order_preparation','report','preparationA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) kwitansi = '-' if datas['form']['data']['kwitansi']: kwitansi = datas['form']['data']['kwitansi'] result = { 'name' : kwitansi, 'customer' : datas['form']['data']['partner_id'][1], 'alamatcustomer' : datas['form']['data']['alamatcustomer'], 'no' : datas['form']['data']['no'], 'qty': datas['form']['data']['qty'], 'product' : datas['form']['data']['product'].encode('latin9'), 'price' : datas['form']['data']['price'], 'subtotal' : datas['form']['data']['subtotal'], 'rsubtotal' : datas['form']['data']['rsubtotal'], 'rpajak' : datas['form']['data']['rpajak'], 'rtotal' : datas['form']['data']['rtotal'], 'terbilang' : datas['form']['data']['terbilang'], 'tanggal' : time.strftime('%d.%m.%Y', time.strptime(datas['form']['data']['date_invoice'],'%Y-%m-%d')), 'orang' : datas['form']['data']['approver'][1], } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('ad_account_finance','report','invoice.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) result = { 'name': datas['form']['data']['name'], 'order': datas['form']['data']['poc'], 'prepare': datas['form']['data']['prepare_id'][1], 'qty': datas['form']['data']['qty'], 'partner': datas['form']['data']['partner_id'][1] + '\n' + datas['form']['data']['street'] + '\n' + datas['form']['data']['jalan'] + '\n' + datas['form']['data']['phone'], 'product_name': datas['form']['data']['product_name'].encode('latin9'), 'product_code': datas['form']['data']['product_code'] } print '------------------', datas['form']['data']['partner_id'][ 1] + '\n' + datas['form']['data']['street'] + '\n' + datas['form'][ 'data']['jalan'] + '\n' + datas['form']['data']['phone'] tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('ad_delivery_note', 'report', 'deliveryA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) result = { 'name': datas['form']['data']['name'], 'date': time.strftime( '%d %B %Y', time.strptime(datas['form']['data']['tanggal'], '%Y-%m-%d')), 'order': datas['form']['data']['poc'], 'qty': datas['form']['data']['qty'], 'partner': datas['form']['data']['partner_id'][1] + '\n' + datas['form']['data']['street'] + '\n' + datas['form']['data']['jalan'] + '\n' + datas['form']['data']['phone'], 'product_name': datas['form']['data']['product_name'].encode('utf-8'), 'product_code': datas['form']['data']['product_code'] } tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('ad_order_preparation', 'report', 'preparationA5.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) result = { 'name' : datas['form']['data']['name'], 'order': datas['form']['data']['poc'], 'prepare': datas['form']['data']['prepare_id'][1], 'qty': datas['form']['data']['qty'], 'partner': datas['form']['data']['partner_id'][1]+'\n'+datas['form']['data']['street']+'\n'+datas['form']['data']['jalan']+'\n'+datas['form']['data']['phone'], 'product_name': datas['form']['data']['product_name'].encode('latin9'), 'product_code': datas['form']['data']['product_code'] } print '------------------',datas['form']['data']['partner_id'][1]+'\n'+datas['form']['data']['street']+'\n'+datas['form']['data']['jalan']+'\n'+datas['form']['data']['phone'] tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('ad_delivery_note','report','deliveryA4.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) kwitansi = '-' if datas['form']['data']['kwitansi']: kwitansi = datas['form']['data']['kwitansi'] result = { 'name': 'INV : ' + kwitansi, 'fakturpajak': datas['form']['data']['faktur_pajak_no'], 'supra': datas['form']['data']['company_id'][1], 'alamatsupra': datas['form']['data']['alamatsupra'], 'npwpsupra': datas['form']['data']['npwpsupra'], 'customer': datas['form']['data']['partner_id'][1], 'alamatcustomer': datas['form']['data']['alamatcustomer'], 'npwpcustomer': datas['form']['data']['npwpcustomer'], 'no': datas['form']['data']['no'], 'qty': datas['form']['data']['qty'], 'product': datas['form']['data']['product'].encode('latin9'), 'valas': datas['form']['data']['valas'], 'rupiah': datas['form']['data']['rupiah'], 'vtotal': datas['form']['data']['vtotal'], 'vdiskon': datas['form']['data']['vdiskon'], 'vkenapajak': datas['form']['data']['vtotal'], 'vpajak': datas['form']['data']['vpajak'], 'rtotal': datas['form']['data']['rtotal'], 'rdiskon': datas['form']['data']['rdiskon'], 'rkenapajak': datas['form']['data']['rtotal'], 'rpajak': datas['form']['data']['rpajak'], 'kmk': datas['form']['data']['kmk'], 'kurs': datas['form']['data']['kurs'], 'matauang': '1 ' + datas['form']['data']['currency_id'][1], 'currency': datas['form']['data']['currency_id'][1], 'tanggal': time.strftime( '%d-%m-%Y', time.strptime(datas['form']['data']['date_invoice'], '%Y-%m-%d')), 'orang': datas['form']['data']['approver'][1], } filepdf = 'fakturpajakrupiah.pdf' if result['currency'] != 'IDR': result['rtotal'] = False filepdf = 'fakturpajakvalas.pdf' tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('ad_account_finance', 'report', filepdf), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: os.remove(tmp_file) self.obj.render() return (self.obj.pdf, 'pdf')
def create(self, cr, uid, ids, datas, context=None): pool = pooler.get_pool(cr.dbname) form = pool.get('form.f2a').browse(cr,uid,ids[0]) result = {} jsostek = form.jamsostek print jsostek, form result['npp'] = form.npp result['com_name'] = form.name.name result['unit_kerja_nama'] = form.nuk result['period_id'] = form.period_id i=1 for member in jsostek: if i<10: seq = '0'+str(i) else: seq = str(i) kpj = 'emp_no_kpj_'+seq nik = 'emp_nik_'+seq nama = 'emp_nama_'+seq ttl = 'emp_ttl_'+seq upah = 'emp_upah_'+seq jkk = 'emp_iuran_jkk_'+seq jkm = 'emp_iuran_jkm_'+seq jpk = 'emp_iuran_jpk_'+seq jht_tk = 'emp_iuran_jhttk_'+seq jht = 'emp_iuran_jht_'+seq total = 'emp_total_iuran_'+seq result[kpj] = member.jnumber result[nik] = member.name.nik result[nama] = member.name.name birthday = datetime.fromtimestamp(time.mktime(time.strptime(member.name.birthday,"%Y-%m-%d"))) birthday = tools.ustr(birthday.strftime('%d/%m/%Y')) result[ttl] = birthday contract_ids = pool.get('hr.contract').search(cr,uid,[('employee_id','=',member.name.id)]) if len(contract_ids)==0: raise osv.except_osv(_('No Contract Found!'), _('No contract found for one of this employee!\nPlease create contract for the employee first.')) else: contract =pool.get('hr.contract').browse(cr,uid,contract_ids[0]) locale.setlocale(locale.LC_ALL, 'en_AU.utf8') result[upah] = locale.format('%.2f', contract.wage, 1) result[jkk] = locale.format('%.2f',member.jkk_amount, 1) or "-" result[jkm] = locale.format('%.2f',member.jk_amount, 1) or "-" result[jpk] = locale.format('%.2f',member.jpk_amount, 1) or "-" result[jht_tk] = locale.format('%.2f',member.jht_amount, 1) or "-" result[jht] = locale.format('%.2f',member.jht_amount, 1) or "-" result[total] = locale.format('%.2f',member.total, 1) or "-" i=i+1 try: tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('ad_hr_jamsostek_form','report','pdf','f2a.pdf'), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: try: os.remove(tmp_file) except: pass # nothing to do self.obj.render() return (self.obj.pdf, 'pdf') except Exception: raise osv.except_osv(_('pdf not created !'), _('Please check if package pdftk is installed!'))
def create(self, cr, uid, ids, datas, context=None): form_name = datas['form']['name']+'.pdf' pool = pooler.get_pool(cr.dbname) emp_obj = pool.get('hr.employee').browse(cr,uid,ids[0],context) result = {} partner = emp_obj.company_id.partner_id emp_name = emp_obj.name emp_name = emp_name.split(" ") name_length = len(emp_name) firstname = emp_name[0] midname = "" lastname = "" wife_husband_birth = "" son1_birthday = "" son2_birthday = "" son3_birthday = "" if name_length==2: midname ="" lastname=emp_name[1] elif name_length==3: midname = emp_name[1] lastname= emp_name[2] elif name_length==4: midname = emp_name[1]+" "+emp_name[2] lastname= emp_name[3] birthday = emp_obj.birthday birthday = birthday.split("-") if emp_obj.country_id.name=="Indonesia": country="" else: country=emp_obj.country_id.name ktp=emp_obj.ktp if emp_obj.ktp: ktp=ktp.replace(".","") ktp=ktp.replace("-","") npwp=emp_obj.npwp if npwp: npwp=npwp.replace(".","") npwp=npwp.replace("-","") else: npwp="" family = emp_obj.family_id wife_husband = ['wife','istri','husband','suami'] son = ['son','daughter','putra','putri','anak'] wife_husband_name = "" son1_name = "" son2_name = "" son3_name = "" if len(family)!=0: for family in family: if family.relation: if family.relation.name.lower() in wife_husband: wife_husband_name = family.name wife_husband_birth = family.birthday.split("-") elif family.relation.name.lower() in son: son_name = family.name if son1_name=="": son1_name = son_name son1_birthday = family.birthday.split("-") elif son2_name=="": son2_name=son_name son2_birthday = family.birthday.split("-") elif son3_name=="": son3_name=son_name son3_birthday = family.birthday.split("-") if wife_husband_birth=="": wife_husband_birth=["","",""] if son1_birthday=="": son1_birthday=["","",""] if son2_birthday=="": son2_birthday=["","",""] if son3_birthday=="": son3_birthday=["","",""] title=partner.title if title: title=title.name else: title="" phone=partner.phone if phone: phone=phone.replace("(","") phone=phone.replace("+","") phone=phone.replace(")","") phone=phone.split("-") phonearea=phone[0] if phone[0][0]!='0': phonearea='0'+phonearea[2:] else: phone="" fax=partner.address[0].fax if fax: fax=fax.replace("(","") fax=fax.replace("+","") fax=fax.replace(")","") fax=fax.split("-") faxarea=fax[0] if fax[0][0]!='0': faxarea='0'+faxarea[2:] else: fax="" result['com_name'] = emp_obj.company_id.name result['com_npwp'] = npwp result['com_phone1_area'] = phonearea result['com_phone1_number'] = phone[1] result['com_zip'] = partner.address[0].zip result['com_badan_hukum'] = title result['emp_first_name'] = firstname result['emp_mid_name'] = midname result['emp_last_name'] = lastname result['emp_nama'] = firstname+" "+midname+" "+lastname result['emp_jabatan'] = emp_obj.job_id.name if emp_obj.department_id: result['emp_unit_bag_usaha'] = emp_obj.department_id.name result['emp_no_induk'] = emp_obj.nik result['emp_tanggal_lahir'] = birthday[2] result['emp_bulan_lahir'] = birthday[1] result['emp_tahun_lahir'] = birthday[0] result['emp_kewarganegaraan'] = country result['emp_no_identitas'] = ktp result['emp_npwp'] = npwp result['emp_email_address'] = emp_obj.work_email if emp_obj.mobile_phone: if len(emp_obj.mobile_phone)>5: result['emp_mobile_area'] = emp_obj.mobile_phone[:4] result['emp_mobile_number'] = emp_obj.mobile_phone[4:] result['emp_phone'] = emp_obj.mobile_phone result['com_phone_area'] = phonearea result['com_phone_number'] = phone[1] result['com_phone'] = phonearea+phone[1] result['com_phone_ext'] = emp_obj.extension result['emp_nama_pasangan'] = wife_husband_name result['emp_tgl_lahir_pasangan'] = wife_husband_birth[2] result['emp_bln_lahir_pasangan'] = wife_husband_birth[1] result['emp_thn_lahir_pasangan'] = wife_husband_birth[0] result['emp_nama_anak1'] = son1_name result['emp_tgl_lahir_anak1'] = son1_birthday[2] result['emp_bln_lahir_anak1'] = son1_birthday[1] result['emp_thn_lahir_anak'] = son1_birthday[0] result['emp_nama_anak2'] = son2_name result['emp_tgl_lahir_anak2'] = son2_birthday[2] result['emp_bln_lahir_anak2'] = son2_birthday[1] result['emp_thn_lahir_anak2'] = son2_birthday[0] result['emp_nama_anak3'] = son3_name result['emp_tgl_lahir_anak3'] = son3_birthday[2] result['emp_bln_lahir_anak3'] = son3_birthday[1] result['emp_thn_lahir_anak3'] = son3_birthday[0] if partner.address: result['com_contact_name'] = partner.address[0].name result['com_contact_function'] = partner.address[0].function # result['com_contact_phone_area'] = phonearea result['com_contact_phone_number'] = phone[1] # result['com_contact_fax_area'] = faxarea result['com_contact_fax_number'] = fax[1] result['com_contact_email'] = partner.address[0].email result['com_address1'] = partner.address[0].street result['com_address2'] = partner.address[0].street2 result['com_address'] = partner.address[0].street result['com_city'] = partner.address[0].city result['com_kabupaten'] = partner.address[0].state_id result['com_fax_area'] = faxarea result['com_fax_number'] = fax[1] else: raise osv.except_osv(_('No Form Available !'), _('No Form Available!')) try: tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf(addons.get_module_resource('hr_jamsostek','report','pdf', form_name), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: try: os.remove(tmp_file) except: pass # nothing to do self.obj.render() return (self.obj.pdf, 'pdf') except Exception: raise osv.except_osv(_('pdf not created !'), _('Please check if package pdftk is installed!'))
def create(self, cr, uid, ids, datas, context=None): form_name = datas['form']['name'] + '.pdf' pool = pooler.get_pool(cr.dbname) emp_obj = pool.get('hr.employee').browse(cr, uid, ids[0], context) result = {} partner = emp_obj.company_id.partner_id emp_name = emp_obj.name emp_name = emp_name.split(" ") name_length = len(emp_name) firstname = emp_name[0] midname = "" lastname = "" wife_husband_birth = "" son1_birthday = "" son2_birthday = "" son3_birthday = "" if name_length == 2: midname = "" lastname = emp_name[1] elif name_length == 3: midname = emp_name[1] lastname = emp_name[2] elif name_length == 4: midname = emp_name[1] + " " + emp_name[2] lastname = emp_name[3] birthday = emp_obj.birthday birthday = birthday.split("-") if emp_obj.country_id.name == "Indonesia": country = "" else: country = emp_obj.country_id.name ktp = emp_obj.ktp if emp_obj.ktp: ktp = ktp.replace(".", "") ktp = ktp.replace("-", "") npwp = emp_obj.npwp if npwp: npwp = npwp.replace(".", "") npwp = npwp.replace("-", "") else: npwp = "" family = emp_obj.family_id wife_husband = ['wife', 'istri', 'husband', 'suami'] son = ['son', 'daughter', 'putra', 'putri', 'anak'] wife_husband_name = "" son1_name = "" son2_name = "" son3_name = "" if len(family) != 0: for family in family: if family.relation: if family.relation.name.lower() in wife_husband: wife_husband_name = family.name wife_husband_birth = family.birthday.split("-") elif family.relation.name.lower() in son: son_name = family.name if son1_name == "": son1_name = son_name son1_birthday = family.birthday.split("-") elif son2_name == "": son2_name = son_name son2_birthday = family.birthday.split("-") elif son3_name == "": son3_name = son_name son3_birthday = family.birthday.split("-") if wife_husband_birth == "": wife_husband_birth = ["", "", ""] if son1_birthday == "": son1_birthday = ["", "", ""] if son2_birthday == "": son2_birthday = ["", "", ""] if son3_birthday == "": son3_birthday = ["", "", ""] title = partner.title if title: title = title.name else: title = "" phone = partner.phone if phone: phone = phone.replace("(", "") phone = phone.replace("+", "") phone = phone.replace(")", "") phone = phone.split("-") phonearea = phone[0] if phone[0][0] != '0': phonearea = '0' + phonearea[2:] else: phone = "" fax = partner.address[0].fax if fax: fax = fax.replace("(", "") fax = fax.replace("+", "") fax = fax.replace(")", "") fax = fax.split("-") faxarea = fax[0] if fax[0][0] != '0': faxarea = '0' + faxarea[2:] else: fax = "" result['com_name'] = emp_obj.company_id.name result['com_npwp'] = npwp result['com_phone1_area'] = phonearea result['com_phone1_number'] = phone[1] result['com_zip'] = partner.address[0].zip result['com_badan_hukum'] = title result['emp_first_name'] = firstname result['emp_mid_name'] = midname result['emp_last_name'] = lastname result['emp_nama'] = firstname + " " + midname + " " + lastname result['emp_jabatan'] = emp_obj.job_id.name if emp_obj.department_id: result['emp_unit_bag_usaha'] = emp_obj.department_id.name result['emp_no_induk'] = emp_obj.nik result['emp_tanggal_lahir'] = birthday[2] result['emp_bulan_lahir'] = birthday[1] result['emp_tahun_lahir'] = birthday[0] result['emp_kewarganegaraan'] = country result['emp_no_identitas'] = ktp result['emp_npwp'] = npwp result['emp_email_address'] = emp_obj.work_email if emp_obj.mobile_phone: if len(emp_obj.mobile_phone) > 5: result['emp_mobile_area'] = emp_obj.mobile_phone[:4] result['emp_mobile_number'] = emp_obj.mobile_phone[4:] result['emp_phone'] = emp_obj.mobile_phone result['com_phone_area'] = phonearea result['com_phone_number'] = phone[1] result['com_phone'] = phonearea + phone[1] result['com_phone_ext'] = emp_obj.extension result['emp_nama_pasangan'] = wife_husband_name result['emp_tgl_lahir_pasangan'] = wife_husband_birth[2] result['emp_bln_lahir_pasangan'] = wife_husband_birth[1] result['emp_thn_lahir_pasangan'] = wife_husband_birth[0] result['emp_nama_anak1'] = son1_name result['emp_tgl_lahir_anak1'] = son1_birthday[2] result['emp_bln_lahir_anak1'] = son1_birthday[1] result['emp_thn_lahir_anak'] = son1_birthday[0] result['emp_nama_anak2'] = son2_name result['emp_tgl_lahir_anak2'] = son2_birthday[2] result['emp_bln_lahir_anak2'] = son2_birthday[1] result['emp_thn_lahir_anak2'] = son2_birthday[0] result['emp_nama_anak3'] = son3_name result['emp_tgl_lahir_anak3'] = son3_birthday[2] result['emp_bln_lahir_anak3'] = son3_birthday[1] result['emp_thn_lahir_anak3'] = son3_birthday[0] if partner.address: result['com_contact_name'] = partner.address[0].name result['com_contact_function'] = partner.address[0].function # result['com_contact_phone_area'] = phonearea result['com_contact_phone_number'] = phone[1] # result['com_contact_fax_area'] = faxarea result['com_contact_fax_number'] = fax[1] result['com_contact_email'] = partner.address[0].email result['com_address1'] = partner.address[0].street result['com_address2'] = partner.address[0].street2 result['com_address'] = partner.address[0].street result['com_city'] = partner.address[0].city result['com_kabupaten'] = partner.address[0].state_id result['com_fax_area'] = faxarea result['com_fax_number'] = fax[1] else: raise osv.except_osv(_('No Form Available !'), _('No Form Available!')) try: tmp_file = tempfile.mkstemp(".pdf")[1] try: fill_pdf( addons.get_module_resource('hr_jamsostek', 'report', 'pdf', form_name), tmp_file, result) with open(tmp_file, "r") as ofile: self.obj = external_pdf(ofile.read()) finally: try: os.remove(tmp_file) except: pass # nothing to do self.obj.render() return (self.obj.pdf, 'pdf') except Exception: raise osv.except_osv( _('pdf not created !'), _('Please check if package pdftk is installed!'))