Skip to content

Commit

Permalink
Merge pull request #502 from frePPLe/17.0
Browse files Browse the repository at this point in the history
Syncing from upstream frePPLe/odoo (17.0)
  • Loading branch information
bt-admin authored Jan 31, 2025
2 parents b6d6959 + 201d34e commit bbe12bb
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions frepple/controllers/outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,8 @@ def export_customers(self):
res.partner.id res.partner.name -> customer.name
"""
self.map_customers = {}
# We also build in the loop the supplier map
self.map_suppliers = {}
first = True
individual_inserted = False
for i in self.generator.getData(
Expand All @@ -856,20 +858,27 @@ def export_customers(self):
yield "<customers>\n"
first = False
if i["is_company"]:
name = "%s %s" % (i["name"], i["id"])
yield "<customer name=%s/>\n" % quoteattr(name)
name = str(i["id"])
supplier = "%s %s" % (i["name"], i["id"])
yield '<customer name="%s" description=%s/>\n' % (
name,
quoteattr(i["name"][:300]),
)
elif i["parent_id"] == False or i["id"] == i["parent_id"][0]:
name = "Individuals"
supplier = "Individuals"
if not individual_inserted:
yield "<customer name=%s/>\n" % quoteattr(name)
individual_inserted = True
else:
if i["parent_id"][0] in self.map_customers:
name = self.map_customers[i["parent_id"][0]]
name = str(self.map_customers[i["parent_id"][0]])
supplier = "%s %s" % (i["parent_id"][1], i["parent_id"][0])
else:
continue

self.map_customers[i["id"]] = name
self.map_suppliers[i["id"]] = supplier
if not first:
yield "</customers>\n"

Expand All @@ -882,7 +891,7 @@ def export_suppliers(self):
res.partner.id res.partner.name -> supplier.name
"""
first = True
for i in self.map_customers.values():
for i in self.map_suppliers.values():
if first:
yield "<!-- suppliers -->\n"
yield "<suppliers>\n"
Expand Down Expand Up @@ -1249,7 +1258,7 @@ def export_items(self):
if tmpl["purchase_ok"]:
suppliers = {}
for sup in itemsuppliers.get(tmpl["id"], []):
name = self.map_customers.get(sup["partner_id"][0], None)
name = self.map_suppliers.get(sup["partner_id"][0], None)
if not name:
# Skip uninterested suppliers (eg archived ones)
continue
Expand Down Expand Up @@ -2269,7 +2278,7 @@ def export_purchaseorders(self):
start = self.formatDateTime(start if start < end else end)
end = self.formatDateTime(end)
qty = mv.product_qty
supplier = self.map_customers.get(j.partner_id.id)
supplier = self.map_suppliers.get(j.partner_id.id)
if not supplier:
# supplier is archived :-(
for sup in self.generator.getData(
Expand All @@ -2287,7 +2296,7 @@ def export_purchaseorders(self):
"(archived) " if not sup["active"] else "",
sup["id"],
)
self.map_customers[sup["id"]] = supplier
self.map_suppliers[sup["id"]] = supplier
break
if not supplier:
continue
Expand Down Expand Up @@ -2325,7 +2334,7 @@ def export_purchaseorders(self):
i.product_uom.id,
self.product_product[i.product_id.id]["template"],
)
supplier = self.map_customers.get(j.partner_id.id)
supplier = self.map_suppliers.get(j.partner_id.id)
if not supplier:
# supplier is archived :-(
for sup in self.generator.getData(
Expand All @@ -2343,7 +2352,7 @@ def export_purchaseorders(self):
"(archived) " if not sup["active"] else "",
sup["id"],
)
self.map_customers[sup["id"]] = supplier
self.map_suppliers[sup["id"]] = supplier
break
if not supplier:
continue
Expand Down

0 comments on commit bbe12bb

Please sign in to comment.