BankingOperation.py 11.7 KB
Newer Older
Yoshinori Okuji's avatar
Yoshinori Okuji committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This proopgram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
30
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
Yoshinori Okuji's avatar
Yoshinori Okuji committed
31
from Products.ERP5.Document.Delivery import Delivery
32
from Products.ERP5.Document.InventoryLine import InventoryLine
Yoshinori Okuji's avatar
Yoshinori Okuji committed
33 34
from Products.ERP5Type.Document.DeliveryCell import DeliveryCell
from Products.ERP5.Document.Movement import Movement
35
from Products.ERP5.Document.Container import Container
Yoshinori Okuji's avatar
Yoshinori Okuji committed
36 37 38 39
from Products.ERP5.Document.AccountingTransaction import AccountingTransaction
from AccessControl.PermissionRole import PermissionRole
from Products.ERP5Type.Utils import convertToMixedCase, convertToUpperCase
from Products.ERP5Banking.BaobabMixin import BaobabMixin
Aurel's avatar
Aurel committed
40
from Products.ERP5Type.Document.Currency import Currency
41

Yoshinori Okuji's avatar
Yoshinori Okuji committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

class BankingOperation(BaobabMixin, AccountingTransaction):

  # CMF Type Definition
  meta_type = 'ERP5Banking Banking Operation'
  portal_type = 'Banking Operation'

  # Declarative security
  security = ClassSecurityInfo()
  security.declareObjectProtected(Permissions.View)

  # Default Properties
  property_sheets = ( PropertySheet.Base
                    , PropertySheet.XMLObject
                    , PropertySheet.CategoryCore
                    , PropertySheet.DublinCore
                    , PropertySheet.Task
                    , PropertySheet.Arrow
                    , PropertySheet.BankingOperation
                    , PropertySheet.ItemAggregation
                    , PropertySheet.Amount
                    )
Sebastien Robin's avatar
Sebastien Robin committed
64 65 66 67 68 69 70
  
  def manage_beforeDelete(self, item, container):
    """
    The right of deleting must be define by workflows
    """
    Delivery.manage_beforeDelete(self, item, container) 
    
71 72 73 74 75 76 77 78 79 80
  security.declareProtected(Permissions.View, 'getDestinationPaymentInternalBankAccountNumber')
  def getDestinationPaymentInternalBankAccountNumber(self, default=None):
    """
    Getter for internal account number
    """
    dest = self.getDestinationPaymentValue(default)
    if dest is default:
      return default
    else:
      return dest.getInternalBankAccountNumber(default)
Yoshinori Okuji's avatar
Yoshinori Okuji committed
81

82 83 84 85 86 87 88 89 90 91 92
  security.declareProtected(Permissions.View, 'getSourcePaymentInternalBankAccountNumber')
  def getSourcePaymentInternalBankAccountNumber(self, default=None):
    """
    Getter for internal account number
    """
    src = self.getSourcePaymentValue(default)
    if src is default:
      return default
    else:
      return src.getInternalBankAccountNumber(default)
    
Yoshinori Okuji's avatar
Yoshinori Okuji committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
### Dynamic patch
Delivery.getBaobabSourceUid = lambda x: x.getSourceUid()
Delivery.getBaobabSourceUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabDestinationUid = lambda x: x.getDestinationUid()
Delivery.getBaobabDestinationUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabSourceSectionUid = lambda x: x.getSourceSectionUid()
Delivery.getBaobabSourceSectionUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabDestinationSectionUid = lambda x: x.getDestinationSectionUid()
Delivery.getBaobabDestinationSectionUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabSourcePaymentUid = lambda x: x.getSourcePaymentUid()
Delivery.getBaobabSourcePaymentUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabDestinationPaymentUid = lambda x: x.getDestinationPaymentUid()
Delivery.getBaobabDestinationPaymentUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabSourceFunctionUid = lambda x: x.getSourceFunctionUid()
Delivery.getBaobabSourceFunctionUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabDestinationFunctionUid = lambda x: x.getDestinationFunctionUid()
Delivery.getBaobabDestinationFunctionUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabSourceProjectUid = lambda x: x.getSourceProjectUid()
Delivery.getBaobabSourceProjectUid__roles__ = PermissionRole(Permissions.View)

Delivery.getBaobabDestinationProjectUid = lambda x: x.getDestinationProjectUid()
Delivery.getBaobabDestinationProjectUid__roles__ = PermissionRole(Permissions.View)

### Overload Movement
Movement.getBaobabSourceUid = lambda x: x.getSourceUid()
Movement.getBaobabSourceUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabDestinationUid = lambda x: x.getDestinationUid()
Movement.getBaobabDestinationUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabSourceSectionUid = lambda x: x.getSourceSectionUid()
Movement.getBaobabSourceSectionUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabDestinationSectionUid = lambda x: x.getDestinationSectionUid()
Movement.getBaobabDestinationSectionUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabSourcePaymentUid = lambda x: x.getSourcePaymentUid()
Movement.getBaobabSourcePaymentUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabDestinationPaymentUid = lambda x: x.getDestinationPaymentUid()
Movement.getBaobabDestinationPaymentUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabSourceFunctionUid = lambda x: x.getSourceFunctionUid()
Movement.getBaobabSourceFunctionUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabDestinationFunctionUid = lambda x: x.getDestinationFunctionUid()
Movement.getBaobabDestinationFunctionUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabSourceProjectUid = lambda x: x.getSourceProjectUid()
Movement.getBaobabSourceProjectUid__roles__ = PermissionRole(Permissions.View)

Movement.getBaobabDestinationProjectUid = lambda x: x.getDestinationProjectUid()
Movement.getBaobabDestinationProjectUid__roles__ = PermissionRole(Permissions.View)

### Acquire Baobab source / destination uids from parent line
DeliveryCell.getBaobabSourceUid = lambda x: x.getSourceUid()
DeliveryCell.getBaobabSourceUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabDestinationUid = lambda x: x.getDestinationUid()
DeliveryCell.getBaobabDestinationUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabSourceSectionUid = lambda x: x.getSourceSectionUid()
DeliveryCell.getBaobabSourceSectionUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabDestinationSectionUid = lambda x: x.getDestinationSectionUid()
DeliveryCell.getBaobabDestinationSectionUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabSourcePaymentUid = lambda x: x.getSourcePaymentUid()
DeliveryCell.getBaobabSourcePaymentUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabDestinationPaymentUid = lambda x: x.getDestinationPaymentUid()
DeliveryCell.getBaobabDestinationPaymentUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabSourceFunctionUid = lambda x: x.getSourceFunctionUid()
DeliveryCell.getBaobabSourceFunctionUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabDestinationFunctionUid = lambda x: x.getDestinationFunctionUid()
DeliveryCell.getBaobabDestinationFunctionUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabSourceProjectUid = lambda x: x.getSourceProjectUid()
DeliveryCell.getBaobabSourceProjectUid__roles__ = PermissionRole(Permissions.View)

DeliveryCell.getBaobabDestinationProjectUid = lambda x: x.getDestinationProjectUid()
DeliveryCell.getBaobabDestinationProjectUid__roles__ = PermissionRole(Permissions.View)
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217



### Dynamic patch
Container.getBaobabSourceUid = lambda x: x.getSourceUid()
Container.getBaobabSourceUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabDestinationUid = lambda x: x.getDestinationUid()
Container.getBaobabDestinationUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabSourceSectionUid = lambda x: x.getSourceSectionUid()
Container.getBaobabSourceSectionUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabDestinationSectionUid = lambda x: x.getDestinationSectionUid()
Container.getBaobabDestinationSectionUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabSourcePaymentUid = lambda x: x.getSourcePaymentUid()
Container.getBaobabSourcePaymentUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabDestinationPaymentUid = lambda x: x.getDestinationPaymentUid()
Container.getBaobabDestinationPaymentUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabSourceFunctionUid = lambda x: x.getSourceFunctionUid()
Container.getBaobabSourceFunctionUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabDestinationFunctionUid = lambda x: x.getDestinationFunctionUid()
Container.getBaobabDestinationFunctionUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabSourceProjectUid = lambda x: x.getSourceProjectUid()
Container.getBaobabSourceProjectUid__roles__ = PermissionRole(Permissions.View)

Container.getBaobabDestinationProjectUid = lambda x: x.getDestinationProjectUid()
Container.getBaobabDestinationProjectUid__roles__ = PermissionRole(Permissions.View)
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249


### Dynamic patch
InventoryLine.getBaobabSourceUid = lambda x: x.getSourceUid()
InventoryLine.getBaobabSourceUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabDestinationUid = lambda x: x.getDestinationUid()
InventoryLine.getBaobabDestinationUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabSourceSectionUid = lambda x: x.getSourceSectionUid()
InventoryLine.getBaobabSourceSectionUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabDestinationSectionUid = lambda x: x.getDestinationSectionUid()
InventoryLine.getBaobabDestinationSectionUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabSourcePaymentUid = lambda x: x.getSourcePaymentUid()
InventoryLine.getBaobabSourcePaymentUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabDestinationPaymentUid = lambda x: x.getDestinationPaymentUid()
InventoryLine.getBaobabDestinationPaymentUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabSourceFunctionUid = lambda x: x.getSourceFunctionUid()
InventoryLine.getBaobabSourceFunctionUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabDestinationFunctionUid = lambda x: x.getDestinationFunctionUid()
InventoryLine.getBaobabDestinationFunctionUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabSourceProjectUid = lambda x: x.getSourceProjectUid()
InventoryLine.getBaobabSourceProjectUid__roles__ = PermissionRole(Permissions.View)

InventoryLine.getBaobabDestinationProjectUid = lambda x: x.getDestinationProjectUid()
InventoryLine.getBaobabDestinationProjectUid__roles__ = PermissionRole(Permissions.View)
250 251 252 253 254 255 256


def getDeliveryValue(self):
  """
  """
  return self

Aurel's avatar
Aurel committed
257
Currency.getDeliveryValue = getDeliveryValue