添加功能

This commit is contained in:
李鹏宇
2026-04-28 15:08:16 +08:00
parent 0909d090ac
commit 473254e919
5 changed files with 28 additions and 31 deletions
@@ -58,6 +58,7 @@
<header>
<button name="all_meeting_issue" type="object" string="会议安排" class="oe_highlight" groups="yuthon_salary.group_lc_user"/>
</header>
<field name="code"/>
<field name="name" column_invisible="1"/>
<field name="is_meeting" column_invisible="1"/>
<field name="department_id"/>
@@ -2517,11 +2517,26 @@ class PropertyLeaseContractLine(models.Model):
address_id = fields.Many2one('yuthon.property', string="物业地址")
tax = fields.Float(related='address_id.tax',string="税率")
admin_line_id = fields.Many2one(related='address_id.admin_id', string="管理员", store=True)
property_area = fields.Float(related='address_id.rent_area', string="可租面积", store=True)
property_area = fields.Float(string="可租面积", compute="_compute_property_area")
message_standard_id = fields.Many2one(related='address_id.message_standard_id', string="管理费标准", store=True)
message_unit = fields.Float(related='message_standard_id.amount', string="管理费单价", store=True)
evaluate_unit_price = fields.Float(string="评估单价")
@api.depends('address_id', 'address_id.manage_information_ids')
def _compute_property_area(self):
today = fields.Date.today()
for line in self:
rent_area = 0.0
if line.address_id:
valid_lines = line.address_id.manage_information_ids.filtered(
lambda r:
r.start_time <= today
and (not r.end_date or r.end_date >= today)
)
if valid_lines:
rent_area = valid_lines[0].rent_area
line.property_area = rent_area
def open_record(self):
self.ensure_one()
@@ -11,7 +11,7 @@
<field name="lease_contract_id" invisible="1"/>
<field name="open_rent_id" invisible="1"/>
<field name="contract_sort" invisible="1"/>
<field name="property_ids" widget="many2many_tags" context="{'search_view_ref': 'yuthon_property.yuthon_property_search'}" options="{'no_create': True}" domain="[('id', 'not in', property_ids2), ('property_type', '=', contract_sort)] if not open_rent_id else [('id', 'not in', property_ids2)]"/>
<field name="property_ids" widget="many2many_tags" context="{'search_view_ref': 'yuthon_property.yuthon_property_search'}" options="{'no_create': True}" domain="[('id', 'not in', property_ids2)]"/>
<field name="property_ids2" widget="many2many_tags" invisible="1"/>
</group>
<group/>
+9 -28
View File
@@ -29,7 +29,12 @@ class SalaryFieldConfig(models.TransientModel):
]
def action_sync(self):
config_fields = self.env[self._dynamic_field_config].search([('active', 'in', [True, False])])
# 👇 只获取当前选中的配置行
record_ids = self.env["salary.field.config"].browse(
self._context.get('active_ids', self._context.get('active_id'))
)
config_fields = record_ids.filtered(lambda r: r.active in [True, False])
model_id = self.env['ir.model'].search([('model', '=', self._dynamic_field_model)])
if not config_fields or not model_id:
@@ -53,18 +58,6 @@ class SalaryFieldConfig(models.TransientModel):
for field in new_config_fields:
field.symbol = f'{self._dynamic_field_prefix}{field.id}'
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('同步字段'),
'message': _(f'成功同步 {len(new_fields)} 个薪资自定义字段。'),
'type': 'success',
'sticky': False,
'next': {'type': 'ir.actions.client', 'tag': 'reload'},
},
}
def update_dynamic_fields(updated_config_fields):
updated_count = 0
for field in updated_config_fields:
@@ -80,18 +73,6 @@ class SalaryFieldConfig(models.TransientModel):
})
updated_count += 1
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('同步字段'),
'message': _(f'成功更新 {updated_count} 个薪资自定义字段。'),
'type': 'success',
'sticky': False,
'next': {'type': 'ir.actions.client', 'tag': 'reload'},
},
}
exist_dynamic_names = dynamic_fields.mapped('name')
exist_ids = [int(e.replace(self._dynamic_field_prefix, '')) for e in exist_dynamic_names if
e.replace(self._dynamic_field_prefix, '').isdigit()]
@@ -99,19 +80,19 @@ class SalaryFieldConfig(models.TransientModel):
# 处理新字段
new_config_ids = [field.id for field in config_fields if field.id not in exist_ids]
if new_config_ids:
create_dynamic_fields(self.search([('id', 'in', new_config_ids)]))
create_dynamic_fields(self.browse(new_config_ids))
# 处理更新字段
updated_config_ids = [field.id for field in config_fields if field.id in exist_ids]
if updated_config_ids:
update_dynamic_fields(self.search([('id', 'in', updated_config_ids)]))
update_dynamic_fields(self.browse(updated_config_ids))
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('同步完成'),
'message': _('所有薪资自定义字段已同步完成!'),
'message': _('选中的自定义字段已同步完成!'),
'type': 'success',
'sticky': False,
'next': {'type': 'ir.actions.client', 'tag': 'reload'},
@@ -6,7 +6,7 @@
<field name="arch" type="xml">
<tree editable="bottom">
<header>
<button name="action_sync" string="同步字段" type="object" class="btn btn-danger" display="always"/>
<button name="action_sync" string="同步字段" type="object" class="btn btn-danger"/>
</header>
<field name="name" readonly="symbol != False" string="字段名称"/>
<field name="field_type" string="字段类型"/>