Odoo Help

Welcome!

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

0

How to avoid Import validation error ?

By
Dr Obx
on 8/28/15, 10:19 AM 1,270 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:

@api.one

@api.constrains('sales_record_number')

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.


0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 8/31/15, 1:25 AM

Rob,
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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