Odoo Help


How to avoid Import validation error ?

Dr Obx
on 8/28/15, 10:19 AM 2,515 views

While uploading CSV file into the Odoo getting this error:

"Unknown error during import: <class 'openerp.exceptions.ValidationError'>: ('ValidateError', u"Error while validating constraint\n\n'iprodstep.log' object has no attribute 'sales_record_number_id'") at row 2

Resolve other errors first"

Help me please, record "sales_record_number" needs to be checked.

If record number exist .... skip it.

Validation script:



def _check_sales_record_number(self):

search = self.search(sales_record_number)

#..... if there is "sales_record_number" in any of this states .... raise error.
# Or maybe someone will tell me how should look like a validation formula ? .....
# I'm a newbee so ... 

sales_record_number = [sales_record_number.id for sales_record_number in search]

for order in self:

if order.sales_record_number in sales_record_number:

raise ValidationError(_('This order is already in Database'))

Guessing that there is an error in this code.

Any suggestion ?

Or just how to check if there is already "sales_record_number" in odoo.




| 4 4 6
Hyderabad, India

On 8/31/15, 1:25 AM

You can not simply check sales_record_number value using constraint, because while creating a every new record, this constraint will run.
So, if, while importing data from file(csv), it gets voilated, then an exception will be thrown at the very first voilation only and as a result of which your import will get stopped.

Thats why inspite of using constraint, you can create your own new object  and create a new functionality in that for importing the files using your required validation.

Hope it seems valid for you ..

Hi Pawan, yeah thank you

Dr Obx
on 9/1/15, 6:40 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/28/15, 10:19 AM
Seen: 2515 times
Last updated: 8/31/15, 1:25 AM