fix: add command to install mysql triggers for CORE office_op
DB
for use with datasync. this also adds datasync support for ProductCost preference
This commit is contained in:
parent
2f22be6e7e
commit
dca2c1bfe2
4 changed files with 435 additions and 28 deletions
|
@ -733,15 +733,7 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
|
|||
return # product has no default vendor
|
||||
|
||||
items = vendor_items[upc]
|
||||
for item in items:
|
||||
if item['vendorID'] == vendor_id:
|
||||
# found the default vendor item
|
||||
j = items.index(item)
|
||||
if j != 0:
|
||||
# it was not first; make it so
|
||||
items.pop(j)
|
||||
items.insert(0, item)
|
||||
break
|
||||
self.sort_these_vendor_items(items, vendor_id)
|
||||
|
||||
self.progress_loop(organize, list(vendor_items),
|
||||
message="Sorting items by default vendor")
|
||||
|
@ -875,7 +867,28 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp
|
|||
if hasattr(self, 'api_vendor_items'):
|
||||
return self.api_vendor_items.get(product['upc'], [])
|
||||
|
||||
raise NotImplementedError("must add real-time datasync support")
|
||||
# nb. remaining logic is for real-time datasync. here we
|
||||
# do not have a cache of vendor items so must fetch what
|
||||
# we need from API. unfortunately we must (?) fetch *all*
|
||||
# vendor items and then filter locally
|
||||
items = [item
|
||||
for item in self.api.get_vendor_items()
|
||||
if item['upc'] == product['upc']]
|
||||
|
||||
vendor_id = product['default_vendor_id']
|
||||
self.sort_these_vendor_items(items, vendor_id)
|
||||
return items
|
||||
|
||||
def sort_these_vendor_items(self, items, default_vendor_id):
|
||||
for item in items:
|
||||
if item['vendorID'] == default_vendor_id:
|
||||
# found the default vendor item
|
||||
i = items.index(item)
|
||||
if i != 0:
|
||||
# it was not first; make it so
|
||||
items.pop(i)
|
||||
items.insert(0, item)
|
||||
break
|
||||
|
||||
|
||||
class MembershipTypeImporter(FromCOREPOSAPI, importing.model.MembershipTypeImporter):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue