全國統(tǒng)一咨詢熱線: 400-660-3328
在線客服
TEL:400-660-3328
自來水公司在使用同創(chuàng)B8ERP系統(tǒng)時,往往會遇到一些操作上的疑問。下面就給大家簡單介紹一下B8ERP系統(tǒng)服務(wù)臺數(shù)據(jù)批量導(dǎo)入的操作步驟:
一、把數(shù)據(jù)導(dǎo)出到EXECL,然后將EXECL的數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫,對數(shù)據(jù)進行轉(zhuǎn)換處理,因為很多數(shù)據(jù)(公司名稱、受理單的狀態(tài)描述、日期)都不統(tǒng)一,都需要把數(shù)據(jù)調(diào)整好,然后再導(dǎo)出。(這里例子用的是Navicat連接pgsql的方式做的操作步驟)
用Navicat導(dǎo)入execl的數(shù)據(jù)是有技巧的,如果某個字段的長度特別的長,導(dǎo)入的時候一定要設(shè)置字符的長度。如下操作步驟:
二、將整理好的EXECL表格數(shù)據(jù)導(dǎo)入到導(dǎo)數(shù)據(jù)的功能模塊。受理單數(shù)據(jù)的狀態(tài)“已完成”和“未完成“的需要分開兩個execl數(shù)據(jù)進行導(dǎo)入,因為“未完成“的受理單是沒有“關(guān)閉日期”的,所以“關(guān)閉日期”的這個數(shù)據(jù)列不需要導(dǎo)入。導(dǎo)入“已完成“狀態(tài)的數(shù)據(jù),“工時表說明“不能為空。
三、導(dǎo)入完后,進入導(dǎo)列表的頁面,隨便點擊一條數(shù)據(jù),打開明細頁面。Number可以輸入當(dāng)次導(dǎo)入的條數(shù),服務(wù)器性能比較好的時候,最多可以導(dǎo)入2000條件,性能不好的時候只能導(dǎo)入200條。
四、導(dǎo)入完的數(shù)據(jù),會自動出現(xiàn)在服務(wù)臺。
導(dǎo)入的附件格式如下:
五、導(dǎo)入數(shù)據(jù)的代碼如下:
# -*- 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='客戶')
user_id = fields.Char(string='分派給')
project_id = fields.Char(string='項目')
task_id = fields.Char(string='任務(wù)')
ticket_type_id = fields.Char(string='工單類型')
stage_id = fields.Char(string='階段')
description = fields.Char(string='說明')
assign_date = fields.Datetime(string='首次分派日期')
close_date = fields.Datetime(string='關(guān)閉日期')
time_date = fields.Datetime(string='工時表/日期')
employee_id = fields.Char(string='工時表/員工')
time_name= fields.Char(string='工時表/說明')
unit_amount= fields.Float(string='工時表/數(shù)量')
account_id= fields.Char(string='工時表/分析賬戶')
# create_uid= fields.Char(string='創(chuàng)建人')
# create_date= fields.Datetime(string='創(chuàng)建時間')
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 '導(dǎo)入成功'
六、導(dǎo)入附件的代碼如下:
# -*- 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='名稱')
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 '導(dǎo)入成功'