供應商資料EXCEL檔匯入
-
我只贴导入部分的代码,希望对你有帮助。
1. 定义一个wizard<br />class cash_bill_import(osv.osv_memory):<br /> _name = "fg_account.cash_bill.import.wizard"<br /> _description = "导入现金账单明细"<br /> <br /> _columns = {<br /> 'excel': fields.binary('excel文件', filters='*.xls'),<br /> }<br /><br /><br /> def import_bill(self, cr, uid, ids, context=None):<br /> result = {'type': 'ir.actions.act_window_close'}<br /> for wiz in self.browse(cr,uid,ids):<br /> if not wiz.excel: continue<br /> excel = xlrd.open_workbook(file_contents=base64.decodestring(wiz.excel))<br /> sh = excel.sheet_by_index(0)<br /> <br /> <br /> for rx in range(sh.nrows):<br /> <br /> date_s = sh.cell(rx, 0).value<br /> cash_in = sh.cell(rx, 3).value<br /><br /> .....<br /><br />