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

I want create a view in mrp. 

VIEW:

<page string="Controle da Qualidade">

    <tree editable="bottom" delete="0" create="0">

        <field name="qualidade_id" required="1"/>

         <field name="qualidade_resultado" required="0"/>

     </tree>

</page>


MODEL:

qualidade_id = fields.Many2one('tr.qualidade',  'Item da Qualidade',  index=True,  help="Item da qualidade que será avaliado.")

qualidade_resultado = fields.Char('Resultado', default="Não medido")


Result: https://imgur.com/6p6cBh0

What i want: https://imgur.com/SLCz7TC


Avatar
Discard

Thanks, this solves the problem with name. 

How a make a tree view (table with all registers)

Best Answer

give the _rec_name for your many2one model. here is an example done for pos product lines. GIve field name needed to display on rec_name

class PosOrderLine(models.Model):
_name = "pos.order.line"
_description = "Lines of Point of Sale"
_rec_name = "product_id"

or you should override the name_get method for your custom model. for eg:

@api.multi
def name_get(self):
if not self._context.get('employee_id'):
# leave counts is based on employee_id, would be inaccurate if not based on correct employee
return super(HolidaysType, self).name_get()
res = []
for record in self:
name = record.name
if not record.limit:
name = "%(name)s (%(count)s)" % {
'name': name,
'count': _('%g remaining out of %g') % (record.virtual_remaining_leaves or 0.0, record.max_leaves or 0.0)
}
res.append((record.id, name))
return res

This is the display set for showing remaining leaves in Leave Request's leave type selection.

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 15
7333
1
Mar 15
3784
0
Oct 24
3
4
Jan 24
20574
2
Jan 24
769