Skip to Content
Menu
This question has been flagged

I have created a model:

from odoo import models, fields, api

class ArticleNumber(models.Model):
_name = "article.number"
_description = "Article Number"

name = fields.Char('Name', index=True, required=True, translate=True)
article_number = fields.Char()
product_id = fields.Many2one('product.product', string="Product")
date = fields.Date()


Now when I load that in, inside the sale.order.line with this:

from odoo import models, fields, api


class SaleOrder(models.Model):
_inherit = "sale.order"


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

article_id = fields.Many2one('article.number', 'Article Number', change_default=True, ondelete='restrict')

and here in the view:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<record
id="sale_order_form" model="ir.ui.view">
<field
name="name">sale.order.form</field>
<field
name="model">sale.order</field>
<field
name="inherit_id" ref="sale.view_order_form"/>
<field
name="arch" type="xml">
<xpath
expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='name']" position="after">
<field
name="article_id"/>
</xpath>
</field>
</record>

</data>
</odoo>


I get this back: 



I only want the Name there, not the object,id 


What is wrong here?







Avatar
Discard
Best Answer

Hello, in your article.number model give _rec_name = 'name'

 class ArticleNumber(models.Model):

    _name = "article.number"
        _rec_name = 'name' 

or

<xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='name']" position="after">
<field name="article_id.name"/>
</xpath>
Avatar
Discard
Related Posts Replies Views Activity
0
Feb 18
3718
2
Jan 24
3671
0
Jun 23
940
0
Mar 23
1536
1
Dec 22
1958