Ir al contenido
Menú
Se marcó esta pregunta

I want to update asset record in odoo 13 enterprise

But because of something, the field asset_type is null for some record. Because of that null field I cannot find the record in my Odoo view. So I need to update that field asset_type but because I cannot find the asset in my view I cannot get external id so I need to use database id.

But I didn't find database id in my import field only external id.
How can I update with database ID with import file?

Avatar
Descartar
Mejor respuesta

Hi  Knuckles,

I think this video can help you:

https://www.youtube.com/watch?v=UOBxxnYDIsM&list=PLSKcWRTtEl5qzvRaI-VTGavfReiHS_EEb&index=1

Avatar
Descartar
Mejor respuesta

Hi,

You can import data using scripts, so you need to add a wizard action and the action contains files when uploading the file add a button to import the record, and you must add functionality on the button function.

class DynamicField(models.TransientModel):
_name = 'import.data'
_description = 'Import Data'

file = fields.Binary('File')


def function_name(self):

csv_data = base64.b64decode(self.file)
data_file = io.StringIO(csv_data.decode("utf-8"))
csv_reader = csv.reader(data_file, delimiter=',')
keys = ['id', 'value1', 'value2']
file_reader = []
file_reader.extend(csv_reader)
for i in range(len(file_reader)):
field = list(map(str, file_reader[i]))
values = dict(zip(keys, field))
if values:
if i == 0:
continue
else:
record = self.env.ref(values['id'])
//You can add the functions here

In this case, you must add the CSV file and the first column contains the external id, using self.env.ref(values['id']) the id contains the external id and you will get the particular data-id on the record variable, as per the value you will get the database id and further information

Regards

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
abr 24
924
4
nov 24
10804
1
nov 23
5678
3
nov 22
18896
1
jul 22
4505