Skip to Content
Menu
This question has been flagged
2 Replies
15173 Views
Traceback:
TypeError: value.split is not a function
    at Class._getDisplayName (http://localhost:8099/web/content/417-9eb0f92/web.assets_backend.js:1036:101)
    at http://localhost:8099/web/content/417-9eb0f92/web.assets_backend.js:1041:219
    at Function._.map._.collect (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:13:270)
    at Object.<anonymous> (http://localhost:8099/web/content/417-9eb0f92/web.assets_backend.js:1041:186)
    at Object.<anonymous> (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:802:681)
    at fire (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:796:299)
    at Object.fireWith [as resolveWith] (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:801:198)
    at Object.deferred.<computed> [as resolve] (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:803:56)
    at Object.<anonymous> (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:3869:358)
    at Object.<anonymous> (http://localhost:8099/web/content/383-91f685c/web.assets_common.js:802:681)



CODE :

class HRContributionTechIndustry(models.Model): _name = 'hr.contribut.tech' _description = 'Contributions to Tech Industry' tech_contribut = fields.Selection([ ('commi', 'International/National Tech Committees'), ('judge', 'Judge/Assessor/Mentor/Author/Speaker of Tech-related Awards, Programmes or Events'), ], string='Tech Industry') name_commi = fields.Char(string='Name of Tech-related Committee', required=False) name_judge = fields.Char(string='Judge/Assessor/Mentor/Author/Speaker of Tech-related Awards, Programmes or Events', required=False) position_judge = fields.Selection([ ('judge', 'Judge'), ('assessor', 'Assessor'), ('author', 'Author'), ('mentor', 'Mentor'), ('speaker', 'Speaker'), ('other', 'Others') ],string='Position') position_commi = fields.Selection([ ('chairman', 'Chairman'), ('cmember', 'Committe Member'), ('other', 'Others') ],string='Position') please_specify = fields.Char('Please Specify') period_start =fields.Date('Start Date') period_end =fields.Date('End Date') @api.model def name_get(self): for select in self : if select.tech_contribut == 'commi' : res = [] for rec in self : name = rec.name_commi res.append((rec.id, name)) return res else : res = [] for rec in self : name = rec.name_judge res.append((rec.id, name)) return res



XML >>>

record model="ir.ui.view" id="hr_contributtech_form_view"> <field name="name">hr.contribut.tech.form</field> <field name="model">hr.contribut.tech</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Contributions to Tech Industry"> <sheet> <group> <field name="tech_contribut" required='1'/> <field name="name_commi" attrs="{'invisible': [('tech_contribut', '!=', 'commi')], 'required': [('tech_contribut', '=', 'commi')]}"/> <field name="name_judge" attrs="{'invisible': [('tech_contribut', '!=', 'judge')], 'required': [('tech_contribut', '=', 'judge')]}"/> <field name="position_judge" attrs="{'invisible': [('tech_contribut', '!=', 'judge')], 'required': [('tech_contribut', '=', 'judge')]}"/> <field name="position_commi" attrs="{'invisible': [('tech_contribut', '!=', 'commi')], 'required': [('tech_contribut', '=', 'commi')]}"/> <field name="please_specify" attrs="{'invisible': [('position_judge', '!=', 'other')], 'required': [('position_judge', '=', 'other')]}"/> <field name="please_specify" attrs="{'invisible': [('position_commi', '!=', 'other')], 'required': [('position_commi', '=', 'other')]}"/> <field name="period_start" required='True'/> <field name="period_end" required='1'/> </group> </sheet> </form> </field> </record> <record id="hr_contributtech_search_view" model="ir.ui.view"> <field name="name">hr.contribut.tech.search</field> <field name="model">hr.contribut.tech</field> <field name="arch" type="xml"> <search string="Event Name"> <field name="name_commi"/> <field name="name_judge"/> </search> </field> </record> <record model="ir.actions.act_window" id="action_hr_contributtech"> <field name="name">Contributions to Tech Industry</field> <field name="type">ir.actions.act_window</field> <field name="res_model">hr.contribut.tech</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="view_id" ref="hr_contributtech_tree_view"/> <!--<field name="search_view_id" ref="hr_contributtech_search_view"/>--> </record> <menuitem action="action_hr_contributtech" id="menu_hr_contributtech" parent="menu_participant_config" sequence="15"/>

Avatar
Discard

Update your code to the latest version. If the issue is still here then please report it at https://github.com/odoo/odoo

Best Answer

Hello Chaanto,


Please try below code:

@api.multi
def name_get(self):
    result = []
    for select in self:
        if select.tech_contribut == 'commi' :
            name = rec.name_commi
        else:
            name = rec.name_judge
        result.append((select.id, name))
    return result


Hope it will works for you.

Thanks,

Avatar
Discard
Author

Hello Jignesh Mehta,

i already tried it before but it still got an error.

Uncaught TypeError: Cannot read property 'split' of undefined

Best Answer

Hello Chaanto,
    This issue is because in the  name  you are not using type string

@ api.multi
def name_get (self):
    result = []
    for select in self:
        if select.tech_contribut == 'commi':
            name = rec.name_commi
        else:
            name = rec.name_judge
        result.append ((select.id, name)) # In this 'name' field should be string
    return result

Please try the above code It will works
Thanks

Avatar
Discard
Related Posts Replies Views Activity
3
Dec 19
12530
0
Nov 21
1988
1
Nov 19
3695
0
Jan 22
2679
1
Aug 19
13783