Merge pull request #5309 from expsa/khazraji_transaction

farward
This commit is contained in:
mohammed-alkhazrji 2025-11-10 02:05:06 -08:00 committed by GitHub
commit 93f9df2ce2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 7 deletions

View File

@ -24,19 +24,33 @@ class ForwardTransactionWizard(models.TransientModel):
filename = fields.Char()
att_description = fields.Char(string='Attach Description')
@api.onchange('employee', 'forward_type')
def _onchange_employee_set_internal_unit(self):
for rec in self:
if rec.forward_type == 'employee' and rec.employee and not rec.internal_unit:
rec.internal_unit = rec.employee.parent_id
if rec.forward_type == 'unit' and rec.employee:
rec.employee = False
@api.onchange('internal_unit', 'forward_type')
def _get_valid_employee_ids(self):
for rec in self:
domain = []
if rec.forward_type == 'employee' and rec.internal_unit:
domain = [('id', 'in', rec.env['cm.entity'].search([('type', '=', 'employee'), ('parent_id', '=', rec.internal_unit.id)]).ids)]
rec.employee = False
return {
"domain": {
"employee": domain
}
}
domain = [
('type', '=', 'employee'),
('parent_id', '=', rec.internal_unit.id),
]
if rec.employee:
if rec.forward_type == 'unit':
rec.employee = False
elif rec.forward_type == 'employee' and rec.internal_unit:
if rec.employee.parent_id.id != rec.internal_unit.id:
rec.employee = False
return {"domain": {"employee": domain}}
def action_forward(self):
transaction = ''