- Timestamp:
- 18 Dec 2014, 14:44:30 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r12256 r12258 406 406 return None 407 407 408 #documents = self.getParent(row, site)409 #if documents is None:410 # return None411 #document_id = row.get('document_id', None)412 #if document_id is None:413 # return None414 #entry = documents.get(document_id)415 #return entry416 417 408 def updateEntry(self, obj, row, site, filename): 418 409 """Update obj to the values given in row. … … 496 487 if contract_id is None: 497 488 return None 498 entry = contracts.get(contract_id) 499 return entry 489 cat = queryUtility(ICatalog, name='contracts_catalog') 490 results = list(cat.searchResults(contract_id=(contract_id, contract_id))) 491 if results: 492 return results[0] 493 return None 500 494 501 495 def updateEntry(self, obj, row, site, filename): 502 496 """Update obj to the values given in row. 503 497 """ 498 # Remove contract_id from row if empty 499 if 'contract_id' in row and row['contract_id'] in (None, IGNORE_MARKER): 500 row.pop('contract_id') 504 501 items_changed = super(ContractProcessor, self).updateEntry( 505 502 obj, row, site, filename) 506 503 customer = self.getParent(row, site).__parent__ 507 504 customer.__parent__.logger.info( 508 '%s - %s - %s - updated: %s' 509 % (self.name, filename, customer.customer_id, items_changed)) 505 '%s - %s - %s - %s - updated: %s' 506 % (self.name, filename, customer.customer_id, obj.contract_id, 507 items_changed)) 510 508 return 511 509 512 510 def addEntry(self, obj, row, site): 513 511 parent = self.getParent(row, site) 514 contract_id = row['contract_id'].strip('#') 515 parent[contract_id] = obj 516 # Reset _curr_con_id if contract_id has been imported 517 site = grok.getSite() 518 if row.get('contract_id', None) not in (None, IGNORE_MARKER): 519 site._curr_con_id -= 1 512 parent.addContract(obj) 520 513 return 521 514 … … 541 534 if class_name != self.factory_name.strip('waeup.'): 542 535 errs.append(('class_name','wrong processor')) 543 try:544 # Correct con_id counter. As the IConverter for contracts545 # creates contract objects that are not used afterwards, we546 # have to fix the site-wide con_id counter.547 site = grok.getSite()548 site._curr_con_id -= 1549 except (KeyError, TypeError, AttributeError):550 pass551 # We have to check contract_id.552 contract_id = row.get('contract_id', None)553 if mode == 'create':554 if not contract_id:555 contract_id = generate_contract_id()556 conv_dict['contract_id'] = contract_id557 return errs, inv_errs, conv_dict558 cat = queryUtility(ICatalog, name='contracts_catalog')559 results = list(560 cat.searchResults(contract_id=(contract_id, contract_id)))561 if results:562 # contract_id must not exist.563 errs.append(('contract_id','id exists'))564 else:565 if not contract_id.startswith('c'):566 errs.append(('contract_id','invalid format'))567 536 return errs, inv_errs, conv_dict
Note: See TracChangeset for help on using the changeset viewer.