Skip to content

Commit f3e27a7

Browse files
committed
[IMP] Supporting import by database ID
1 parent 25fc616 commit f3e27a7

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

excel_import_export/models/xlsx_import.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def _get_field_type(self, model, field):
6565
try:
6666
record = self.env[model].new()
6767
for f in field.split("/"):
68+
if f == '.id': # Supporting import by database ID
69+
f = 'id'
6870
field_type = record._fields[f].type
6971
if field_type in ("one2many", "many2many"):
7072
record = record[f]

excel_import_export/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
(<http://ecosoft.co.th>)
33
- Saran Lim. \<<[email protected]>\> (<http://ecosoft.co.th>)
44
- Do Anh Duy \<<[email protected]>\>
5+
- 张飞虎 \<<[email protected]>\>

excel_import_export/readme/USAGE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,33 @@ excel_import_export_demo/report_sale_order)
6969
5. Create instruction dictionary for report in xlsx.template model --
7070
templates.xml
7171

72+
**Use Case 4:** Import and Update Existing Records by Database ID
73+
74+
This feature enables batch updating of existing data by including the record ID
75+
in the export template and using it during import to match and update corresponding
76+
records.
77+
78+
**Scenario:** Suitable for procurement quotation processes where product quotes
79+
need to be batch updated. For example, a purchase order contains hundreds of
80+
products. You can export the details to suppliers for quoting, then import the
81+
supplier's returned quotes to quickly update the prices in the quotation for
82+
easy comparison.
83+
84+
**Workflow:**
85+
86+
1. Define Export Template: When exporting purchase details, include id field (ID)
87+
in the template.
88+
89+
2. Configure Import Template: In the import template's ID field, enter ".id"
90+
to leverage Odoo's built-in mechanism for matching and updating corresponding
91+
records.
92+
93+
3. Execute Import: Select the file with supplier quotes for import.
94+
95+
4. Complete Update: After successful import, the prices in the related purchase
96+
quotation lines will automatically update to the latest quotes provided by
97+
the supplier.
98+
7299
**Note:**
73100

74101
Another option for reporting is to use report action

0 commit comments

Comments
 (0)