Commit b1e29d6e authored by Thierry's avatar Thierry

new


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@71 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8d706077
##############################################################################
#
# Copyright (c) 2003 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# 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
#
# This program as such is not intended to be used by end users. 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 Zope Public License (ZPL) Version 2.0
#
# This program 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.
#
##############################################################################
code_ean13_client = {}
def getCodeEan13Client(self) :
"""
Add as extension Amount_getCodeEan13Client
self -- an amount (movement, delivery line, etc.)
"""
coloris = self.getColoris()
taille = self.getTaille()
morphologie = self.getMorphologie()
resource = self.getResource()
resource_value = self.getResourceValue()
if resource_value is None:
return ''
else :
variated_reference_list = resource_value.contentValues(filter={'portal_type':'Variated Reference'})
# we search a variated_reference wich define 'code_ean13'
my_variated_reference = None
for variated_reference in variated_reference_list :
if len(variated_reference.getMappedValuePropertyList()) <> 0 :
if variated_reference.getMappedValuePropertyList()[0] == 'code_ean13' :
my_variated_reference = variated_reference
break
predicate_value = []
if my_variated_reference is not None :
base_category_list = my_variated_reference.getVariationBaseCategoryList()
if 'coloris' in base_category_list and coloris :
predicate_value.append('coloris/'+coloris)
if 'taille' in base_category_list and taille :
predicate_value.append('taille/'+taille)
if 'morphologie' in base_category_list and morphologie :
predicate_value.append('morphologie/'+morphologie)
predicate_value.sort()
key = tuple([resource] + predicate_value)
if code_ean13_client.has_key(key):
return code_ean13_client[key] # This is an infinite cache
# Build cache
if my_variated_reference is not None :
mapped_value_list = my_variated_reference.objectValues()
# Fill the cache
for cell in mapped_value_list:
predicate_value = []
for predicate_value_item in cell.getPredicateValueList():
if predicate_value_item <> 'value' :
predicate_value.append(predicate_value_item)
predicate_value.sort()
new_key = tuple([resource] + predicate_value)
code_ean13_client[new_key] = cell.getProperty(key='code_ean13')
else :
return ''
if code_ean13_client.has_key(key):
return code_ean13_client[key]
return ''
def getCodeEan13ClientKeyList():
return str(code_ean13_client.keys())
##############################################################################
#
# Copyright (c) 2003 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# 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
#
# This program as such is not intended to be used by end users. 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 Zope Public License (ZPL) Version 2.0
#
# This program 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.
#
##############################################################################
code_modele_client = {}
def getCodeModeleClient(self) :
"""
Add as extension Amount_getCodeModeleClient
self -- an amount (movement, delivery line, etc.)
"""
coloris = self.getColoris()
taille = self.getTaille()
morphologie = self.getMorphologie()
resource = self.getResource()
resource_value = self.getResourceValue()
if resource_value is None:
return ''
else :
variated_reference_list = resource_value.contentValues(filter={'portal_type':'Variated Reference'})
# we search a variated_reference wich define 'code_modele'
my_variated_reference = None
for variated_reference in variated_reference_list :
if len(variated_reference.getMappedValuePropertyList()) <> 0 :
if variated_reference.getMappedValuePropertyList()[0] == 'code_modele' :
my_variated_reference = variated_reference
break
predicate_value = []
if my_variated_reference is not None :
base_category_list = my_variated_reference.getVariationBaseCategoryList()
if 'coloris' in base_category_list and coloris :
predicate_value.append('coloris/'+coloris)
if 'taille' in base_category_list and taille :
predicate_value.append('taille/'+taille)
if 'morphologie' in base_category_list and morphologie :
predicate_value.append('morphologie/'+morphologie)
predicate_value.sort()
key = tuple([resource] + predicate_value)
if code_modele_client.has_key(key):
return code_modele_client[key] # This is an infinite cache
# Build cache
if my_variated_reference is not None :
mapped_value_list = my_variated_reference.objectValues()
# Fill the cache
for cell in mapped_value_list:
predicate_value = []
for predicate_value_item in cell.getPredicateValueList():
if predicate_value_item <> 'value' :
predicate_value.append(predicate_value_item)
predicate_value.sort()
new_key = tuple([resource] + predicate_value)
code_modele_client[new_key] = cell.getProperty(key='code_modele')
else :
return resource_value.getDestinationReference('')
if code_modele_client.has_key(key):
return code_modele_client[key]
return resource_value.getDestinationReference('')
def getCodeModeleClientKeyList():
return str(code_modele_client.keys())
##############################################################################
#
# Copyright (c) 2003 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# 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
#
# This program as such is not intended to be used by end users. 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 Zope Public License (ZPL) Version 2.0
#
# This program 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.
#
##############################################################################
coloris_client = {}
def getColorisClient(self) :
"""
Add as extension Amount_getColorisClient
self -- an amount (movement, delivery line, etc.)
"""
coloris = self.getColoris()
taille = self.getTaille()
morphologie = self.getMorphologie()
resource = self.getResource()
resource_value = self.getResourceValue()
coloris_value = self.getColorisValue()
if resource_value is None:
return ''
else :
variated_reference_list = resource_value.contentValues(filter={'portal_type':'Variated Reference'})
# we search a variated_reference wich define 'code_coloris'
my_variated_reference = None
for variated_reference in variated_reference_list :
if len(variated_reference.getMappedValuePropertyList()) <> 0 :
if variated_reference.getMappedValuePropertyList()[0] == 'code_coloris' :
my_variated_reference = variated_reference
break
predicate_value = []
if my_variated_reference is not None :
base_category_list = my_variated_reference.getVariationBaseCategoryList()
if 'coloris' in base_category_list and coloris :
predicate_value.append('coloris/'+coloris)
if 'taille' in base_category_list and taille :
predicate_value.append('taille/'+taille)
if 'morphologie' in base_category_list and morphologie :
predicate_value.append('morphologie/'+morphologie)
predicate_value.sort()
key = tuple([resource] + predicate_value)
if coloris_client.has_key(key):
return coloris_client[key] # This is an infinite cache
# Build cache
if my_variated_reference is not None :
mapped_value_list = my_variated_reference.objectValues()
# Fill the cache
for cell in mapped_value_list:
predicate_value = []
for predicate_value_item in cell.getPredicateValueList():
if predicate_value_item <> 'value' :
predicate_value.append(predicate_value_item)
predicate_value.sort()
new_key = tuple([resource] + predicate_value)
coloris_client[new_key] = cell.getProperty(key='code_coloris')
else :
if coloris_value is not None :
if not coloris_value.getDestinationReference() in (None, '') :
return coloris_value.getDestinationReference('')
else :
return coloris.split('/')[-1]
else :
return coloris.split('/')[-1]
if coloris_client.has_key(key):
return coloris_client[key]
if coloris_value is not None :
if not coloris_value.getDestinationReference() in (None, '') :
return coloris_value.getDestinationReference('')
else :
return coloris.split('/')[-1]
else :
return coloris.split('/')[-1]
def getColorisClientKeyList():
return str(coloris_client.keys())
##############################################################################
#
# Copyright (c) 2003 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# 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
#
# This program as such is not intended to be used by end users. 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 Zope Public License (ZPL) Version 2.0
#
# This program 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.
#
##############################################################################
prix_consommateur = {}
def getPrixConsommateur(self) :
"""
Add as extension Amount_getPrixConsommateur
self -- an amount (movement, delivery line, etc.)
"""
coloris = self.getColoris()
taille = self.getTaille()
morphologie = self.getMorphologie()
resource = self.getResource()
resource_value = self.getResourceValue()
if resource_value is None:
return '0'
else :
variated_reference_list = resource_value.contentValues(filter={'portal_type':'Variated Reference'})
# we search a variated_reference wich define 'code_ean13'
my_variated_reference = None
for variated_reference in variated_reference_list :
if len(variated_reference.getMappedValuePropertyList()) <> 0 :
if variated_reference.getMappedValuePropertyList()[0] == 'prix_consommateur' :
my_variated_reference = variated_reference
break
predicate_value = []
if my_variated_reference is not None :
base_category_list = my_variated_reference.getVariationBaseCategoryList()
if 'coloris' in base_category_list and coloris :
predicate_value.append('coloris/'+coloris)
if 'taille' in base_category_list and taille :
predicate_value.append('taille/'+taille)
if 'morphologie' in base_category_list and morphologie :
predicate_value.append('morphologie/'+morphologie)
predicate_value.sort()
key = tuple([resource] + predicate_value)
if prix_consommateur.has_key(key):
return prix_consommateur[key] # This is an infinite cache
# Build cache
if my_variated_reference is not None :
mapped_value_list = my_variated_reference.objectValues()
# Fill the cache
for cell in mapped_value_list:
predicate_value = []
for predicate_value_item in cell.getPredicateValueList():
if predicate_value_item <> 'value' :
predicate_value.append(predicate_value_item)
predicate_value.sort()
new_key = tuple([resource] + predicate_value)
prix_consommateur[new_key] = cell.getProperty(key='prix_consommateur')
else :
return '0'
if prix_consommateur.has_key(key):
return prix_consommateur[key]
return '0'
def getPrixConsommateurKeyList():
return str(prix_consommateur.keys())
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