How to override "ir.sequence" field in csv import in Odoo?

I am trying to import new customer data into Odoo using CSV import. There is one customer_id_no field that is automatically created when the record is created (using "ir.sequence").

Now each customer record in CSV has a unique customer_id_no , but when I try to import it, the existing customer_id_no overridden by the standard sequence.

How can I insert data from a CSV like in Odoo?

Also, I could not find an answer to import many2one fields. Any help on this would be good.

+6
source share
1 answer

@CZoellner is right. You must change your method. It will be something like this:

 @api.model def create(self, vals): vals['customer_id_no'] = mechanics_to_generate_sequence() return super(ClassName, self).create(vals) 

He needs to refer to the case when customer_id_no is provided. Like this

 @api.model def create(self, vals): if not vals.get('customer_id_no'): vals['customer_id_no'] = mechanics_to_generate_sequence() return super(ClassName, self).create(vals) 

Note that after that you will need to make the next iteration sequence the next value in customer_id_no .

+1
source

Source: https://habr.com/ru/post/1012134/


All Articles