I'm trying to import new customer data into Odoo using CSV import. There is one field customer_id_no
which is auto generated when the record is created(using the "ir.sequence").
Now each customer record in the CSV has a unique customer_id_no
but when I try to import it, the existing customer_id_no
is overridden by the standard sequence.
How can I insert the data from CSV as it is in the Odoo?
Also I was unable to find an answer to import many2one fields. Any help on that would be greatful.
@CZoellner is right. You have to change your method. It would be something like this :
@api.model
def create(self, vals):
vals['customer_id_no'] = mechanics_to_generate_sequence()
return super(ClassName, self).create(vals)
It needs to address the case where 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 afterward you would need to make the sequence next iteration to the value next to the highest in customer_id_no
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With