diff --git a/yuthon_property/__manifest__.py b/yuthon_property/__manifest__.py
index d74449eeb..f82bb4b52 100644
--- a/yuthon_property/__manifest__.py
+++ b/yuthon_property/__manifest__.py
@@ -48,6 +48,7 @@
'views/property_meter_reading_views.xml',
'wizard/yuthon_property_wizard_views.xml',
'wizard/property_meter_wizard_views.xml',
+ 'wizard/property_tenant_wizard_views.xml',
'views/menuitem.xml',
],
'assets': {
diff --git a/yuthon_property/models/property_tenant_information.py b/yuthon_property/models/property_tenant_information.py
index 5753e32aa..d480c8420 100644
--- a/yuthon_property/models/property_tenant_information.py
+++ b/yuthon_property/models/property_tenant_information.py
@@ -27,4 +27,15 @@ class PropertyTenantInformation(models.Model):
power_attorney_id = fields.Many2one('ir.attachment', string='委托代理书')
attorne_card_id = fields.Many2one('ir.attachment', string='委托代理人身份证')
+ def update_tenant_wizard(self):
+ return {
+ "type": "ir.actions.act_window",
+ "name": "更新承租方信息",
+ "res_model": "property.tenant.wizard",
+ "view_mode": "form",
+ "target": "new",
+ }
+
+
+
diff --git a/yuthon_property/security/ir.model.access.csv b/yuthon_property/security/ir.model.access.csv
index 73beab6d1..48fd9d205 100644
--- a/yuthon_property/security/ir.model.access.csv
+++ b/yuthon_property/security/ir.model.access.csv
@@ -55,4 +55,5 @@ access_yuthon_lot_setting,yuthon_lot_setting,model_yuthon_lot_setting,base.group
access_yuthon_property_wizard,yuthon_property_wizard,model_yuthon_property_wizard,base.group_user,1,1,1,1
access_yuthon_property_company,yuthon_property_company,model_yuthon_property_company,base.group_user,1,1,1,1
access_property_meter_wizard,property_meter_wizard,model_property_meter_wizard,base.group_user,1,1,1,1
-access_yuthon_industry_setting,yuthon_industry_setting,model_yuthon_industry_setting,base.group_user,1,1,1,1
\ No newline at end of file
+access_yuthon_industry_setting,yuthon_industry_setting,model_yuthon_industry_setting,base.group_user,1,1,1,1
+access_property_tenant_wizard,property_tenant_wizard,model_property_tenant_wizard,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/yuthon_property/views/property_tenant_information_views.xml b/yuthon_property/views/property_tenant_information_views.xml
index 6f7f0a7a0..9a5508655 100644
--- a/yuthon_property/views/property_tenant_information_views.xml
+++ b/yuthon_property/views/property_tenant_information_views.xml
@@ -60,4 +60,11 @@
property.tenant.information
tree,form
+
+ 更新承租方信息
+
+
+ code
+ action = model.update_tenant_wizard()
+
\ No newline at end of file
diff --git a/yuthon_property/wizard/__init__.py b/yuthon_property/wizard/__init__.py
index d3ac592d8..d05385e17 100644
--- a/yuthon_property/wizard/__init__.py
+++ b/yuthon_property/wizard/__init__.py
@@ -1,2 +1,3 @@
from . import yuthon_property_wizard
-from . import property_meter_wizard
\ No newline at end of file
+from . import property_meter_wizard
+from . import property_tenant_wizard
\ No newline at end of file
diff --git a/yuthon_property/wizard/property_tenant_wizard.py b/yuthon_property/wizard/property_tenant_wizard.py
new file mode 100644
index 000000000..b4001e551
--- /dev/null
+++ b/yuthon_property/wizard/property_tenant_wizard.py
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+from odoo import models, fields, api, _, SUPERUSER_ID
+from odoo.exceptions import ValidationError, UserError
+from pypinyin import pinyin, Style
+import xlrd
+import base64
+import datetime
+from datetime import datetime
+
+
+class PropertyTenantWizard(models.Model):
+ _name = 'property.tenant.wizard'
+
+
+ excel_file = fields.Binary(string="上传Excel表")
+ excel_name = fields.Char(string="文件名")
+
+ def confirm(self):
+ """
+ 导入excel文件,按行读取数据并处理
+ """
+ if not self.excel_file:
+ raise ValidationError('请上传文件。')
+ book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file))
+ sh = book.sheet_by_index(0)
+ for rx in range(1, sh.nrows):
+ row = sh.row(rx)
+ self.property_tenant_data(row)
+
+ def property_tenant_data(self, row):
+ tenant_id = self.env['property.tenant.information'].search([('name', '=', row[0].value)])
+ tax_number = row[1].value
+ invoicing_begins = row[2].value
+ invoicing_type_dict = {'专票': 'spot', '普票': 'cape'}
+ invoicing_type = invoicing_type_dict.get(row[3].value)
+ entity_type_dict = {'个人': 'person', '企业': 'company'}
+ entity_type = entity_type_dict.get(row[4].value)
+ legal = row[6].value
+ email = row[7].value
+ contact = row[8].value
+ phone = int(row[9].value) if row[9].value else False
+ industry_id = self.env['yuthon.industry.setting'].search([('name', '=', row[10].value)])
+ if not industry_id:
+ industry_id = self.env['yuthon.industry.setting'].create({'name': row[10].value})
+ tenant_data = {
+ 'name': row[0].value,
+ 'tax_number': tax_number,
+ 'invoicing_begins': invoicing_begins,
+ 'invoicing_type': invoicing_type,
+ 'entity_type': entity_type,
+ 'legal': legal,
+ 'email': email,
+ 'contact': contact,
+ 'phone': phone,
+ 'industry_id': industry_id.id,
+ }
+
+ if not tenant_id:
+ self.env['property.tenant.information'].create(tenant_data)
+ else:
+ tenant_id.write(tenant_data)
+
+
diff --git a/yuthon_property/wizard/property_tenant_wizard_views.xml b/yuthon_property/wizard/property_tenant_wizard_views.xml
new file mode 100644
index 000000000..aa3a88e70
--- /dev/null
+++ b/yuthon_property/wizard/property_tenant_wizard_views.xml
@@ -0,0 +1,34 @@
+
+
+
+ 电仪表模板 下载
+ self
+ .
+
+
+ 审批意见弹窗
+ property.tenant.wizard
+
+
+
+
+
\ No newline at end of file