Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
3088 Ansichten

Hi all,

I would like to show the fields of product template from witin a sale_order_line.

More specific I want to show the description of the product_template for each order line.

I have these fields in my view:

<field name="x_product_template_id"/>

This field was added to sale_order_line via:

#table 'sale_order_line' (extended with fields we need) class sale_order_line(osv.osv): _name = 'sale.order.line' _inherit = 'sale.order.line' rec_name = 'name_template' _columns = { 'x_product_template_id': fields.many2one('product.template', 'Product template', required=False), } sale_order_line()

However: it still shows me a drop down with the products (the default fields) instead of the product template values...

How can I change my code to show for example the description of the product_template? I haven't got a clue about the right approach.

Thanks in advance, hope question is clear...

Wiebe

Avatar
Verwerfen

Search and Display Multiple Fields on Product Many2one (Quotation, SO, PO MO etc) Field
This module allows you to search and display multiple fields in the Product Many2one field across all Odoo screens - such as quotations, sale orders, purchase orders, invoices, and more.
https://www.youtube.com/watch?v=fF_U28ey0NU

Beste Antwort

Hi,

To show the actual field values (like description) from the product template instead of the default many2one dropdown in your sale order line, try with below code:


.py


class sale_order_line(osv.osv):

    _name = 'sale.order.line'

    _inherit = 'sale.order.line'

    _columns = {

        'x_product_template_id': fields.many2one('product.template', 'Product Template'),

        'product_template_description': fields.related(

            'x_product_template_id', 'description',

            type='text', string='Description', readonly=True, store=True),

        'product_template_name': fields.related(

            'x_product_template_id', 'name',

            type='char', string='Template Name', readonly=True, store=True),

    }


xml


<field name="product_template_name" readonly="1"/>

<field name="product_template_description" widget="html" readonly="1"/>


Hope it helps

Avatar
Verwerfen