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.

1

How to control the order of fields in your new table? [Closed]

By
Dale E. Moore
on 2/15/13, 7:28 PM 1,777 views

The Question has been closed

by
Ray Carnes
on 03/09/2014 00:24:40

When I create a new table the field order is always different than what I specified in the

class newClass(osv.osv):
    _columns = {
        fieldA:fields.char('Field A',size=10),
        fieldB:fields.char('Field B',size=10),
        fieldC:fields.char('Field C',size=10),
    }

Is there some way I can force the fields to be created in the new table in the order I've specified?

Why do you need the fields in a specific order? ORM persists the models you define as OpenERP see's fit - the order shouldn't matter. It is not important to the Web client, SQL or other python code since you can access them in any order.

Bista Solutions US, Ray Carnes
on 2/15/13, 11:11 PM

In the academic sense, both database fields and database rows are 'sets' rather than 'ordered lists'.

Bista Solutions US, Ray Carnes
on 2/15/13, 11:11 PM

If you really need to do this, define your own SQL to create the table.

Bista Solutions US, Ray Carnes
on 2/15/13, 11:12 PM

You would do this by using the tag: _auto = False to tell OpenERP you will code the persistence of this model, then writing a def init(self,cr): funtion. Then you can do cr.execute and use SQL.

Bista Solutions US, Ray Carnes
on 2/15/13, 11:23 PM

Thanks Ray; your comments are very helpful. If you would compose the last comment as an answer, I would be happy to grant you the cred.

Moore Works, Dale E. Moore
on 2/16/13, 12:31 AM

To answer your question, I don't like the default field order that appears in a view. Perhaps I should be asking how to order the fields in the view.

Moore Works, Dale E. Moore
on 2/16/13, 12:33 AM

To change the order of fields in a view (and I can see why you would want to do this) you need to edit the XML definition of the view. Settings -> User Interface -> Views. You should really create your own view that inherits and modifies a base view, rather than changing it.

Bista Solutions US, Ray Carnes
on 2/16/13, 2:44 AM

If you haven't created your own view for your model, OpenERP will generate one on the fly, which is why it would look messy.

Bista Solutions US, Ray Carnes
on 2/16/13, 2:45 AM
2

Ray Carnes

--Ray Carnes--
15717
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 2/16/13, 2:41 AM

You would do this by using the tag: _auto = False to tell OpenERP you will code the persistence of this model, then writing a def init(self,cr): funtion. Then you can do cr.execute and use SQL.

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 2/15/13, 7:28 PM
Seen: 1777 times
Last updated: 3/16/15, 8:10 AM