diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index 6b3770bad..b85757290 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -274,6 +274,13 @@ class YuthonProperty(models.Model): "target": "new", } + def trigger_company_id(self): + property_ids = self.env["yuthon.property"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for record in property_ids: + company_id = record.lease_ids[0].address_id.company_id.id if record.lease_ids else '' + record.company_id = company_id + class YuthonPropertyWater(models.Model): _name = 'yuthon.property.water' _description = '水表' diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index e2cea7cab..2bc469a52 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -357,4 +357,11 @@ code action = model.action_yuthon_property_wizard() + + 更新公司 + + + code + action = model.trigger_company_id() + \ No newline at end of file diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 6b53ad469..17c702e0f 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -488,7 +488,7 @@ class PropertyLeaseContract(models.Model): property_ids = self.env["property.lease.contract"].browse(self._context.get('active_ids', self._context.get('active_id'))) for record in property_ids: company_id = record.lease_ids[0].address_id.company_id.id if record.lease_ids else '' - record.company_id = company_id + record.write({'company_id': company_id}) def action_yuthon_property_contract_wizard(self): return {