Changeset 14202


Ignore:
Timestamp:
29 Sep 2016, 06:51:42 (8 years ago)
Author:
Henrik Bettermann
Message:

Fix bug. Customers could also select documents from other customers.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r12986 r14202  
    154154        contract = createObject('waeup.SampleContract')
    155155        contract.contract_id = u'CON1'
     156        customer['contracts'].addContract(contract)
    156157        contract.product_object = self.product
    157158        contract.document_object = self.document
     
    160161        contract.valid_from = datetime.date(2014, 2, 4)
    161162        contract.valid_to = datetime.date(2014, 12, 4)
    162 
    163         customer['contracts'].addContract(contract)
    164163        self.contract = contract
    165164        return customer
     
    535534    def test_import_update(self):
    536535        # We perform the same import twice,
    537         # the second time in update mode. The number
    538         # of warnings must be the same.
     536        # the second time in update mode. No record can be imported.
    539537        num, num_warns, fin_file, fail_file = self.processor.doImport(
    540538            self.csv_file, CONTRACT_HEADER_FIELDS,'create')
     
    544542        # There are one record without contract_id and two
    545543        # records with wrong object identifier.
    546         self.assertEqual(num_warns,3)
     544        # The other 4 records cannot be imported because DOC1 does
     545        # not belong to these customers.
     546        self.assertEqual(num_warns,7)
    547547        shutil.rmtree(os.path.dirname(fin_file))
    548548
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py

    r12839 r14202  
    182182
    183183    def getValues(self, context):
    184         # When checking conversion during import, contracts do not belong to
    185         # customers. Thus all portal documents must be returned.
    186         user_id = getattr(getattr(context, 'customer', None), 'user_id', None)
     184        # When checking conversion during import in create mode,
     185        # contracts do not belong to customers.
     186        # Thus all portal documents must be returned.
     187        # Attention: In create mode documents of other customers
     188        # can be assigned. ConstraintNotSatisfied is not raised.
     189        user_id = getattr(context, 'user_id', None)
     190        # Alternative implementation:
     191        #if not user_id:
     192        #    return []
    187193        catalog = getUtility(ICatalog, name='documents_catalog')
    188194        results = catalog.searchResults(user_id=(user_id, user_id))
Note: See TracChangeset for help on using the changeset viewer.