diff --git a/yuthon_property/models/property_accounts_receivable.py b/yuthon_property/models/property_accounts_receivable.py index 49a5f0e5b..854f8b4c3 100644 --- a/yuthon_property/models/property_accounts_receivable.py +++ b/yuthon_property/models/property_accounts_receivable.py @@ -60,6 +60,11 @@ class PropertyAccountsReceivable(models.Model): has_date = fields.Date(string='退款日期') delivered = fields.Boolean() submitted = fields.Float(string='未收', compute='compute_submitted', store=True) + # 欠费月数 = 当前日期 - 应收开始日期(按整月计,未到期为 0);不落库,随算随出 + overdue_months = fields.Integer(string='欠费月数', compute='_compute_overdue_months', + help='当前日期 - 应收开始日期,按整月计算;未到期为 0') + # 列表徽章展示用,形如「47 个月」 + overdue_months_display = fields.Char(string='欠费月数', compute='_compute_overdue_months') is_invalid = fields.Boolean(string='作废') void_date = fields.Date(string='作废日期') is_red = fields.Boolean(string='红冲') @@ -278,6 +283,20 @@ class PropertyAccountsReceivable(models.Model): else: record.submitted = 0 + @api.depends('due_date') + def _compute_overdue_months(self): + today = fields.Date.context_today(self) + for record in self: + months = 0 + if record.due_date: + delta = relativedelta(today, record.due_date) + months = delta.years * 12 + delta.months + if months < 0: + months = 0 + record.overdue_months = months + # 未到期(0)时留空,列表里的徽章自动隐藏 + record.overdue_months_display = ('%s 个月' % months) if months > 0 else '' + def initialize_wizard(self): return { 'name': '应收账单初始化数据弹窗', diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index 164fb8403..edfe4700f 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -511,40 +511,14 @@ property.accounts.receivable.tree.contract property.accounts.receivable + primary + due_date desc - -
-
-
- - -