Skip to Content
Menu
This question has been flagged
2 Replies
2333 Views

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

Hi ,

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

With Regards,

Debendra Ray

Avatar
Discard

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
Discard
Related Posts Replies Views Activity
5
Feb 20
9038
1
Dec 19
6015
1
Mar 16
4118
4
Mar 24
1604
0
Feb 24
1095