Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi  Knuckles,

I think this video can help you:

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 24
1038
4
thg 11 24
11227
1
thg 11 23
5922
3
thg 11 22
19223
1
thg 7 22
4666