콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3118 화면

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

아바타
취소

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

베스트 답변

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

아바타
취소