Skip to Content
Menu
This question has been flagged
3 Replies
2571 Views

Hello folks.
I have a model on my odoo that is populate by a XML when it is upgrade/installed.
I am trying to get the values of a column of this model to make a selection list into a form.

class ChargeRule(models.Model):
"""
Class storing line item charge type lookup for Finance table logic .
"""
_name = 'guimarc.linechargerule'
line_type = fields.Char('line_type', required=True)
loc = fields.Char('loc', required=True)
prod_type = fields.Char('prod_type', required=True)
cost_element = fields.Char('cost_element', required=True)

So I want create a form that will have the field called cost element as well for the user be able to create a new entry.
However the entry only can be allowed with the names that are already stored into the guimarc.linechargerule.

1 - I have put this on the new model :
cost_element = fields.Many2one('ibmfinance.linechargerule',string='cost_element')

2 - On my form I have created like this :
<form string="Fiance master cost" create="true" editable="top" delete="true">
<sheet string="Finance Master Cost">
<group>
<group>
<field name="cost_element"/> ---- HERE
<field name="loc"/>
<field name="cost"/>
<field name="created_by"/>
<field name="activate_date"/>
</group>
</group>
</sheet>
</form
so when I open my form it comes a drop LIST however with the IDS only like guimarc.linechargerule,1 guimarc.linechargerule,2 and etc.
 I would like to see on the field the value of cost_element not the IDS.. the values of cost element.
Could you please help me on that?
Thank you so much team

Avatar
Discard

If I understand correctly, try this

<field name="cost_element">

<tree name="cost">

<field name="cost_element"/>

</tree>

</field>

Best Answer

If I understand correctly, you have a problem  with definition of model ibmfinance.linechargerule
In this model, you should define a field named name or add the _rec_name parameter to the class definition.

_rec_name name by default looks for name field, if name field is not available then it will display like your model_name,db_id , so we have to pass at least one field to _rec_name in case of no name field.

Avatar
Discard
Author Best Answer

I tried it but not worked.
What I am trying is when I use the many2one it give back to me  a list of IDS  of all entries that I have in the guimarcfinance.linechargerule and then this becomes a drop list in the form with only the IDS. what I want is get the drop list but with the value for these ids from cost_element  column, not the IDS.

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 22
7402
1
Jun 21
1057
2
Feb 21
299
5
Sep 20
12740
4
Jun 20
48215