Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4250 Vistas

Odoo 14 EE

View: account.move.form

I want to set a conditional domain on the field "res_partner" in account.move.form.

If the "move_type" is "out_invoice" or "out_receipt", the domain would be "[('example0','=',1)]".

If not one of those types, the domain would be "[('example1','=',1)]".

How do I do this?

Avatar
Descartar
Mejor respuesta

Hi Russ:

Try this

['|', '&', ('move_type', 'in', ['out_invoice','out_receipt']), ('example0', '=', 1), 
  '&', ('move_type', 'not in', ['out_invoice','out_receipt']), ('example1', '=', 1)]

This should translate into

(move_type is 'out_invoice' or 'out_receipt) AND (example0 = '1') 
OR
(move_type is not 'out_invoice' or 'out_receipt) AND (example1 = '1')

NOTE: You may need to use '&' in place of '&' if you are putting this in XML.

Avatar
Descartar
Mejor respuesta

Hello Russ Schneider,

Please refer below method for set conditional domain on res_partner based on move_type in account_move

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
domain = "[('example1','=',1)]"
res = super(AccountMove, self).fields_view_get(view_id=view_id, view_type=view_type,
toolbar=toolbar, submenu=submenu)
if self._context.get('default_move_type') in ['out_invoice', 'out_receipt'] \
and self._context.get('view_type') == 'form':
if res.get('fields', False):
if 'res_partner' in res.get('fields'):
domain = "[('example0','=',1)]"
res['fields']['res_partner']['domain'] = domain
else:
if 'res_partner' in res.get('fields'):
res['fields']['res_partner']['domain'] = domain
return res

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
dic 20
13828
1
jul 22
2483
1
jul 22
10990
0
sept 21
214
1
jun 21
3726