Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

import a field from product to my module

By
Xleth Yireh
on 6/2/14, 12:13 PM 690 views

Hello! i try to import a field from the product module to my module, but when i try it, it appears all the product data and not just the field i want, here is the code of the .py file:

 

class student(osv.osv):
    _name = 'student'
    _rec_name = 'default_code'
    _columns = {
        'name': fields.char('name',size=30,required=True, help='the name'),
        'first_name': fields.char('first name',size=30,required=True, help='the first name'),
        'birth_date': fields.date('birth date',size=30,required=True, help='the birth date'),
        'email': fields.char('email', help='the email'),
        'phone': fields.integer('phone',size=30, help='the phone'),
        'sexo': fields.selection([('m','Masculino'),('f','Femenino')],'Sexo',help="Opcion sexual"),
        'product': fields.many2one('product.product','cantidad', help='the Specialty'),

    }
student()

And my view:

<record model="ir.ui.view" id="view_student_form">
                <field name="name">student.form</field>
                <field name="model">student</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="student">
                        <group col="1" colspan="2">
                            <field name='image_medium' widget='image' />
                        </group>
                        <group col="2" colspan="2">
                            <field name="name" select="1"/>
                            <field name="first_name" select="2"/>
                            <field name="phone" />
                        </group>
                        <group col="2" colspan="2">
                            <field name="birth_date" select="0"/>
                            <field name="email" select="0"/>
                            <field name='sexo'/>
                        </group>
                        <notebook colspan="4">
                            <page string="stock">
                                <field name="product" select="0" widget='many2one_list'/>
                            </page>
                        </notebook>

And this is how it appears: http://drasticelanik.comoj.com/product.jpg

it appears the name field and not the default_code field.

I'm doing something wrong?

In the student table you define _rec_name = 'default_code' its wrong. to Inherit product.product table and define _rec_name or using override name_get method in the product.product class and display the default_code.

Prakash
on 6/3/14, 1:49 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 6/2/14, 12:13 PM
Seen: 690 times
Last updated: 3/16/15, 8:10 AM