← Back to team overview

openerp-community team mailing list archive

Re: NULL Integers

 

> Furthermore, where the error message before was
> 
>   'That variety code already exists!'
> 
> now it is:
> 
>   Integrity Error
>   duplicate key value violates unique constraint
> "product_unique_variety_code_idx"
>   DETAIL:  Key (variety_code)=(101) already exists.
> 
> I wouldn't call any of that pretty.

true enough. To trick OpenERP into showing your custom error message: Declare 
an _sql_constraint with the same name and your error message, then throw it 
away on SQL level in your init function and create your own constraint.
(You could patch your error message into the pooler on runtime, but that's 
more complicated)

But on the other hand: Is there a good reason not to use _constraints and 
doing this check by hand? That's very straightforward code-wise and the speed 
penalty is negligible if it's about a user filling in one record at a time.
 
-- 
Therp - Maatwerk in open ontwikkeling

Holger Brunn - Ontwerp en implementatie

mail: holger@xxxxxxxx
web: http://therp.nl


Follow ups

References