添加功能

This commit is contained in:
zhou
2025-01-08 19:39:41 +08:00
parent 548dcd338b
commit e2b858cb6e
7 changed files with 96 additions and 21 deletions
+5 -2
View File
@@ -9,8 +9,11 @@ class PropertyRentList(models.Model):
property_id = fields.Many2one('yuthon.property', string='物业')
lessee_id = fields.Many2one('property.tenant.information', string='承租方')
due_date = fields.Date(string='应收日期')
year = fields.Char(string='所属年')
month = fields.Char(string='所属月')
year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2060)], string='所属年',)
month = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
('9', '九月'), ('10', '十月'), ('11', '十一月'),
('12', '十二月')], string='选择月份')
original_amount = fields.Float(string='原金额')
discount_amount = fields.Float(string='减免金额')
remark = fields.Text(string='备注')
+1
View File
@@ -52,6 +52,7 @@
'views/inherit_yuthon_property_views.xml',
'wizard/property_contract_wizard.xml',
'wizard/choose_contract_wizard_views.xml',
'wizard/property_rental_wizard_views.xml',
'views/property_menu_all.xml',
],
'demo': [],
@@ -297,26 +297,20 @@ class PropertyLeaseContract(models.Model):
def action_generate_rental_charges(self):
"""
生成租金费用明细
跳转租金费用弹窗
:return:
"""
for record in self:
if not record.term_start_time:
raise UserError(_("请填写租期开始时间!"))
if not record.term_end_time:
raise UserError(_("请填写租期结束时间!"))
self.sudo().env["property.rent.list"].search([("contract_id", "=", record.id)]).unlink()
return {
'name': '租金费用弹窗',
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'property.rental.wizard',
'target': 'new',
'context': {
'default_lease_contract_id': self.id,
}
}
start_date = record.term_start_time
end_date = record.term_end_time + relativedelta(days=1)
all_period_rent = record.do_generate_details_core(start_date, end_date)
self.sudo().env["property.rent.list"].create({
"contract_id": record.id,
"contract_code": record.code,
"due_date": start_date,
"original_amount": all_period_rent,
})
def action_generate_administrative_expenses(self):
"""
@@ -63,4 +63,5 @@ access_property_contract_wizard,property_contract_wizard,model_property_contract
access_property_subset_contract,property_subset_contract,model_property_subset_contract,base.group_user,1,1,1,1
access_property_contract_line,property_contract_line,model_property_contract_line,base.group_user,1,1,1,1
access_choose_property_wizard,choose_property_wizard,model_choose_property_wizard,base.group_user,1,1,1,1
access_choose_property_wizard,choose_property_wizard,model_choose_property_wizard,base.group_user,1,1,1,1
access_property_rental_wizard,property_rental_wizard,model_property_rental_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
63 access_property_subset_contract property_subset_contract model_property_subset_contract base.group_user 1 1 1 1
64 access_property_contract_line property_contract_line model_property_contract_line base.group_user 1 1 1 1
65 access_choose_property_wizard choose_property_wizard model_choose_property_wizard base.group_user 1 1 1 1
66 access_property_rental_wizard property_rental_wizard model_property_rental_wizard base.group_user 1 1 1 1
67
+2 -1
View File
@@ -1,2 +1,3 @@
from . import property_contract_wizard
from . import choose_property_wizard
from . import choose_property_wizard
from . import property_rental_wizard
@@ -0,0 +1,50 @@
from odoo import models, fields, api, _, SUPERUSER_ID
from odoo.exceptions import UserError, ValidationError
from dateutil.relativedelta import relativedelta
class PropertyRentalWizard(models.Model):
_name = 'property.rental.wizard'
_description = '租金明细弹窗'
lease_contract_id = fields.Many2one('property.lease.contract', string="合同")
select_month = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
('9', '九月'), ('10', '十月'), ('11', '十一月'),
('12', '十二月')], string='选择月份')
select_year = fields.Selection(selection=[(str(i), str(i)) for i in range(2024, 2060)], string='选择年份')
def confirm(self):
"""
'生成租金明细‘
:return:
"""
for record in self.lease_contract_id:
if not record.term_start_time:
raise UserError(_("请填写租期开始时间!"))
if not record.term_end_time:
raise UserError(_("请填写租期结束时间!"))
rent_id = self.sudo().env["property.rent.list"].search([("contract_id", "=", record.id)])
start_date = record.term_start_time
end_date = record.term_end_time + relativedelta(days=1)
all_period_rent = record.do_generate_details_core(start_date, end_date)
if not rent_id:
self.sudo().env["property.rent.list"].create({
"contract_id": record.id,
"contract_code": record.code,
"due_date": start_date,
"original_amount": all_period_rent,
"year": self.select_year,
'month': self.select_month,
})
else:
rent_id.write({
"contract_id": record.id,
"contract_code": record.code,
"due_date": start_date,
"original_amount": all_period_rent,
"year": self.select_year,
'month': self.select_month,
})
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="property_rental_wizard_form" model="ir.ui.view">
<field name="name">生成租金明细弹窗</field>
<field name="model">property.rental.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="lease_contract_id"/>
<field name="select_month"/>
<field name="select_year"/>
</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>