openerp-expert-framework team mailing list archive
-
openerp-expert-framework team
-
Mailing list archive
-
Message #00549
Re: _constraints message improvement
A Divendres, 8 de juliol de 2011 03:04:16, Olivier Dony va escriure:
> On 07/08/2011 12:09 AM, Albert Cervera i Areny wrote:
> > Well, we use an osv.except_osv() instead of returning False.
>
> That works as a valid alternative, good point!
>
> > I think the API should simply not include the possibility of adding a
> > static text and force the developer to always use the exception. The
> > possibility that comments Olivier seems to complex to me, compared to
> > how easy it is to raise an insightful exception.
>
> _constraints offer a SQL-like way to perform business-level validation
> checks. Hence the API is based on the result of a boolean test, exactly
> like SQL constraints, and the user notification is handled elsewhere. To
> me, this is good and simple, and you have the other, more complicated
> options when needed (such as explicitly raising).
>
> The static messages also save you the trouble of repeated boilerplate
> code (raising, translating, coming up with a yet another meaningful
> exception title, etc.), for the many cases where a static message is
> sufficient.
I'd say there are *no* cases in which a static message is sufficient. Well, it
is if you think the other place where that can happen is when the user is
storing a form but what happens when the user is validating a bank statement
with litteraly hundreds of entries and you get something like "Entries are not
of the same account or already reconciled !" (note the example is taken from
an osv.except_osv, but you know what I mean).
Having the possibility of a static message encourages bad error messages.
Those should be forbiden and explain developers that they must always provide
enough information for the user to know what is going on and where. What we do
in these cases is add the amount of debit or credit fields and add move id, for
example.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-expert-framework
> Post to : openerp-expert-framework@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-expert-framework
> More help : https://help.launchpad.net/ListHelp
--
Albert Cervera i Areny
http://www.NaN-tic.com
OpenERP Partners
Tel: +34 93 553 18 03
http://twitter.com/albertnan
http://www.nan-tic.com/blog
References