Odoo Help


Inherit class and modify columns

Stefano De Rosso
on 1/29/16, 3:01 PM 554 views

I'm working on a module in Openerp, and I'd like to inherit a class from another module, but I don't need every single column that's in the other class.

This is my class:

class BookingManagement(orm.Model):
    _name = 'booking.management'

    _inherit = 'res.partner.address.contact'

    _description = 'Booking management'

    _columns = {
        'guests': fields.integer('Number of guests', required=True),
        'check_in': fields.date('From', required=True),
        'check_out': fields.date('To', required=True),
        'special_requests': fields.text('Special requests')

And this is res.partner.address.contact

class res_partner_address_contact(orm.Model):
    _name = "res.partner.address.contact"

    _description = "Address Contact"

    def [...]

    def [...]

    _columns = {
        'complete_name': fields.function(_name_get_full, string='Name', size=64, type="char", store=False, select=True),
        'name': fields.char('Name', size=64, ),
        'last_name': fields.char('Last Name', size=64, required=True),
        'first_name': fields.char('First Name', size=64),
        'mobile': fields.char('Mobile', size=64),
        'fisso': fields.char('Phone', size=64),
        'title': fields.many2one('res.partner.title', 'Title', domain=[('domain', '=', 'contact')]),
        'website': fields.char('Website', size=120),
        'address_id': fields.many2one('res.partner.address', 'Address'),
        'partner_id': fields.related(
            'address_id', 'partner_id', type='many2one', relation='res.partner', string='Main Employer'),
        'lang_id': fields.many2one('res.lang', 'Language'),
        'country_id': fields.many2one('res.country', 'Nationality'),
        'birthdate': fields.char('Birthdate', size=64),
        'active': fields.boolean('Active', help="If the active field is set to False,\
                 it will allow you to hide the partner contact without removing it."),
        'email': fields.char('E-Mail', size=240),
        'comment': fields.text('Notes', translate=True),
        'photo': fields.binary('Photo'),
        'function': fields.char("Function", size=64),
        'function_id': fields.many2one('res.contact.function', 'Function'),

    def [...]

Let's say that the only columns I need are 'last_name', 'first_name', 'email' and 'mobile'.
How do I do that?

Thank you!

Krupesh Laiya
On 1/30/16, 4:29 AM

Create a new view and put your required fields in new view or you can make invisible those fields which are not required in your requirements.

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/29/16, 3:01 PM
Seen: 554 times
Last updated: 1/30/16, 4:29 AM