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

Please provide resolution for the following error : 

ValueError: Wrong value for crm.lead.service: 

Appended is the code snippet causing this problem :

from odoo import models, fields, api

class mjcrm(models.Model):
_inherit = 'crm.lead'

service = fields.Selection([('fa', 'FA'),
('psms', 'PSMS'),
('parishkaran ', 'Parishkaran'),
('valuation', 'Valuation'),
('mjpro', 'mjPRO'),
('onlineStore', 'OnlineStore'),
('loyaltyprogram', 'LoyaltyProgram'),
('ra', 'RA'),
('as', 'AS'),
('mss', 'MSS'),
('cms', 'CMS'),
('psp', 'PSP'),
], string="BU Services", tracking=True)

@api.onchange('bu')
def onchange_bu(self):
#global service_selection
service_selection = []

if self.bu:
if self.bu == 'MetalJunction':
self.bu_head = 'Anup_Jagnania'
service_selection.append([('fa', 'FA'),
('psms', 'PSMS'),
('parishkaran ', 'Parishkaran')
])

Avatar
Descartar
Autor Mejor respuesta

Hi ,

Thank you for your reply - Please could you provide an example to illustrate your recommended solution?

With Regards,

Debendra Ray

Avatar
Descartar

if you need to write value to service field from any where,
you can write as follows: self.service = 'cms'

Hi,
This solution works for one value - Please could you confirm how to pass multiple Keys to the Selection Field in the Onchange function?

Thanks & Regards,

Debendra 

On Fri, Jul 14, 2023 at 1:37 PM Niyas Raphy <notifications@mail.odoo.com> wrote:
if you need to write value to service field from any where, you can write as follows: self.service = 'cms' ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​ ͏ ​

if you need to write value to service field from any where,
you can write as follows: self.service = 'cms'

--
Niyas Raphy


Odoo S.A.

+32 81 81 37 00 | info@odoo.com | https://www.odoo.com

Powered by Odoo
Mejor respuesta

Hi,

Could not find issue in the shared code snippet, anyway, the case is that when you update value to the service selection field, ensure that you are writing using the key of selection, rather than the value of selection.


Thanks

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
5
feb 20
9045
1
dic 19
6017
1
mar 16
4118
4
mar 24
1608
0
feb 24
1109