[FIX] exp_transaction_documents: domain for employee in forward transaction

This commit is contained in:
Samir Ladoui 2024-12-26 14:18:53 +01:00
parent 5b1d792659
commit dee6cb34ad
2 changed files with 22 additions and 2 deletions

View File

@ -9,8 +9,13 @@
<group>
<group>
<field name="forward_type" required="True"/>
<field name="internal_unit" attrs="{'required': True}" domain="[('type','in',['unit'])]" options="{'no_open': True, 'no_create': True}"/>
<field name="employee" attrs="{'required': [('forward_type','=','employee')], 'invisible': [('forward_type','!=','employee')]}" domain="[('type','in',['employee']), ('parent_id','=',internal_unit)]" options="{'no_open': True, 'no_create': True}"/>
<field name="internal_unit"
attrs="{'required': True}"
domain="[('type','in',['unit'])]"
options="{'no_open': True, 'no_create': True}"/>
<field name="employee"
attrs="{'required': [('forward_type','=','employee')], 'invisible': [('forward_type','!=','employee')]}"
options="{'no_open': True, 'no_create': True}"/>
<field name="cc_ids" widget="many2many_tags"/>
<field name="note"/>
<field name="is_secret"/>

View File

@ -23,6 +23,21 @@ class ForwardTransactionWizard(models.TransientModel):
filename = fields.Char()
att_description = fields.Char(string='Attach Description')
@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)]
elif rec.forward_type == 'employee':
rec.employee = False
return {
"domain": {
"employee": domain
}
}
def action_forward(self):
transaction = ''
name = ''