From 51e9ff14912ae0de4552063761fcfad938bf7aa4 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sat, 5 Oct 2024 07:50:17 +0300 Subject: [PATCH] Update internal_transaction.py --- .../models/internal_transaction.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/odex25_transactions/exp_transaction_documents/models/internal_transaction.py b/odex25_transactions/exp_transaction_documents/models/internal_transaction.py index 678bd6d29..b1af3dfb5 100644 --- a/odex25_transactions/exp_transaction_documents/models/internal_transaction.py +++ b/odex25_transactions/exp_transaction_documents/models/internal_transaction.py @@ -27,11 +27,14 @@ class InternalTransaction(models.Model): @api.onchange('type_sender') def _onchange_type_sender(self): - if self.to_ids: + self.ensure_one() + if self.type_sender == 'unit' and self.to_ids and self.to_ids.type != 'unit': self.to_ids = False - if self.partner_id: - self.partner_id =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') cc_ids = fields.Many2many(comodel_name='cm.entity', relation='internal_entity_cc_rel',