Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
2389 Tampilan

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
Buang
Penulis Jawaban Terbai

Hi ,

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

With Regards,

Debendra Ray

Avatar
Buang

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
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
5
Feb 20
9099
1
Des 19
6075
1
Mar 16
4170
4
Mar 24
1673
0
Feb 24
1129