Merge pull request !1250 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-01-09 09:19:28 +00:00
committed by Gitee
7 changed files with 120 additions and 2 deletions
+1
View File
@@ -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': {
@@ -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",
}
+2 -1
View File
@@ -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
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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
55 access_yuthon_property_wizard yuthon_property_wizard model_yuthon_property_wizard base.group_user 1 1 1 1
56 access_yuthon_property_company yuthon_property_company model_yuthon_property_company base.group_user 1 1 1 1
57 access_property_meter_wizard property_meter_wizard model_property_meter_wizard base.group_user 1 1 1 1
58 access_yuthon_industry_setting yuthon_industry_setting model_yuthon_industry_setting base.group_user 1 1 1 1
59 access_property_tenant_wizard property_tenant_wizard model_property_tenant_wizard base.group_user 1 1 1 1
@@ -60,4 +60,11 @@
<field name="res_model">property.tenant.information</field>
<field name="view_mode">tree,form</field>
</record>
<record id="update_property_tenant_information" model="ir.actions.server">
<field name="name">更新承租方信息</field>
<field name="model_id" ref="yuthon_property.model_property_tenant_information"/>
<field name="binding_model_id" ref="yuthon_property.model_property_tenant_information"/>
<field name="state">code</field>
<field name="code">action = model.update_tenant_wizard()</field>
</record>
</odoo>
+2 -1
View File
@@ -1,2 +1,3 @@
from . import yuthon_property_wizard
from . import property_meter_wizard
from . import property_meter_wizard
from . import property_tenant_wizard
@@ -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)
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="property_tenant_template_downloads_tian_he_action" model="ir.actions.act_url">
<field name="name">电仪表模板 下载</field>
<field name="target">self</field>
<field name="url">.</field>
</record>
<record id="property_tenant_wizard_form" model="ir.ui.view">
<field name="name">审批意见弹窗</field>
<field name="model">property.tenant.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<header>
<button name="%(property_tenant_template_downloads_tian_he_action)d" string="模板下载" type="action"
class="btn btn-primary"/>
</header>
<group>
<group>
<field name="excel_file" filename="excel_name"/>
<field name="excel_name" invisible="1"/>
</group>
<group>
</group>
</group>
</sheet>
<footer>
<button name="confirm" string="确认" type="object" class="oe_highlight"/>
<button string="返回" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
</odoo>