Update internal_transaction.py

This commit is contained in:
zainab2097 2024-10-05 07:53:56 +03:00 committed by GitHub
parent 51e9ff1491
commit b006a1880b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 5 deletions

View File

@ -27,13 +27,22 @@ class InternalTransaction(models.Model):
@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':
# تعيين الدومين لحقل to_ids بناءً على النوع المختار
if self.type_sender == 'unit':
return {
'domain': {'to_ids': [('type', '=', 'unit')]}
}
elif self.type_sender == 'employee':
return {
'domain': {'to_ids': [('type', '=', 'employee')]}
}
# إعادة تعيين القيم بعد تغيير الدومين
if self.to_ids:
self.to_ids = False
if self.partner_id:
self.partner_id = False
partner_id = fields.Many2one('res.partner', string='Partner', readonly=True,
related='to_ids.secretary_id.partner_id')