Skip to Content
Menú
This question has been flagged
2 Respostes
2344 Vistes

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 Best Answer

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
Best Answer

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
Related Posts Respostes Vistes Activitat
5
de febr. 20
9055
1
de des. 19
6019
1
de març 16
4132
4
de març 24
1613
0
de febr. 24
1111