Esempio n. 1
0
 def setSourceDebit(self, source_debit):
   """Set the quantity.
   Overloaded from movement, we always set the quantity, even if not passed
   """
   try:
     source_debit = float(source_debit)
   except TypeError:
     source_debit = 0.0
   Movement.setSourceDebit(self, source_debit)
Esempio n. 2
0
 def setSourceDebit(self, source_debit):
   """Set the quantity.
   Overloaded from movement, we always set the quantity, even if not passed
   """
   try:
     source_debit = float(source_debit)
   except TypeError:
     source_debit = 0.0
   Movement.setSourceDebit(self, source_debit)
Esempio n. 3
0
    def _getTotalPrice(self, default=0.0, context=None, fast=0):
      """
        Returns the total price for this line, this line contains, or the cells it contains.

        if hasLineContent: return sum of lines total price
        if hasCellContent: return sum of cells total price
        else: return quantity * price
        if fast argument is true, inventory API will be used.
      """
      if fast:
        kw = {}
        kw['section_uid'] = self.getDestinationSectionUid()
        kw['stock.explanation_uid'] = self.getExplanationUid()
        kw['relative_url'] = ( '%s/%%' % (
          self.getRelativeUrl().replace('_', '\\_')),
          self.getRelativeUrl() )
        kw['only_accountable'] = False
        return self.getPortalObject().portal_simulation.getInventoryAssetPrice(**kw)
      if self.hasLineContent():
        meta_type = self.meta_type
        return sum(l.getTotalPrice(context=context)
                   for l in self.objectValues() if l.meta_type==meta_type)
      elif not self.hasCellContent(base_id='movement'):
        return Movement._getTotalPrice(self, default=default, context=context)
      return sum(cell.getTotalPrice(default=0.0, context=context)
                 for cell in self.getCellValueList())
Esempio n. 4
0
    def _getTotalPrice(self, default=0.0, context=None, fast=0):
      """
        Returns the total price for this line, this line contains, or the cells it contains.

        if hasLineContent: return sum of lines total price
        if hasCellContent: return sum of cells total price
        else: return quantity * price
        if fast argument is true, inventory API will be used.
      """
      if fast:
        kw = {}
        kw['section_uid'] = self.getDestinationSectionUid()
        kw['stock.explanation_uid'] = self.getExplanationUid()
        kw['relative_url'] = ( '%s/%%' % (
          self.getRelativeUrl().replace('_', '\\_')),
          self.getRelativeUrl() )
        kw['only_accountable'] = False
        return self.getPortalObject().portal_simulation.getInventoryAssetPrice(**kw)
      if self.hasLineContent():
        meta_type = self.meta_type
        return sum(l.getTotalPrice(context=context)
                   for l in self.objectValues() if l.meta_type==meta_type)
      elif not self.hasCellContent(base_id='movement'):
        return Movement._getTotalPrice(self, default=default, context=context)
      return sum(cell.getTotalPrice(default=0.0, context=context)
                 for cell in self.getCellValueList())
Esempio n. 5
0
    def _edit(self, edit_order=(), **kw):
      # XXX FIXME For now, special cases are handled in _edit methods in many
      # documents : DeliveryLine, DeliveryCell ... Ideally, to prevent code
      # duplication, it should be handled in a _edit method present only in
      # Amount.py

      # If variations and resources are set at the same time, resource must be
      # set before any variation.
      before_order = ('resource', 'resource_value',
                      'variation_base_category_list',
                      'variation_category_list')
      before_kw = {k: kw.pop(k) for k in before_order if k in kw}
      if before_kw:
        before_kw.update((k, kw[k]) for k in edit_args_list if k in kw)
        Base._edit(self, edit_order=before_order, **before_kw)
      if kw:
        Movement._edit(self, edit_order=edit_order, **kw)
Esempio n. 6
0
    def _edit(self, edit_order=(), **kw):
      # XXX FIXME For now, special cases are handled in _edit methods in many
      # documents : DeliveryLine, DeliveryCell ... Ideally, to prevent code
      # duplication, it should be handled in a _edit method present only in
      # Amount.py

      # If variations and resources are set at the same time, resource must be
      # set before any variation.
      before_order = ('resource', 'resource_value',
                      'variation_base_category_list',
                      'variation_category_list')
      before_kw = {k: kw.pop(k) for k in before_order if k in kw}
      if before_kw:
        before_kw.update((k, kw[k]) for k in edit_args_list if k in kw)
        Base._edit(self, edit_order=before_order, **before_kw)
      if kw:
        Movement._edit(self, edit_order=edit_order, **kw)
Esempio n. 7
0
    def _edit(self, REQUEST=None, force_update=0, **kw):
        # XXX FIXME For now, special cases are handled in _edit methods in many
        # documents : DeliveryLine, DeliveryCell ... Ideally, to prevent code
        # duplication, it should be handled in a _edit method present only in
        # Amount.py

        # If variations and resources are set at the same time, resource must be
        # set before any variation.
        if kw.has_key('resource_value'):
            self._setResourceValue(kw['resource_value'])
        # We must first prepare the variation_base_category_list before we do the edit of the rest
        #LOG('in edit', 0, str(kw))
        if kw.has_key('variation_base_category_list'):
            self._setVariationBaseCategoryList(
                kw['variation_base_category_list'])
        if kw.has_key('variation_category_list'):
            self._setVariationCategoryList(kw['variation_category_list'])
        Movement._edit(self, REQUEST=REQUEST, force_update=force_update, **kw)
Esempio n. 8
0
    def _edit(self, REQUEST=None, force_update = 0, **kw):
      # XXX FIXME For now, special cases are handled in _edit methods in many
      # documents : DeliveryLine, DeliveryCell ... Ideally, to prevent code
      # duplication, it should be handled in a _edit method present only in
      # Amount.py

      # If variations and resources are set at the same time, resource must be
      # set before any variation.
      if kw.has_key('resource_value'):
        self._setResourceValue( kw['resource_value'] )
      # We must first prepare the variation_base_category_list before we do the edit of the rest
      #LOG('in edit', 0, str(kw))
      if kw.has_key('variation_base_category_list'):
        self._setVariationBaseCategoryList( kw['variation_base_category_list'] )
      if kw.has_key('variation_category_list'):
        self._setVariationCategoryList( kw['variation_category_list'] )
      Movement._edit(self, REQUEST=REQUEST,
                       force_update = force_update, **kw)
Esempio n. 9
0
 def getDivergenceList(self):
   """Returns a list of messages that contains the divergences for that line
   and the cells it may contain.
   """
   if self.hasCellContent():
     divergence_list = []
     for cell in self.objectValues(portal_type=self.getPortalObject()
         .getPortalDeliveryMovementTypeList()):
       divergence_list += cell.getDivergenceList()
     return divergence_list
   else:
     return Movement.getDivergenceList(self)
Esempio n. 10
0
 def getDivergenceList(self):
   """Returns a list of messages that contains the divergences for that line
   and the cells it may contain.
   """
   divergence_list = []
   if self.hasCellContent():
     for cell in self.contentValues(filter={
             'portal_type': self.getPortalDeliveryMovementTypeList()}):
       divergence_list.extend(cell.getDivergenceList())
     return divergence_list
   else:
     return Movement.getDivergenceList(self)
Esempio n. 11
0
 def getDivergenceList(self):
   """Returns a list of messages that contains the divergences for that line
   and the cells it may contain.
   """
   divergence_list = []
   if self.hasCellContent():
     for cell in self.contentValues(filter={
             'portal_type': self.getPortalDeliveryMovementTypeList()}):
       divergence_list.extend(cell.getDivergenceList())
     return divergence_list
   else:
     return Movement.getDivergenceList(self)
Esempio n. 12
0
    def _getTotalPrice(self, default=0.0, context=None, fast=0):
      """
        Returns the total price for this line, this line contains, or the cells it contains.

        if hasLineContent: return sum of lines total price
        if hasCellContent: return sum of cells total price
        else: return quantity * price
        if fast is argument true, then a SQL method will be used.
      """
      if self.hasLineContent():
        meta_type = self.meta_type
        return sum(l.getTotalPrice(context=context)
                   for l in self.objectValues() if l.meta_type==meta_type)
      elif not self.hasCellContent(base_id='movement'):
        return Movement._getTotalPrice(self, default=default, context=context)
      elif fast: # Use MySQL
        return self.DeliveryLine_zGetTotal()[0].total_price or 0.0
      return sum(cell.getTotalPrice(default=0.0, context=context)
                 for cell in self.getCellValueList())
Esempio n. 13
0
 def getInventoriatedQuantity(self):
   """
     Take into account efficiency in converted target quantity
   """
   return Movement.getInventoriatedQuantity(self)
Esempio n. 14
0
 def manage_beforeDelete(self, item, container):
   "if the container is a line too, reindex it"
   if self.meta_type == container.meta_type:
     container.reindexObject()
   return Movement.manage_beforeDelete(self, item, container)
Esempio n. 15
0
 def getInventoriatedQuantity(self):
   """
   """
   return Movement.getInventoriatedQuantity(self)
Esempio n. 16
0
 def getInventoriatedStopDate(self):
   """
   """
   return Movement.getStopDate(self)
Esempio n. 17
0
 def getInventoriatedQuantity(self):
     """
 Take into account efficiency in converted target quantity
 """
     return Movement.getInventoriatedQuantity(self)
Esempio n. 18
0
 def getPrice(self, *args, **kw):
     """
   call Movement.getPrice
   """
     return Movement.getPrice(self, *args, **kw)
Esempio n. 19
0
 def getPrice(self, *args, **kw):
     """
   call Movement.getPrice
   """
     return Movement.getPrice(self, *args, **kw)
Esempio n. 20
0
 def getTotalPrice(self, default=0.0, *args, **kw):
     """
   call Movement.getTotalPrice
   """
     return Movement.getTotalPrice(self, default=default, *args, **kw)
Esempio n. 21
0
 def getTotalPrice(self, default=0.0, *args, **kw):
     """
   call Movement.getTotalPrice
   """
     return Movement.getTotalPrice(self, default=default, *args, **kw)
Esempio n. 22
0
 def getInventoriatedQuantity(self):
   """
   """
   return Movement.getInventoriatedQuantity(self)
Esempio n. 23
0
 def manage_beforeDelete(self, item, container):
   "if the container is a line too, reindex it"
   if self.meta_type == container.meta_type:
     container.reindexObject()
   return Movement.manage_beforeDelete(self, item, container)