全國統一咨詢(xún)熱線(xiàn): 400-660-3328
在線(xiàn)客服
TEL:400-660-3328
自來(lái)水公司在使用同創(chuàng )B8ERP系統時(shí),往往會(huì )遇到一些操作上的疑問(wèn)。下面就給大家簡(jiǎn)單介紹一下B8ERP系統服務(wù)臺數據批量導入的操作步驟:
一、把數據導出到EXECL,然后將EXECL的數據導入到數據庫,對數據進(jìn)行轉換處理,因為很多數據(公司名稱(chēng)、受理單的狀態(tài)描述、日期)都不統一,都需要把數據調整好,然后再導出。(這里例子用的是Navicat連接pgsql的方式做的操作步驟)
用Navicat導入execl的數據是有技巧的,如果某個(gè)字段的長(cháng)度特別的長(cháng),導入的時(shí)候一定要設置字符的長(cháng)度。如下操作步驟:
二、將整理好的EXECL表格數據導入到導數據的功能模塊。受理單數據的狀態(tài)“已完成”和“未完成“的需要分開(kāi)兩個(gè)execl數據進(jìn)行導入,因為“未完成“的受理單是沒(méi)有“關(guān)閉日期”的,所以“關(guān)閉日期”的這個(gè)數據列不需要導入。導入“已完成“狀態(tài)的數據,“工時(shí)表說(shuō)明“不能為空。
三、導入完后,進(jìn)入導列表的頁(yè)面,隨便點(diǎn)擊一條數據,打開(kāi)明細頁(yè)面。Number可以輸入當次導入的條數,服務(wù)器性能比較好的時(shí)候,最多可以導入2000條件,性能不好的時(shí)候只能導入200條。
四、導入完的數據,會(huì )自動(dòng)出現在服務(wù)臺。
導入的附件格式如下:
五、導入數據的代碼如下:
# -*- coding: utf-8 -*-
from odoo import models, fields, api
import datetime
from werkzeug import urls
from io import BytesIO
import base64
class fuwutai3(models.Model):
_name = 'dsj.fuwutai3'
_description = 'dsj.fuwutai3'
name = fields.Char(string='主題')
team_id = fields.Char(string='服務(wù)臺團隊')
partner_id = fields.Char(string='客戶(hù)')
user_id = fields.Char(string='分派給')
project_id = fields.Char(string='項目')
task_id = fields.Char(string='任務(wù)')
ticket_type_id = fields.Char(string='工單類(lèi)型')
stage_id = fields.Char(string='階段')
description = fields.Char(string='說(shuō)明')
assign_date = fields.Datetime(string='首次分派日期')
close_date = fields.Datetime(string='關(guān)閉日期')
time_date = fields.Datetime(string='工時(shí)表/日期')
employee_id = fields.Char(string='工時(shí)表/員工')
time_name= fields.Char(string='工時(shí)表/說(shuō)明')
unit_amount= fields.Float(string='工時(shí)表/數量')
account_id= fields.Char(string='工時(shí)表/分析賬戶(hù)')
# create_uid= fields.Char(string='創(chuàng )建人')
# create_date= fields.Datetime(string='創(chuàng )建時(shí)間')
shoulidan_id= fields.Char(string='受理單id')
number = fields.Integer(string='number',default=200)
def piliangdaoru(self):
ddsj=self.env['dsj.fuwutai3'].search([],limit=self.number)
for record in ddsj:
res_team_id= self.env['helpdesk.team'].search([('name', '=', record.team_id)], limit=1).id
res_partner_id= self.env['res.partner'].search([('name', '=', record.partner_id)], limit=1).id
res_user_id= self.env['res.users'].search([('name', '=', record.user_id)], limit=1).id
res_project_id= self.env['project.project'].search([('name', '=', record.project_id)], limit=1).id
res_task_id= self.env['project.task'].search([('name', '=', record.task_id)], limit=1).id
res_ticket_type_id =self.env['helpdesk.ticket.type'].search([('name', '=', record.ticket_type_id)], limit=1).id
res_stage_id= self.env['helpdesk.stage'].search([('name', '=', record.stage_id)], limit=1).id
res_employee_id= self.env['hr.employee'].search([('name', '=', record.employee_id)], limit=1).id
res_account_id= self.env['project.project'].search([('name', '=', record.account_id)], limit=1).id
vals = {
'name': record.name,
'team_id': res_team_id,
'partner_id': res_partner_id,
'user_id': res_user_id,
'project_id': res_project_id,
'task_id': res_task_id,
'ticket_type_id': res_ticket_type_id,
'stage_id': res_stage_id,
'description': record.description,
'assign_date': record.assign_date,
'close_date': record.close_date,
'partner_email': record.shoulidan_id
}
helpdesk_ticket_id = self.env['helpdesk.ticket'].sudo().create(vals)
time_vals = {
'date': record.time_date,
'partner_id': res_partner_id,
'user_id': res_user_id,
'employee_id': res_employee_id,
'project_id': res_project_id,
'name': record.time_name,
'unit_amount': record.unit_amount,
'account_id': res_account_id,
'helpdesk_ticket_id':helpdesk_ticket_id.id
}
account_analytic_line_id = self.env['account.analytic.line'].sudo().create(time_vals)
record.unlink()
return '導入成功'
六、導入附件的代碼如下:
# -*- coding: utf-8 -*-
from odoo import models, fields, api
import datetime
from werkzeug import urls
from io import BytesIO
import base64
import requests
class fujian(models.Model):
_name = 'dsj.fujian'
_description = 'dsj.fujian'
name = fields.Char(string='名稱(chēng)')
partner_email = fields.Char(string='受理單id')
filename = fields.Char(string='文件名')
url = fields.Char(string='url')
number = fields.Integer(string='number',default=200)
def piliangdaoru(self):
ddsj=self.env['dsj.fujian'].search([],limit=self.number)
for record in ddsj:
helpdesk_ticket_id =record.env['helpdesk.ticket'].search([('partner_email', '=', record.partner_email)],limit=1)
response = requests.get(record.url)
data = base64.b64encode(BytesIO(response.content).read())
vals = {
'name' : record.filename,
'datas_fname' : record.url,
'res_model' : 'helpdesk.ticket',
'type' : 'binary',
'datas' : data,
'res_id' : helpdesk_ticket_id,
'res_name' : record.partner_email
}
oa_attachment = self.env['ir.attachment'].sudo().create(vals)
# print(oa_attachment)
record.unlink()
return '導入成功'