def manage_beforeDelete(self, item, container): """ Delete related Applied Rule """ for o in self.getCausalityRelatedValueList(portal_type='Applied Rule'): o.getParentValue().deleteContent(o.getId()) Delivery.manage_beforeDelete(self, item, container)
def updateAppliedRule(self, rule_id=None, rule_reference=None, **kw): """XXX FIXME: Kept for compatibility. updateAppliedRule must be called with a rule_reference in a workflow script. """ if rule_id is None and rule_reference is None: warn('Relying on a default delivery rule is deprecated; ' \ 'rule_reference must be specified explicitly.', DeprecationWarning) rule_reference = 'default_delivery_rule' Delivery.updateAppliedRule(self, rule_id=rule_id, rule_reference=rule_reference, **kw)
def getTotalQuantity(self, **kw) : """Returns the total quantity for this Order. """ if 'portal_type' not in kw: kw['portal_type'] = self.getPortalObject() \ .getPortalOrderMovementTypeList() if kw.get('fast'): kw['only_accountable'] = False return Delivery.getTotalQuantity(self, **kw)
def getTotalQuantity(self, **kw): """Returns the total quantity for this Order. """ if 'portal_type' not in kw: kw['portal_type'] = self.getPortalObject() \ .getPortalOrderMovementTypeList() if kw.get('fast'): kw['only_accountable'] = False return Delivery.getTotalQuantity(self, **kw)
def getTotalPrice(self, **kw): """Returns the total price for this Order. If base_contribution is passed, the trade model lines will be used to include movements that will be generated. """ if kw.get('fast'): kw['only_accountable'] = False rounding = kw.get('rounding') if kw.get('base_contribution') is None: kw.setdefault('portal_type', self.getPortalOrderMovementTypeList()) return Delivery.getTotalPrice(self, **kw) else: # Find amounts from the result of getAggregatedAmountList. # Call getAggregatedAmountList and sum all the amounts which # base_contribution category is matched with. from Products.ERP5.PropertySheet.TradeModelLine import TARGET_LEVEL_MOVEMENT trade_condition = self.getSpecialiseValue() if trade_condition is None: # We cannot find any amount so that the result is 0. return 0 base_contribution = kw.get('base_contribution') if isinstance(base_contribution, (tuple, list)): base_contribution_list = base_contribution else: base_contribution_list = (base_contribution, ) base_contribution_value_list = [] portal_categories = self.portal_categories for relative_url in base_contribution_list: base_contribution_value = portal_categories.getCategoryValue( relative_url) if base_contribution_value is not None: base_contribution_value_list.append( base_contribution_value) if not base_contribution_value_list: # We cannot find any amount so that the result is 0. return 0 current_aggregated_amount_list = trade_condition.getAggregatedAmountList( self, rounding=rounding, force_create_line=True) trade_model_line = self.newContent(temp_object=True, portal_type='Trade Model Line', id='_temp_' + self.getId(), notify_workflow=False) # prevent invoking interaction workflows. trade_model_line.portal_type = '' trade_model_line.edit( target_level=TARGET_LEVEL_MOVEMENT, price=1, efficiency=1, quantity=None, base_application_value_list=base_contribution_value_list) aggregated_amount_list = trade_model_line._getAggregatedAmountList( self, movement_list=self.getMovementList(), current_aggregated_amount_list=current_aggregated_amount_list, rounding=rounding) return aggregated_amount_list.getTotalPrice()
def getTotalPrice(self, **kw) : """Returns the total price for this Order. If base_contribution is passed, the trade model lines will be used to include movements that will be generated. """ if kw.get('fast'): kw['only_accountable'] = False rounding = kw.get('rounding') if kw.get('base_contribution') is None: kw.setdefault('portal_type', self.getPortalOrderMovementTypeList()) return Delivery.getTotalPrice(self, **kw) else: # Find amounts from the result of getAggregatedAmountList. # Call getAggregatedAmountList and sum all the amounts which # base_contribution category is matched with. from Products.ERP5Type.Document import newTempTradeModelLine from Products.ERP5.PropertySheet.TradeModelLine import TARGET_LEVEL_MOVEMENT trade_condition = self.getSpecialiseValue() if trade_condition is None: # We cannot find any amount so that the result is 0. return 0 base_contribution = kw.get('base_contribution') if isinstance(base_contribution, (tuple, list)): base_contribution_list = base_contribution else: base_contribution_list = (base_contribution,) base_contribution_value_list = [] portal_categories = self.portal_categories for relative_url in base_contribution_list: base_contribution_value = portal_categories.getCategoryValue(relative_url) if base_contribution_value is not None: base_contribution_value_list.append(base_contribution_value) if not base_contribution_value_list: # We cannot find any amount so that the result is 0. return 0 current_aggregated_amount_list = trade_condition.getAggregatedAmountList(self, rounding=rounding, force_create_line=True) trade_model_line = newTempTradeModelLine( self, '_temp_' + self.getId(), notify_workflow=False) # prevent invoking interaction workflows. trade_model_line.portal_type = '' trade_model_line.edit(target_level=TARGET_LEVEL_MOVEMENT, price=1, efficiency=1, quantity=None, base_application_value_list=base_contribution_value_list) aggregated_amount_list = trade_model_line._getAggregatedAmountList( self, movement_list=self.getMovementList(), current_aggregated_amount_list=current_aggregated_amount_list, rounding=rounding) return aggregated_amount_list.getTotalPrice()
def getTotalQuantity(self, **kw) : """Returns the total quantity for this Order. """ kw.setdefault('portal_type', self.getPortalOrderMovementTypeList()) if kw.get('fast'): kw['only_accountable'] = False return Delivery.getTotalQuantity(self, **kw)
def manage_beforeDelete(self, item, container): """ The right of deleting must be define by workflows """ Delivery.manage_beforeDelete(self, item, container)
def getTotalQuantity(self, **kw): """ Returns the total quantity for this invoice """ kw.setdefault('portal_type', self.getPortalInvoiceMovementTypeList()) return Delivery.getTotalQuantity(self, **kw)
def getTotalQuantity(self, **kw) : """Returns the total quantity for this Order. """ kw.setdefault('portal_type', self.getPortalOrderMovementTypeList()) return Delivery.getTotalQuantity(self, **kw)
def getTotalPrice(self, **kw): """ Returns the total price for this invoice """ kw.setdefault('portal_type', self.getPortalInvoiceMovementTypeList()) return Delivery.getTotalPrice(self, **kw)