Update internal_transaction.py

This commit is contained in:
zainab2097 2024-10-05 12:13:53 +03:00 committed by GitHub
parent b17de8915c
commit b3bfe592ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,16 @@ class InternalTransaction(models.Model):
to_ids = fields.Many2one(comodel_name='cm.entity', string='Send To')
@api.onchange('type_sender')
def _onchange_type_sender(self):
self.ensure_one()
if self.type_sender == 'unit' and self.to_ids and self.to_ids.type != 'unit':
self.to_ids = False
self.partner_id = False
elif self.type_sender == 'employee' and self.to_ids and self.to_ids.type != 'employee':
self.to_ids = False
self.partner_id = False
partner_id = fields.Many2one('res.partner', string='Partner', readonly=True,
related='to_ids.secretary_id.partner_id')