@@ -11,7 +11,7 @@ class PropertyBankStatements(models.Model):
|
||||
name = fields.Char('账户卡号')
|
||||
company_id = fields.Many2one('yuthon.property.company', string="收款账户")
|
||||
name_account = fields.Char('户名')
|
||||
start_time = fields.Date('交易时间')
|
||||
start_time = fields.Datetime('交易时间')
|
||||
contract_account = fields.Char(string="合同累计应收")
|
||||
contract_penalty = fields.Char(string="合同累计违约金")
|
||||
original_amount = fields.Float(string='交易金额')
|
||||
@@ -65,3 +65,26 @@ class PropertyBankStatements(models.Model):
|
||||
property_ids.append(lease_id.id)
|
||||
self.property_ids = [(6, 0, property_ids)]
|
||||
self.contract_ids = [(6, 0, contract_ids.ids)] if contract_ids else []
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
record = super(PropertyBankStatements, self).create(vals)
|
||||
record._update_related_fields()
|
||||
return record
|
||||
|
||||
def _update_related_fields(self):
|
||||
contract_ids = self.env['property.lease.contract']
|
||||
property_ids = []
|
||||
if self.name:
|
||||
bank_id = self.env['property.bank.line'].search([('bank', '=', self.name)])
|
||||
if bank_id:
|
||||
tenant_id = bank_id.tenant_id
|
||||
if tenant_id:
|
||||
contract_ids = self.env['property.lease.contract'].search([('lessee_id', '=', tenant_id.id)])
|
||||
for contract in contract_ids:
|
||||
if contract.lease_ids:
|
||||
lease_id = contract.lease_ids[0].address_id
|
||||
if lease_id:
|
||||
property_ids.append(lease_id.id)
|
||||
self.property_ids = [(6, 0, property_ids)]
|
||||
self.contract_ids = [(6, 0, contract_ids.ids)] if contract_ids else []
|
||||
@@ -9,11 +9,11 @@
|
||||
<field name="company_id"/>
|
||||
<field name="name"/>
|
||||
<field name="name_account"/>
|
||||
<field name="contract_account"/>
|
||||
<field name="remake"/>
|
||||
<field name="property_ids" widget="many2many_tags"/>
|
||||
<field name="original_amount"/>
|
||||
<field name="contract_account"/>
|
||||
<field name="contract_penalty"/>
|
||||
<field name="original_amount"/>
|
||||
<field name="property_ids" widget="many2many_tags"/>
|
||||
<field name="voucher_type"/>
|
||||
<button name="unlink" type="object" string="删除" class="btn btn-primary"/>
|
||||
</tree>
|
||||
|
||||
@@ -5,12 +5,13 @@ from datetime import datetime, time, timedelta
|
||||
import xlrd
|
||||
import base64
|
||||
import pandas as pd
|
||||
|
||||
import re
|
||||
|
||||
class PropertyStatementsWizard(models.Model):
|
||||
_name = 'property.statements.wizard'
|
||||
_description = '银行流水向导弹窗'
|
||||
|
||||
selection_bank = fields.Select(string="选择银行", selection=[('js', '建设银行'), ('gs', '工商银行')])
|
||||
excel_file = fields.Binary(string="上传Excel表")
|
||||
excel_name = fields.Char(string="文件名")
|
||||
|
||||
@@ -29,7 +30,8 @@ class PropertyStatementsWizard(models.Model):
|
||||
def property_bank_statements_data(self, row):
|
||||
contract_ids = self.env['property.lease.contract']
|
||||
if row[2].value:
|
||||
start_time = pd.to_datetime(row[2].value, unit='d', origin='1899-12-30')
|
||||
formatted_date = self.convert_date_format(row[2].value)
|
||||
start_time = pd.to_datetime(formatted_date)
|
||||
else:
|
||||
start_time = None
|
||||
name = row[0].value
|
||||
@@ -61,4 +63,6 @@ class PropertyStatementsWizard(models.Model):
|
||||
}
|
||||
self.env['property.bank.statements'].create(bank_data)
|
||||
|
||||
|
||||
def convert_date_format(self,date_str):
|
||||
pattern = r'(\d{4})(\d{2})(\d{2}) (\d{2}:\d{2}:\d{2})'
|
||||
return re.sub(pattern, r'\1/\2/\3 \4', date_str)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
</header>
|
||||
<group>
|
||||
<group>
|
||||
<field name="selection_bank"/>
|
||||
<field name="excel_file" filename="excel_name"/>
|
||||
<field name="excel_name" invisible="1"/>
|
||||
</group>
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
'wizard/choose_contract_wizard_views.xml',
|
||||
'wizard/property_reconciliation_wizard_views.xml',
|
||||
'wizard/property_rental_wizard_views.xml',
|
||||
'wizard/property_penalty_wizard_views.xml',
|
||||
'views/property_menu_all.xml',
|
||||
],
|
||||
'demo': [],
|
||||
|
||||
@@ -25,7 +25,7 @@ class PropertyBankStatements(models.Model):
|
||||
for contract_id in record.contract_ids:
|
||||
receivable_id = self.env['property.accounts.receivable'].search([('contract_id', '=', contract_id.id)])
|
||||
if receivable_id:
|
||||
dt = datetime.strptime(str(record.start_time), '%Y-%m-%d').date()
|
||||
dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date()
|
||||
due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date()
|
||||
# 判断是否违约
|
||||
if receivable_id.due_date > record.start_time and receivable_id.is_reconciliation == False:
|
||||
@@ -60,18 +60,46 @@ class PropertyAccountsReceivable(models.Model):
|
||||
|
||||
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
|
||||
penalty = fields.Float(string="违约金")
|
||||
penalty_date = fields.Date(string="违约金日期")
|
||||
|
||||
@api.onchange('penalty_date')
|
||||
def _onchange_penalty_date(self):
|
||||
for record in self:
|
||||
if record.create_time and record.penalty_date:
|
||||
create_time = record.create_time
|
||||
dt = datetime.strptime(str(create_time), '%Y-%m-%d').date()
|
||||
new_month = dt.month + 1
|
||||
new_year = dt.year
|
||||
if new_month > 12:
|
||||
new_month = 1
|
||||
new_year += 1
|
||||
new_date = dt.replace(year=new_year, month=new_month, day=1)
|
||||
penalty_date = datetime.strptime(str(record.penalty_date), '%Y-%m-%d').date()
|
||||
if penalty_date.year == datetime.now().year - 1:
|
||||
raise UserWarning("选择的日期为去年的年份,请重新选择!")
|
||||
days_difference = (penalty_date - new_date).days
|
||||
penalty = days_difference * record.difference_amount
|
||||
record.write({'penalty': penalty})
|
||||
|
||||
def all_penalty_date(self):
|
||||
receivable_ids= self.env["property.accounts.receivable"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
||||
for receivable in receivable_ids:
|
||||
if receivable.receivable_id.create_time and receivable.penalty_date:
|
||||
create_time = receivable.receivable_id.create_time
|
||||
dt = datetime.strptime(str(create_time), '%Y-%m-%d').date()
|
||||
new_month = dt.month + 1
|
||||
new_year = dt.year
|
||||
if new_month > 12:
|
||||
new_month = 1
|
||||
new_year += 1
|
||||
new_date = dt.replace(year=new_year, month=new_month, day=1)
|
||||
penalty_date = datetime.strptime(str(receivable.penalty_date), '%Y-%m-%d').date()
|
||||
if penalty_date.year == datetime.now().year - 1:
|
||||
raise UserWarning("选择的日期为去年的年份,请重新选择!")
|
||||
days_difference = (penalty_date - new_date).days
|
||||
penalty = days_difference * receivable.receivable_id.difference_amount
|
||||
receivable.receivable_id.write({'penalty': penalty})
|
||||
|
||||
def button_penalty(self):
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"name": "违约金弹窗",
|
||||
"res_model": "property.penalty.wizard",
|
||||
"view_mode": "form",
|
||||
"target": "new",
|
||||
"context": {
|
||||
'default_receivable_id': self.id,
|
||||
}
|
||||
}
|
||||
|
||||
def receivable_return(self):
|
||||
model_type_data = {
|
||||
|
||||
@@ -88,7 +88,6 @@ access_property_borrowing_approval,property_borrowing_approval,model_property_bo
|
||||
access_yuthon_borrowing_line,yuthon_borrowing_line,model_yuthon_borrowing_line,base.group_user,1,1,1,1
|
||||
access_property_claim_approval,property_claim_approval,model_property_claim_approval,base.group_user,1,1,1,1
|
||||
access_property_claim_line,property_claim_line,model_property_claim_line,base.group_user,1,1,1,1
|
||||
access_property_penalty_wizard,property_penalty_wizard,model_property_penalty_wizard,base.group_user,1,1,1,1
|
||||
access_property_reconciliation_wizard,property_reconciliation_wizard,model_property_reconciliation_wizard,base.group_user,1,1,1,1
|
||||
access_property_reconciliation_line,property_reconciliation_line,model_property_reconciliation_line,base.group_user,1,1,1,1
|
||||
|
||||
|
||||
|
@@ -314,11 +314,18 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='difference_amount']" position="after">
|
||||
<field name="penalty"/>
|
||||
<button name="button_penalty" string="违约金" type="object" class="oe_highlight"/>
|
||||
<field name="penalty_date"/>
|
||||
<button name="receivable_return" string="退回" class="btn-primary" type="object"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="all_button_accounts_receivable" model="ir.actions.server">
|
||||
<field name="name">批量生成违约金</field>
|
||||
<field name="model_id" ref="yuthon_property.model_property_accounts_receivable"/>
|
||||
<field name="binding_model_id" ref="yuthon_property.model_property_accounts_receivable"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.all_penalty_date()</field>
|
||||
</record>
|
||||
<record id="all_button_return_property" model="ir.actions.server">
|
||||
<field name="name">批量退回</field>
|
||||
<field name="model_id" ref="yuthon_property.model_property_accounts_receivable"/>
|
||||
|
||||
@@ -3,5 +3,4 @@ from . import choose_property_wizard
|
||||
from . import property_rental_wizard
|
||||
from . import property_add_wizard
|
||||
from . import property_physical_wizard
|
||||
from . import property_penalty_wizard
|
||||
from . import property_reconciliation_wizard
|
||||
@@ -1,28 +0,0 @@
|
||||
from odoo import models, fields, api, _, SUPERUSER_ID
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
class PropertyPenaltyWizard(models.Model):
|
||||
_name = 'property.penalty.wizard'
|
||||
_description = '违约金弹窗'
|
||||
|
||||
select_time_date = fields.Date(string='选择日期')
|
||||
receivable_id = fields.Many2one('property.accounts.receivable', string='关联应收列表')
|
||||
|
||||
def confirm(self):
|
||||
for record in self:
|
||||
if record.receivable_id.create_time:
|
||||
create_time = record.receivable_id.create_time
|
||||
dt = datetime.strptime(str(create_time), '%Y-%m-%d').date()
|
||||
new_month = dt.month + 1
|
||||
new_year = dt.year
|
||||
if new_month > 12:
|
||||
new_month = 1
|
||||
new_year += 1
|
||||
new_date = dt.replace(year=new_year, month=new_month, day=1)
|
||||
select_date = datetime.strptime(str(record.select_time_date), '%Y-%m-%d').date()
|
||||
if select_date.year == datetime.now().year - 1:
|
||||
raise UserWarning("选择的日期为去年的年份,请重新选择!")
|
||||
days_difference = (select_date - new_date).days
|
||||
penalty = days_difference * record.receivable_id.difference_amount
|
||||
record.receivable_id.write({'penalty': penalty})
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="property_penalty_wizard_form" model="ir.ui.view">
|
||||
<field name="name">property.penalty.wizard.form</field>
|
||||
<field name="model">property.penalty.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="违约金弹窗">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="select_time_date"/>
|
||||
<field name="receivable_id"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="confirm" string="确认" type="object" class="oe_highlight"/>
|
||||
<button string="返回" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user