New OpenERP Server

Registered by Mantavya Gajjar (Open ERP)

SAServer will be Enhanced Version OpenERP-Server which will support all Major Databases. Major aim is to make openerp database independent . and customer can make their existing application as it and able to implement openerp easily on the same dababase.

Things to be Take Care
* OpenERP Krenal - osv, orm and fields
* OpenERP Modules
* OpenERP DB Supports - sql_db.py

There are many type of Implementation is in my mind, of course SQLAlchemy is the great ORM so its better to use the same framework inside the openerp, but also take care about the openerp existing framework and modules, which should not be changed at all. and all modules and new development will work as it is.

Prototype 1:
class orm(object):

    #__metaclass__ = orm_meta

    def __init__(self):
        self.metadata = MetaData()
        self.tbl = None
        self.cols = []
        self.conn = engine.connect()

        for key, col in self._columns.items():
            if isinstance(col, char):
                self.cols += [Column(key, String(col.size))]
            elif isinstance(col, boolean):
                #TODO : Create a Boolean Fields
                pass
            elif isinstance(col, text):
                #TODO : Create a Text fields
                pass

        self.cols += [Column('id', Integer, primary_key=True)]
        self.tbl = Table(self._name, self.metadata, *self.cols)
        self.metadata.create_all(engine)

    def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
        query = self.tbl.select()
        query = query.where(self.tbl.c.id.in_(ids))
        result = self.conn.execute(query)
        return result.fetchall()

    def create(self, cr, user, vals, context=None):
        return self.conn.execute(self.tbl.insert(), vals)

class DemoModel(orm):
    _name = 'account_voucher'
    _columns = {
        'name' : char('Name', size=64),
    }

Prototype 2:
class Partner(ORMTemplate):
    _name = 'res.partner'
    _description = 'Partner Data'

    id = fields.integer('Id', primary_key=True)
    name = fields.char('Name', size=256, nullable=False)
    ref = fields.char('Code', size=256, nullable=False)
    website = fields.char('Website', size=256)
    emails = fields.one2many('res.partner.emails', 'partner_id', 'Emails')
    category_ids = fields.many2many('res.partner.category', 'res_partner_category_rel', 'partner_id', 'category_id', 'Categories')

but in above prototype the openerp model is totally changed but it looks as pure SQLAlchemy Implementation, so this will not be a good prototype

Prototype 3:
if we can do something like described billow based on the OpenERP model during the execution of the server
class Partner(osv.osv):
    _name = 'res.partner'
    _table = 'res_partner'
    def _get_credit(self, cr. uid, context={}):
        return [{}]
    _columns = {
        'name':fields.char('Name', size=256, required=True),
        'contacts_id':fields.one2many('res.partner.contact', 'partner_id', 'Contacts'),
        'debit':fields.function(_get_credit, type='float')
    }
Partner()

#TODO : Convert _columns to _sa automatically
_sa = Table(
    _table,
    metadata,
    Column('id', Integer, primary_key=True),
    Column('name', String(256), nullable=False, default="NULL"),
    Column('debit', Function(_get_credit, type=Integer)),
)
_mapping = mapper(Partner, _sa)

in this case we can easily attract the openerp developer, and also sqlalchemy lovers. thosw weho can either define opener _columns or sqlalchemy table directly in to the openerp model.

Well, Al this model are the based on the research, but there are still many things that is to be take care like
* Relational Fields
* Function Fields
* Sequences
* Indexes
* Selection Fields
* Store Functionality
* Inheritance Functionalists
* and many more

Well More Ideas Invited

Blueprint information

Status:
Complete
Approver:
Fabien (Open ERP)
Priority:
Undefined
Drafter:
Mantavya Gajjar (Open ERP)
Direction:
Needs approval
Assignee:
Mantavya Gajjar (Open ERP)
Definition:
Review
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
Mantavya Gajjar (Open ERP)
Completed by
Mantavya Gajjar (Open ERP)

Sprints

Whiteboard

you may fine the good Progress of the SAServer here https://code.launchpad.net/~openerp-commiter/openobject-server/server-sa

there are few changes while starting the server
./openerp-server.py --engine='mysql://localhost' --addons-path=/home/mga/workspace/sa/addons-sa/

--engine is the new parameter which will be directly related to the engine url of the sqlalchemy http://www.sqlalchemy.org/docs/05/dbengine.html?highlight=url

(?)

Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.