Commit 456ab1c3 authored by Kevin Deldycke's avatar Kevin Deldycke

Basic support of Cash Inventory


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3205 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eaad40ed
...@@ -99,10 +99,12 @@ class BaobabConduit(ERP5Conduit): ...@@ -99,10 +99,12 @@ class BaobabConduit(ERP5Conduit):
, 'erp5_property': 'bic_code' , 'erp5_property': 'bic_code'
, 'conditions' : {'erp5_portal_type':'Organisation'} , 'conditions' : {'erp5_portal_type':'Organisation'}
} }
, { 'xml_property' : 'intitule' , { 'xml_property' : 'intitule'
, 'erp5_property': 'title' , 'erp5_property': 'title'
, 'conditions' : {'erp5_portal_type':'Bank Account'} , 'conditions' : {'erp5_portal_type':'Bank Account'}
} }
, { 'xml_property' : 'montant_maxi' , { 'xml_property' : 'montant_maxi'
, 'erp5_property': 'operation_upper_limit' , 'erp5_property': 'operation_upper_limit'
, 'conditions' : {'erp5_portal_type':'Agent Privilege'} , 'conditions' : {'erp5_portal_type':'Agent Privilege'}
...@@ -111,6 +113,11 @@ class BaobabConduit(ERP5Conduit): ...@@ -111,6 +113,11 @@ class BaobabConduit(ERP5Conduit):
, 'erp5_property': 'description' , 'erp5_property': 'description'
, 'conditions' : {'erp5_portal_type':'Agent Privilege'} , 'conditions' : {'erp5_portal_type':'Agent Privilege'}
} }
, { 'xml_property' : 'inventory_title'
, 'erp5_property': 'title'
, 'conditions' : {'erp5_portal_type':'Cash Inventory'}
}
] ]
""" """
...@@ -120,7 +127,7 @@ class BaobabConduit(ERP5Conduit): ...@@ -120,7 +127,7 @@ class BaobabConduit(ERP5Conduit):
security.declarePrivate('buildConditions') security.declarePrivate('buildConditions')
def buildConditions(self, object): def buildConditions(self, object):
""" """
Build a condition dictionnary Build a condition dictionnary
""" """
dict = {} dict = {}
dict['erp5_portal_type'] = object.getPortalType() dict['erp5_portal_type'] = object.getPortalType()
...@@ -129,7 +136,7 @@ class BaobabConduit(ERP5Conduit): ...@@ -129,7 +136,7 @@ class BaobabConduit(ERP5Conduit):
security.declarePrivate('findPropertyMapItem') security.declarePrivate('findPropertyMapItem')
def findPropertyMapItem(self, xml_property_name, conditions): def findPropertyMapItem(self, xml_property_name, conditions):
""" """
Find the property_map item that match conditions Find the property_map item that match conditions
""" """
for item in property_map: for item in property_map:
if item['xml_property'] == xml_property_name: if item['xml_property'] == xml_property_name:
...@@ -147,11 +154,12 @@ class BaobabConduit(ERP5Conduit): ...@@ -147,11 +154,12 @@ class BaobabConduit(ERP5Conduit):
security.declareProtected(Permissions.ModifyPortalContent, 'constructContent') security.declareProtected(Permissions.ModifyPortalContent, 'constructContent')
def constructContent(self, object, object_id, docid, portal_type): def constructContent(self, object, object_id, docid, portal_type):
""" """
This is a redefinition of the original ERP5Conduit.constructContent function to create Baobab objects This is a redefinition of the original ERP5Conduit.constructContent function to create Baobab objects
""" """
erp5_site_path = object.absolute_url(relative=1) erp5_site_path = object.absolute_url(relative=1)
person_folder = object.restrictedTraverse(erp5_site_path + '/person') person_module = object.restrictedTraverse(erp5_site_path + '/person')
organisation_folder = object.restrictedTraverse(erp5_site_path + '/organisation') organisation_module = object.restrictedTraverse(erp5_site_path + '/organisation')
cash_inventory_module = object.restrictedTraverse(erp5_site_path + '/cash_inventory_module')
subobject = None subobject = None
...@@ -176,12 +184,14 @@ class BaobabConduit(ERP5Conduit): ...@@ -176,12 +184,14 @@ class BaobabConduit(ERP5Conduit):
# handle client objects # handle client objects
if portal_type.startswith('Client'): if portal_type.startswith('Client'):
if portal_type[-3:] == 'PER': if portal_type[-3:] == 'PER':
subobject = person_folder.newContent( portal_type = 'Person' subobject = person_module.newContent( portal_type = 'Person'
, id = object_id) , id = object_id
)
subobject.setCareerRole('client') subobject.setCareerRole('client')
else: else:
subobject = organisation_folder.newContent( portal_type = 'Organisation' subobject = organisation_module.newContent( portal_type = 'Organisation'
, id = object_id) , id = object_id
)
subobject.setRole('client') subobject.setRole('client')
# handle bank account objects # handle bank account objects
...@@ -189,11 +199,13 @@ class BaobabConduit(ERP5Conduit): ...@@ -189,11 +199,13 @@ class BaobabConduit(ERP5Conduit):
owner = findObjectFromSpecialPortalType(portal_type) owner = findObjectFromSpecialPortalType(portal_type)
if owner == None: return None if owner == None: return None
subobject = owner.newContent( portal_type = 'Bank Account' subobject = owner.newContent( portal_type = 'Bank Account'
, id = object_id) , id = object_id
)
# set the bank account owner as agent with no-limit privileges (only for persons) # set the bank account owner as agent with no-limit privileges (only for persons)
if owner.getPortalType() == 'Person': if owner.getPortalType() == 'Person':
new_agent = subobject.newContent( portal_type = 'Agent' new_agent = subobject.newContent( portal_type = 'Agent'
, id = 'owner') , id = 'owner'
)
new_agent.setAgent(owner.getRelativeUrl()) new_agent.setAgent(owner.getRelativeUrl())
privileges = ( 'circularization' privileges = ( 'circularization'
, 'cash_out' , 'cash_out'
...@@ -211,12 +223,14 @@ class BaobabConduit(ERP5Conduit): ...@@ -211,12 +223,14 @@ class BaobabConduit(ERP5Conduit):
dest = findObjectFromSpecialPortalType(portal_type) dest = findObjectFromSpecialPortalType(portal_type)
if dest == None: return None if dest == None: return None
subobject = dest.newContent( portal_type = 'Agent' subobject = dest.newContent( portal_type = 'Agent'
, id = object_id) , id = object_id
)
# try to get the agent in the person module # try to get the agent in the person module
person = findObjectFromSpecialPortalType('Person_' + object_id) person = findObjectFromSpecialPortalType('Person_' + object_id)
if person == None: if person == None:
person = person_folder.newContent( portal_type = 'Person' person = person_module.newContent( portal_type = 'Person'
, id = object_id + 'a') , id = object_id + 'a'
)
subobject.setAgent(person.getRelativeUrl()) subobject.setAgent(person.getRelativeUrl())
# handle privilege objects # handle privilege objects
...@@ -224,13 +238,27 @@ class BaobabConduit(ERP5Conduit): ...@@ -224,13 +238,27 @@ class BaobabConduit(ERP5Conduit):
dest = findObjectFromSpecialPortalType(portal_type) dest = findObjectFromSpecialPortalType(portal_type)
if dest == None: return None if dest == None: return None
subobject = dest.newContent( portal_type = 'Agent Privilege' subobject = dest.newContent( portal_type = 'Agent Privilege'
, id = object_id) , id = object_id
)
# handle inventory objects
elif portal_type == 'Cash Inventory':
if cash_inventory_module == None: return None
subobject = cash_inventory_module.newContent( portal_type = 'Cash Inventory'
, id = object_id
)
# handle inventory details objects
elif portal_type == 'Cash Inventory Detail':
subobject = object.newContent( portal_type = 'Cash Inventory Line'
, id = object_id
)
return subobject return subobject
# EXPERIMENTAL ### EXPERIMENTAL
# security.declareProtected(Permissions.ModifyPortalContent, 'getProperty') # security.declareProtected(Permissions.ModifyPortalContent, 'getProperty')
# def getProperty(self, object, kw): # def getProperty(self, object, kw):
# """ # """
...@@ -256,10 +284,10 @@ class BaobabConduit(ERP5Conduit): ...@@ -256,10 +284,10 @@ class BaobabConduit(ERP5Conduit):
security.declareProtected(Permissions.ModifyPortalContent, 'editDocument') security.declareProtected(Permissions.ModifyPortalContent, 'editDocument')
def editDocument(self, object=None, **kw): def editDocument(self, object=None, **kw):
""" """
This function transfer datas from the dictionary to the baobab document object given in parameters This function transfer datas from the dictionary to the baobab document object given in parameters
""" """
# EXPERIMENTAL ### EXPERIMENTAL
# This message help to track in the log when an object is edited # This message help to track in the log when an object is edited
# It permit us to verify the consistency of a synchronisation process : # It permit us to verify the consistency of a synchronisation process :
# 1- Launch a normal synchronisation. # 1- Launch a normal synchronisation.
...@@ -301,8 +329,8 @@ class BaobabConduit(ERP5Conduit): ...@@ -301,8 +329,8 @@ class BaobabConduit(ERP5Conduit):
""" """
All functions below are defined to set a document's property to a value given in parameters. All functions below are defined to set a document's property to a value given in parameters.
The name of those functions are chosen to help the transfert of datas from a given XML format to standard Baobab objects. The name of those functions are chosen to help the transfert of datas from a given XML format to standard Baobab objects.
""" """
# Client-related-properties functions # Client-related-properties functions
...@@ -394,7 +422,8 @@ class BaobabConduit(ERP5Conduit): ...@@ -394,7 +422,8 @@ class BaobabConduit(ERP5Conduit):
def editMandataireService(self, document, value): def editMandataireService(self, document, value):
assignment = document.getAgentValue().newContent( portal_type = 'Assignment' assignment = document.getAgentValue().newContent( portal_type = 'Assignment'
, id = 'service') , id = 'service'
)
assignment.setGroup(value) assignment.setGroup(value)
return return
...@@ -436,4 +465,19 @@ class BaobabConduit(ERP5Conduit): ...@@ -436,4 +465,19 @@ class BaobabConduit(ERP5Conduit):
def editPouvoirDateFin(self, document, value): def editPouvoirDateFin(self, document, value):
if document.getStartDate() in ('', None): if document.getStartDate() in ('', None):
document.setStartDate(str(datetime.datetime.min)) document.setStartDate(str(datetime.datetime.min))
document.setStopDate(value) document.setStopDate(value)
\ No newline at end of file
# CashInventory-related-properties functions
def editCashInventoryInventoryDate(self, document, value):
if value in ('', None):
date = str(datetime.datetime.max)
else:
# Convert french date to strandard date
date_items = value.split('/')
day = date_items[0]
month = date_items[1]
year = date_items[2]
date = '/'.join([year, month, day])
document.setStopDate(date)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment