Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Excel Import/Export/Report
Entity: xlsx.template
Compute Method: _compute_output_instruction
| Inputs | Method | Outputs |
|---|---|---|
|
- """From database, compute back to dictionary""" - for rec in self: - inst_dict = {} - prev_sheet = False - prev_row = False - # Export Instruction - itype = "__EXPORT__" - inst_dict[itype] = {} - for line in rec.export_ids: - if line.section_type == "sheet": - sheet = co.isinteger(line.sheet) and int(line.sheet) or line.sheet - sheet_dict = {sheet: {}} - inst_dict[itype].update(sheet_dict) - prev_sheet = sheet - continue - if line.section_type in ("head", "row"): - row_field = line.row_field - if line.section_type == "row" and line.is_cont: - row_field = f"_CONT_{row_field}" - if line.section_type == "row" and line.is_extend: - row_field = f"_EXTEND_{row_field}" - row_dict = {row_field: {}} - inst_dict[itype][prev_sheet].update(row_dict) - prev_row = row_field - continue - if line.section_type == "data": - excel_cell = line.excel_cell - field_name = self._compose_field_name(line) - cell_dict = {excel_cell: field_name} - inst_dict[itype][prev_sheet][prev_row].update(cell_dict) - continue - # Import Instruction - itype = "__IMPORT__" - inst_dict[itype] = {} - for line in rec.import_ids: - if line.section_type == "sheet": - sheet = co.isinteger(line.sheet) and int(line.sheet) or line.sheet - sheet_dict = {sheet: {}} - inst_dict[itype].update(sheet_dict) - prev_sheet = sheet - continue - if line.section_type in ("head", "row"): - row_field = line.row_field - if line.section_type == "row" and line.no_delete: - row_field = f"_NODEL_{row_field}" - row_dict = {row_field: {}} - inst_dict[itype][prev_sheet].update(row_dict) - prev_row = row_field - continue - if line.section_type == "data": - excel_cell = line.excel_cell - field_name = line.field_name or "" - field_name += line.field_cond or "" - cell_dict = {excel_cell: field_name} - inst_dict[itype][prev_sheet][prev_row].update(cell_dict) - continue - itype = "__POST_IMPORT__" - inst_dict[itype] = False - if rec.post_import_hook: - inst_dict[itype] = rec.post_import_hook - rec.instruction = inst_dict |
|
