添加功能
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
from odoo import models, fields, api, _, SUPERUSER_ID
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
import xlrd
|
||||
import base64
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class PropertyContractWizard(models.Model):
|
||||
_name = 'property.contract.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.yuthon_contract_data(row)
|
||||
|
||||
def yuthon_contract_data(self, row):
|
||||
admin_id = self.env['res.users'].search([('name', '=', row[0].value)])
|
||||
contract_code = row[1].value
|
||||
name = row[2].value
|
||||
address_id = int(row[3].value)
|
||||
lessee_id = int(row[5].value)
|
||||
contact = row[6].value
|
||||
invoicing_begins = row[7].value
|
||||
invoicing_type_dict = {'专票': 'spot', '普票': 'cape', '': ''}
|
||||
invoicing_type = invoicing_type_dict.get(row[8].value, '')
|
||||
contract_time = row[11].value
|
||||
term_start_time = row[12].value
|
||||
term_end_time = row[13].value
|
||||
total_area = row[14].value
|
||||
deposit = row[15].value
|
||||
increments_every_few_years = row[16].value
|
||||
increment_percentage = row[17].value
|
||||
unit_price = row[23].value
|
||||
first_year_rent = row[25].value
|
||||
tax_rate = row[26].value
|
||||
# rent_company = row[27].value
|
||||
# rent_account = row[28].value
|
||||
contract_type_dict = {'续租': 'lease_renewal', '临租': 'interim', '补充协议': 'new', '首租': 'first'}
|
||||
contract_type = contract_type_dict.get(row[29].value, '')
|
||||
cycle_type_dict = {'月': 'monthly', '季度': 'quarter', '半年': 'half', '年度': 'year'}
|
||||
cycle_dict = cycle_type_dict.get(row[35].value, '')
|
||||
percentage_liquidated_damages = self.env['yuthon.penalty.setting'].search([('name', '=', row[36].value)])
|
||||
if not percentage_liquidated_damages:
|
||||
percentage_liquidated_damages = self.env['yuthon.penalty.setting'].create({'name': row[36].value})
|
||||
|
||||
tax = row[40].value
|
||||
performance_bonds = row[39].value
|
||||
contract_date = {
|
||||
'name': name,
|
||||
'admin_id': admin_id.id,
|
||||
'contract_code': contract_code,
|
||||
'contact': contact,
|
||||
'phone': invoicing_begins,
|
||||
'invoicing_type': invoicing_type,
|
||||
'contract_time':datetime.strptime(contract_time, '%Y-%m-%d').date() if term_start_time else None,
|
||||
'term_start_time':datetime.strptime(term_start_time, '%Y-%m-%d').date() if term_start_time else None,
|
||||
'term_end_time':datetime.strptime(term_end_time, '%Y-%m-%d').date() if term_end_time else None,
|
||||
'total_area':total_area,
|
||||
'deposit':deposit,
|
||||
'tax':tax,
|
||||
'performance_bonds':performance_bonds,
|
||||
'increments_every_few_years':increments_every_few_years,
|
||||
'increment_percentage':increment_percentage,
|
||||
'unit_price':unit_price,
|
||||
'first_year_rent':first_year_rent,
|
||||
'tax_rate':tax_rate,
|
||||
'contract_type':contract_type,
|
||||
'cycle_dict':cycle_dict,
|
||||
'lessee_id':lessee_id if self.env['property.tenant.information'].search([('id', '=',lessee_id)]) else '',
|
||||
'percentage_liquidated_damages':percentage_liquidated_damages.id,
|
||||
}
|
||||
property_contract_id = self.env['property.lease.contract'].create(contract_date)
|
||||
management_list = []
|
||||
management_list.append((0, 0, {
|
||||
'lease_id': property_contract_id.id,
|
||||
'address_id': address_id,
|
||||
}))
|
||||
property_contract_id.lease_ids = management_list
|
||||
+6
-6
@@ -1,19 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="user_template_downloads_tian_he_action" model="ir.actions.act_url">
|
||||
<field name="name">物业信息模板下载</field>
|
||||
<record id="property_contract_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_inducts_wizard_form" model="ir.ui.view">
|
||||
<field name="name">物业信息导入弹窗</field>
|
||||
<field name="model">property.inducts.wizard</field>
|
||||
<record id="property_contract_wizard_form" model="ir.ui.view">
|
||||
<field name="name">物业合同导入弹窗</field>
|
||||
<field name="model">property.contract.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<header>
|
||||
<button name="%(user_template_downloads_tian_he_action)d" string="模板下载" type="action"
|
||||
<button name="%(property_contract_template_downloads_tian_he_action)d" string="模板下载" type="action"
|
||||
class="btn btn-primary"/>
|
||||
</header>
|
||||
<group>
|
||||
@@ -1,35 +0,0 @@
|
||||
from odoo import models, fields, api, _, SUPERUSER_ID
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
import xlrd
|
||||
import base64
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class PropertyInductsWizard(models.Model):
|
||||
_name = 'property.inducts.wizard'
|
||||
|
||||
excel_file = fields.Binary(string="上传Excel表")
|
||||
excel_name = fields.Char(string="文件名")
|
||||
|
||||
def confirm(self):
|
||||
"""
|
||||
导入excel文件,按行读取数据并处理
|
||||
:return: 导入新增物业明细行并更新
|
||||
"""
|
||||
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.employee_user_data(row)
|
||||
return {
|
||||
'name': '批量更新新物业信息',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'tree',
|
||||
'res_model': 'property.approval.line',
|
||||
}
|
||||
|
||||
def employee_user_data(self, row):
|
||||
pass
|
||||
Reference in New Issue
Block a user