← Back to team overview

openerp-community team mailing list archive

Re: [Merge] lp:~openerp-community/openobject-server/stefan-therp_lp891592-6.1 into lp:openobject-server

 

On 11/17/2011 04:08 PM, Raphaël Valyi - http://www.akretion.com wrote:
> I understand why you reject that raw constraints don't use context.
> Now, it would be good if OpenERP would have the equivalent of something
> like Rails activemodels lifecycle methods such as:
> 
>    - validate
>    - before_validate
>    - after_validate

Those are hooks, and for now we would rather stay away from them as much
as possible. I believe we can reach much better code quality using a
truly clean and extensible API than adding hooks everywhere.
Cleaning up the API and making smaller and more extensible methods makes
the code simpler and easier to read. Adding hooks does the opposite (IMO).

Ultimately, it's probably a matter of taste, though.


> Then a immediate idea is to override write and create of the object. being
> edited. But this prove to be extremely ugly and crappy in practice.

Don't see why it should.


> But there is more: imagine you override the create/write of a sale order
> line.
> Actually, if you edit a sale order (at least in the GTK client) and create
> some order lines inline, then create and write will not be called at the
> order line level!!
> Only create or write from the sale order will be called.

Reading/Writing a o2m field via a parent model calls the
fields.one2many.set/get method which delegate to the CRUD methods of the
child model.

Overriding the CRUD methods of sale.order.line will thus give the
desired/expected effect.

The API would be really crappy otherwise, indeed ;-)


References