diff --git a/excel_import_export/models/xlsx_import.py b/excel_import_export/models/xlsx_import.py index 1892396c7f7..c9b0a47fa7d 100644 --- a/excel_import_export/models/xlsx_import.py +++ b/excel_import_export/models/xlsx_import.py @@ -65,6 +65,9 @@ def _get_field_type(self, model, field): try: record = self.env[model].new() for f in field.split("/"): + # Supporting import by database ID + if f == ".id": + f = "id" field_type = record._fields[f].type if field_type in ("one2many", "many2many"): record = record[f] diff --git a/excel_import_export/readme/CONTRIBUTORS.md b/excel_import_export/readme/CONTRIBUTORS.md index f5c065bfe39..b03fc459985 100644 --- a/excel_import_export/readme/CONTRIBUTORS.md +++ b/excel_import_export/readme/CONTRIBUTORS.md @@ -2,3 +2,4 @@ () - Saran Lim. \<\> () - Do Anh Duy \<\> +- 张飞虎 \<\> \ No newline at end of file diff --git a/excel_import_export/readme/USAGE.md b/excel_import_export/readme/USAGE.md index 34ffa3a1005..0c108635dbe 100644 --- a/excel_import_export/readme/USAGE.md +++ b/excel_import_export/readme/USAGE.md @@ -69,6 +69,33 @@ excel_import_export_demo/report_sale_order) 5. Create instruction dictionary for report in xlsx.template model -- templates.xml +**Use Case 4:** Import and Update Existing Records by Database ID + +This feature enables batch updating of existing data by including the record ID +in the export template and using it during import to match and update corresponding +records. + +**Scenario:** Suitable for procurement quotation processes where product quotes +need to be batch updated. For example, a purchase order contains hundreds of +products. You can export the details to suppliers for quoting, then import the +supplier's returned quotes to quickly update the prices in the quotation for +easy comparison. + +**Workflow:** + +1. Define Export Template: When exporting purchase details, include id field (ID) + in the template. + +2. Configure Import Template: In the import template's ID field, enter ".id" + to leverage Odoo's built-in mechanism for matching and updating corresponding + records. + +3. Execute Import: Select the file with supplier quotes for import. + +4. Complete Update: After successful import, the prices in the related purchase + quotation lines will automatically update to the latest quotes provided by + the supplier. + **Note:** Another option for reporting is to use report action