diff --git a/yuthon_property/models/property_rent_list.py b/yuthon_property/models/property_rent_list.py index ea677dfa0..01d7ca468 100644 --- a/yuthon_property/models/property_rent_list.py +++ b/yuthon_property/models/property_rent_list.py @@ -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='备注') diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py index 9086bb620..90c34510e 100644 --- a/yuthon_property_approval/__manifest__.py +++ b/yuthon_property_approval/__manifest__.py @@ -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': [], diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 6acda06f9..c3e1064a1 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -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): """ diff --git a/yuthon_property_approval/security/ir.model.access.csv b/yuthon_property_approval/security/ir.model.access.csv index b24bc771c..270c413c7 100644 --- a/yuthon_property_approval/security/ir.model.access.csv +++ b/yuthon_property_approval/security/ir.model.access.csv @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/yuthon_property_approval/wizard/__init__.py b/yuthon_property_approval/wizard/__init__.py index 8520c19ee..2d1e43bd2 100644 --- a/yuthon_property_approval/wizard/__init__.py +++ b/yuthon_property_approval/wizard/__init__.py @@ -1,2 +1,3 @@ from . import property_contract_wizard -from . import choose_property_wizard \ No newline at end of file +from . import choose_property_wizard +from . import property_rental_wizard \ No newline at end of file diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py new file mode 100644 index 000000000..bdc28573c --- /dev/null +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -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, + }) + + diff --git a/yuthon_property_approval/wizard/property_rental_wizard_views.xml b/yuthon_property_approval/wizard/property_rental_wizard_views.xml new file mode 100644 index 000000000..5aa23d587 --- /dev/null +++ b/yuthon_property_approval/wizard/property_rental_wizard_views.xml @@ -0,0 +1,25 @@ + + + + 生成租金明细弹窗 + property.rental.wizard + +
+ + + + + + + + + + + +
+
+
+
\ No newline at end of file