Commit 330ef75f authored by Jean-Paul Smets's avatar Jean-Paul Smets

Global Udate to Latest Coramy Optimizations (force in rules)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@529 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a51dbd2c
......@@ -903,6 +903,21 @@ class CategoryTool( UniqueObject, Folder, Base ):
return 1
return 0
security.declareProtected( Permissions.AccessContentsInformation, 'isAcquiredMemberOf' )
def isAcquiredMemberOf(self, context, category):
"""
Tests if an object if member of a given category
Category is a string here. It could be more than a string (ex. an object)
XXX Should include acquisition ?
"""
if getattr(aq_base(context), 'isCategory', 0):
return context.isAcquiredMemberOf(category)
for c in self._getAcquiredCategoryList(context):
if c.find(category) >= 0:
return 1
return 0
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryList' )
def getCategoryList(self, context):
self._cleanupCategories(context)
......
......@@ -178,3 +178,4 @@ un modele..."""
#pass
self.modele_compute_pri(batch_mode=1)
......@@ -217,60 +217,60 @@
<title>Right</title>
<fields>
<field><id>my_organisation_title</id> <type>RelationStringField</type>
<field><id>my_default_email_text</id> <type>EmailField</type>
<values>
<alternate_name></alternate_name>
<base_category>subordination</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<display_width type="int">30</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation')]</portal_type>
<required type="int">0</required>
<title>Organisation</title>
<title>Email</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
<default>here/getDefaultEmailText</default>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
<message name="not_email">You did not enter an email address.</message>
</messages>
</field>
<field><id>my_default_email_text</id> <type>EmailField</type>
<field><id>my_organisation_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>subordination</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">30</display_width>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation')]</portal_type>
<required type="int">0</required>
<title>Email</title>
<title>Organisation</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
<default>here/getDefaultEmailText</default>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
<message name="not_email">You did not enter an email address.</message>
</messages>
</field>
<field><id>my_default_telephone_text</id> <type>StringField</type>
......
......@@ -76,4 +76,10 @@ if fix:
for delivery in delivery_list:
print " New delivery %s for causality %s" % (delivery.getRelativeUrl(), ' '.join(delivery.getCausalityList()))
# Invoke delivery rule
if len(requires_delivery_rule) > 0:
if fix:
context.updateAppliedRule()
print "Building new delivery rule"
return printed
......@@ -17,4 +17,4 @@ WHERE
<dtml-if priority> AND priority = <dtml-sqlvar priority type="int"> </dtml-if>
ORDER BY
priority, date
\ No newline at end of file
priority, date
......@@ -22,4 +22,4 @@ WHERE
GROUP BY
path, method_id, processing_node, processing
ORDER BY
priority, date
\ No newline at end of file
priority, date
......@@ -19,4 +19,4 @@ SET
processing_node = -1,
processing = -1,
priority = <dtml-sqlvar priority type="int">,
message = <dtml-sqlvar message type="string">
\ No newline at end of file
message = <dtml-sqlvar message type="string">
......@@ -26,4 +26,6 @@ elif local_user in equipe2 :
elif local_user in equipe3 :
object.AssignLocalRole(user_list=equipe3,role_list=['GestionaireDesigne',])
else :
object.AssignLocalRole(user_list=[local_user,],role_list=['GestionaireDesigne',])
if user_name == "AnimatriceAppros" :
local_user = 'Michele_Kmiecik'
object.AssignLocalRole(user_list=[local_user,],role_list=['GestionaireDesigne',])
......@@ -68,8 +68,8 @@ AND resource_membership.category_uid = resource_c.uid
AND resource_membership.base_category_uid = resource_bc.uid
AND resource_membership.uid = resource.uid
</dtml-if><dtml-if omit_simulation>AND catalog.portal_type != "Simulation Movement"
</dtml-if><dtml-if omit_input>AND stock.quantity < 0
</dtml-if><dtml-if omit_output>AND stock.quantity > 0
</dtml-if><dtml-if omit_input>AND stock.quantity < 0 AND movement.source_uid <> movement.destination_uid
</dtml-if><dtml-if omit_output>AND stock.quantity > 0 AND movement.source_uid <> movement.destination_uid
</dtml-if><dtml-if simulation_state>AND (<dtml-in simulation_state> catalog.simulation_state = <dtml-sqlvar sequence-item type="string"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if query>AND category.uid = node.uid
AND <dtml-var query></dtml-if>
\ No newline at end of file
......@@ -67,8 +67,8 @@ AND movement.resource_uid = resource.uid
</dtml-if><dtml-if to_date>AND movement.stop_date < <dtml-sqlvar to_date type="string">
</dtml-if><dtml-if "variation_text is not None">AND movement.variation_text = <dtml-sqlvar variation_text type="string">
</dtml-if><dtml-if omit_simulation>AND catalog.portal_type != "Simulation Movement"
</dtml-if><dtml-if omit_input>AND stock.quantity < 0
</dtml-if><dtml-if omit_output>AND stock.quantity > 0
</dtml-if><dtml-if omit_input>AND stock.quantity < 0 AND movement.source_uid <> movement.destination_uid
</dtml-if><dtml-if omit_output>AND stock.quantity > 0 AND movement.source_uid <> movement.destination_uid
</dtml-if><dtml-if node_category>AND node_c.relative_url = <dtml-sqlvar node_category type="string">
AND node_membership.category_uid = node_c.uid
AND node_membership.base_category_uid = node_bc.uid
......
......@@ -4,7 +4,7 @@
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=import_file, segmentation_strategique='2003-2004', incoterm='DAF',delivery_mode='Transporteur', order_type='Approvisionnement', travel_duration=0, batch_mode=0,**kw
##parameters=import_file, segmentation_strategique='2003-2004', incoterm='DAF',delivery_mode='Transporteur', order_type='Approvisionnement', travel_duration=0, batch_mode=0,user_name='',**kw
##title=
##
# import d'un fichier EDI
......@@ -70,9 +70,11 @@ sales_order.setDeliveryMode(delivery_mode)
sales_order.setIncoterm(incoterm)
sales_order.setOrderType(order_type)
# set the source administration
local_user = container.portal_membership.getAuthenticatedMember()
local_user_name = string.replace(local_user.getUserName(), ' ', '_')
#local_user = container.portal_membership.getAuthenticatedMember()
#local_user_name = string.replace(local_user.getUserName(), '_', ' ')
local_user_name = string.replace(user_name, '_', ' ')
local_persons = sales_order.item_by_title_sql_search(title = local_user_name, portal_type = 'Person')
if len(local_persons) > 0:
sales_order.setSourceAdministration(local_persons[0].relative_url)
......@@ -272,7 +274,11 @@ sales_order.flushActivity(invoke=1)
# try to apply a sale condition
sales_order.sales_order_apply_condition(my_id, 1)
# change the workflow to create the sales packing list
# give the role to user
sales_order.Item_doWorkflowTransition(workflow_action='user_order', workflow_id='order_workflow')
#sales_order.flushActivity(invoke=1)
sales_order.Item_doWorkflowTransition(workflow_action='user_confirm', workflow_id='order_workflow')
# and this is the end ....
if batch_mode:
......
......@@ -526,6 +526,28 @@
<infostring align="left" x="1.1cm" y="3.2cm" size="5" font="Helvetica" color="(0,0,0)">
dues cette date de rglement en principal, frais et taxes inclus, et au taux de l'intrt lgal major de 5 points, sans que cette pnalit puisse tre en toute hypothse infrieure 1,5 fois le taux de l'intrt lgal.
</infostring>
<infostring align="left" x="10cm" y="24.7cm" size="9"
font="Helvetica-Oblique" color="(0,0,0)">
Rpartition par tailles
</infostring>
<infostring align="left" x="15.4cm" y="24.7cm" size="9"
font="Helvetica-Oblique" color="(0,0,0)">
Quantit
</infostring>
<infostring align="left" x="17.1cm" y="24.7cm" size="9"
font="Helvetica-Oblique" color="(0,0,0)">
P.U.H.T.
</infostring>
<infostring align="left" x="18.8cm" y="24.7cm" size="9"
font="Helvetica-Oblique" color="(0,0,0)">
Total H.T.
</infostring>
<!-- Pied de facture -->
<rectangle x="1cm" y="5.0cm" width="19.5cm" height="0.8cm"
linewidth="0" fill="(0.75,0.75,0.75)"/>
<line x1="1cm" x2="20.5cm" y1="5.8cm" y2="5.8cm" width="1"/>
<line x1="1cm" x2="20.5cm" y1="5.0cm" y2="5.0cm" width="1"/>
</static>
......@@ -608,7 +630,7 @@
<line x1="20.5cm" x2="20.5cm" y1="25cm" y2="4cm" width="1"/>
<line x1="1cm" x2="20.5cm" y1="4cm" y2="4cm" width="1"/>
<!-- Dtail de la facture -->
<rectangle x="1cm" y="24.6cm" width="19.5cm" height="0.4cm"
linewidth="0" fill="(0.75,0.75,0.75)"/>
......@@ -696,12 +718,12 @@
<infostring align="center" x="3.8cm" y="4.5cm" size="9"
font="Helvetica" color="(0,0,0)">
</infostring>
<infostring align="left" x="6.5cm" y="4.5cm" size="9"
font="Helvetica" color="(0,0,0)"
tal:content="python: '%.2f' % income">
</infostring>
<tal:block tal:condition="python: vad_recoverable">
<infostring align="center" x="9.7cm" y="4.5cm" size="9"
......@@ -712,7 +734,7 @@
</tal:block>
<infostring align="left" x="10.7cm" y="4.5cm" size="9"
font="Helvetica" color="(0,0,0)">
</infostring>
<infostring align="center" x="13.8cm" y="4.5cm" size="10"
font="Helvetica-Bold" color="(0,0,0)"
......@@ -722,7 +744,7 @@
<infostring align="center" x="16cm" y="4.5cm" size="10"
font="Helvetica-Bold" color="(0,0,0)"
tal:content="python: resource_id">
resource_id XXX
resource_id XXX
</infostring>
<infostring align="left" x="18cm" y="4.5cm" size="10"
font="Helvetica-Bold" color="(0,0,0)"
......
......@@ -140,6 +140,36 @@
<message name="unknown_selection">You selected an item that was not in the list.</message>
</messages>
</field>
<field><id>my_source_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>source</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation'), ('Category', 'Category'), ('Person', 'Person')]</portal_type>
<required type="int">0</required>
<title>Expdi par</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
</fields>
</group>
<group>
......@@ -231,6 +261,61 @@
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>destination_address</id> <type>StringField</type>
<values>
<alternate_name></alternate_name>
<css_class></css_class>
<default></default>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">1</hidden>
<max_length></max_length>
<required type="int">0</required>
<title>Lieu livraison : inconnu</title>
<truncate type="int">0</truncate>
</values>
<tales>
<title>python: here.getDestinationValue(portal_type=['Organisation']).Organisation_getOneLineAddress()</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>my_destination_section_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>destination_section</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation'), ('Category', 'Category'), ('Person', 'Person')]</portal_type>
<required type="int">0</required>
<title>Pour le compte de</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>my_start_date</id> <type>DateTimeField</type>
<values>
<alternate_name></alternate_name>
......@@ -248,7 +333,7 @@
<title>Date d'expdition prvue</title>
</values>
<tales>
<title>python:'Date d'expdition prvue : %s' % here.getStartDate()</title>
<title>python:'Expdition prvue le : ' + here.getStartDate().strftime('%d/%m/%Y')</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
......@@ -299,7 +384,7 @@
<title>Date de livraison prvue</title>
</values>
<tales>
<title>python:'Date de livraison prvue : %s' % here.getStopDate()</title>
<title>python:'Livraison prvue le : ' + here.getStopDate().strftime('%d/%m/%Y')</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
......
......@@ -140,6 +140,36 @@
<message name="unknown_selection">You selected an item that was not in the list.</message>
</messages>
</field>
<field><id>my_source_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>source</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation'), ('Category', 'Category'), ('Person', 'Person')]</portal_type>
<required type="int">0</required>
<title>Expdi par</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
</fields>
</group>
<group>
......@@ -231,6 +261,61 @@
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>destination_address</id> <type>StringField</type>
<values>
<alternate_name></alternate_name>
<css_class></css_class>
<default></default>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">1</hidden>
<max_length></max_length>
<required type="int">0</required>
<title>Lieu livraison : inconnu</title>
<truncate type="int">0</truncate>
</values>
<tales>
<title>python: here.getDestinationValue(portal_type=['Organisation']).Organisation_getOneLineAddress()</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>my_destination_section_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>destination_section</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation'), ('Category', 'Category'), ('Person', 'Person')]</portal_type>
<required type="int">0</required>
<title>Pour le compte de</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>my_start_date</id> <type>DateTimeField</type>
<values>
<alternate_name></alternate_name>
......@@ -248,7 +333,7 @@
<title>Date d'expdition prvue</title>
</values>
<tales>
<title>python:'Date d'expdition prvue : %s' % here.getStartDate()</title>
<title>python:'Expdition prvue le : ' + here.getStartDate().strftime('%d/%m/%Y')</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
......@@ -299,7 +384,7 @@
<title>Date de livraison prvue</title>
</values>
<tales>
<title>python:'Date de livraison prvue : %s' % here.getStopDate()</title>
<title>python:'Livraison prvue le : ' + here.getStopDate().strftime('%d/%m/%Y')</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
......
......@@ -8,7 +8,7 @@
page_number python:[0]">
<TABLE tal:repeat="delivery delivery_list" width="660" height="955" cellpadding="0" cellspacing="0" tal:attributes="class python:here.PT_pageBreak(page_number)">
<TABLE border="0" width="660" height="900" cellpadding="0" cellspacing="0"
tal:define="order python:delivery.getCausalityValue(portal_type=['Sales Order']);
tal:define="order python:delivery.getCausalityValue(portal_type=['Sales Order','Sales Packing List']);
destination python:delivery.getDestinationValue(portal_type=['Organisation']);
delivery_line_list python:filter(lambda line_item: line_item.getTargetTotalQuantity() > 0, delivery.contentValues(filter={'portal_type':
'Sales Packing List Line'}));
......
......@@ -140,6 +140,36 @@
<message name="unknown_selection">You selected an item that was not in the list.</message>
</messages>
</field>
<field><id>my_source_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>source</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation'), ('Category', 'Category'), ('Person', 'Person')]</portal_type>
<required type="int">0</required>
<title>Expdi par</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
</fields>
</group>
<group>
......@@ -248,7 +278,37 @@
<truncate type="int">0</truncate>
</values>
<tales>
<title>python: 'Lieu livraison : %s %s' % (here.getDestinationValue(portal_type=['Organisation']).getDefaultAddress().getZipCode(),here.getDestinationValue(portal_type=['Organisation']).getDefaultAddress().getCity())</title>
<title>python: here.getDestinationValue(portal_type=['Organisation']).Organisation_getOneLineAddress()</title>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
<message name="required_not_found">Input is required but no input given.</message>
<message name="too_long">Too much input was given.</message>
</messages>
</field>
<field><id>my_destination_section_title</id> <type>RelationStringField</type>
<values>
<alternate_name></alternate_name>
<base_category>destination_section</base_category>
<catalog_index>Title</catalog_index>
<css_class></css_class>
<default></default>
<default_module>organisation</default_module>
<description></description>
<display_maxwidth></display_maxwidth>
<display_width type="int">20</display_width>
<external_validator></external_validator>
<extra></extra>
<hidden type="int">0</hidden>
<jump_method>base_jump_relation</jump_method>
<max_length></max_length>
<portal_type type="list">[('Organisation', 'Organisation'), ('Category', 'Category'), ('Person', 'Person')]</portal_type>
<required type="int">0</required>
<title>Pour le compte de</title>
<truncate type="int">0</truncate>
<update_method>base_update_relation</update_method>
</values>
<tales>
</tales>
<messages>
<message name="external_validator_failed">The input failed the external validator.</message>
......@@ -587,4 +647,4 @@
</fields>
</group>
</groups>
</form>
\ No newline at end of file
</form>
......@@ -163,7 +163,7 @@ An ERP5 Rule..."""
rule.reset(self)
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self):
def expand(self, **kw):
"""
Expands the current movement downward.
......
......@@ -120,7 +120,7 @@ An ERP5 Rule..."""
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule):
def expand(self, applied_rule, **kw):
"""
Expands the current movement downwards.
......@@ -136,7 +136,9 @@ An ERP5 Rule..."""
# Only expand if my_delivery is not None and state is not 'confirmed'
if my_delivery is not None:
if my_delivery.getSimulationState() not in ('delivered', ):
#if my_delivery.getSimulationState() not in ('delivered', ):
# Even if delivered, we should always calculate consequences
if 1:
# First, check each contained movement and make
# a list of delivery ids which do not need to be copied
# eventually delete movement which do not exist anylonger
......@@ -216,7 +218,7 @@ An ERP5 Rule..."""
% delivery_line_object.absolute_url())
# Pass to base class
Rule.expand(self, applied_rule)
Rule.expand(self, applied_rule, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'solve')
def solve(self, applied_rule, solution_list):
......
......@@ -236,20 +236,24 @@ An order..."""
my_applied_rule_list = self.getCausalityRelatedValueList(portal_type='Applied Rule')
if len(my_applied_rule_list) != 1:
# XXX This is an error
return
raise CategoryError, "Order has no or too many order rule(s)"
applied_rule = my_applied_rule_list[0].getObject()
if applied_rule is None:
# XXX This is an error
return
raise CategoryError, "Order has None order rule"
# Make sure applied rule has been reindexed
applied_rule.flushActivity(invoke=1)
# Make sure there are no more activities on this order related to expand
self.flushActivity(invoke=1, method_id='expand') # Make sure expand is finished
self.flushActivity(invoke=0, method_id='expand') # Make sure expand is finished
# We are expanding but are not allowed to if state wrong...
# (ex. confirmed)
applied_rule.expand(force = 1) # thus, we mist force expand of applied order rule
applied_rule.flushActivity(invoke=1)
# Build delivery list on applied rule
# Currently, we build it 'again' but we should actually only build
# deliveries for orphaned movements
if self.getPortalType() == 'Production Order' :
delivery_list = self.ProductionOrder_buildDeliveryList() # Coramy specific moved to portal_simulation
#else:
elif self.getPortalType() in ('Purchase Order', 'Sales Order') :
delivery_list = self.order_create_packing_list() # Coramy specific should be moved to portal_simulation
#self.informDeliveryList(delivery_list=delivery_list, comment=repr(delivery_list)) # XXX Not ready
......
......@@ -29,7 +29,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Rule import Rule
from Products.ERP5.ERP5Globals import movement_type_list, order_movement_type_list
from Products.ERP5.ERP5Globals import movement_type_list, order_movement_type_list, reserved_inventory_state_list, current_inventory_state_list
from zLOG import LOG
......@@ -121,7 +121,7 @@ An ERP5 Rule..."""
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule):
def expand(self, applied_rule, force=0, **kw):
"""
Expands the current movement downward.
......@@ -141,8 +141,9 @@ An ERP5 Rule..."""
if my_order is not None:
# Only expand order rule if order not yet confirmed (This is consistent
# with the fact that once simulation is launched, we stick to it)
if my_order.getSimulationState() not in reserved_inventory_state_list and \
my_order.getSimulationState() not in current_inventory_state_list:
if force or \
(my_order.getSimulationState() not in reserved_inventory_state_list and \
my_order.getSimulationState() not in current_inventory_state_list):
# First, check each contained movement and make
# a list of order ids which do not need to be copied
# eventually delete movement which do not exist anylonger
......@@ -198,7 +199,7 @@ An ERP5 Rule..."""
% order_line_object.absolute_url())
# Pass to base class
Rule.expand(self, applied_rule)
Rule.expand(self, applied_rule, force=force, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'solve')
def solve(self, applied_rule, solution_list):
......
......@@ -167,7 +167,7 @@ An ERP5 Rule..."""
"""
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule):
def expand(self, applied_rule, **kw):
"""
Expands the current movement downward.
......@@ -177,7 +177,7 @@ An ERP5 Rule..."""
is expanded.
"""
for o in applied_rule.objectValues():
o.expand()
o.expand(**kw)
security.declareProtected(Permissions.ModifyPortalContent, 'solve')
def solve(self, applied_rule, solution_list):
......
......@@ -236,7 +236,7 @@ a service in a public administration)."""
# Causality Workflow Methods
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self):
def expand(self, **kw):
"""
-> new status : expanded
......@@ -252,7 +252,7 @@ a service in a public administration)."""
if self.getCausalityState() is 'expanded':
# Reexpand
for my_applied_rule in self.objectValues():
my_applied_rule.expand()
my_applied_rule.expand(**kw)
else:
portal_rules = getToolByName(self, 'portal_rules')
# Parse each applied rule and test if it applied
......
......@@ -166,7 +166,7 @@ An ERP5 Rule..."""
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule):
def expand(self, applied_rule, **kw):
"""
Expands the current movement downward.
......@@ -289,7 +289,7 @@ An ERP5 Rule..."""
applied_rule._delObject(movement.getId()) # XXXX Make sur this is not deleted if already in delivery
# Pass to base class
Rule.expand(self, applied_rule)
Rule.expand(self, applied_rule, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'solve')
def solve(self, applied_rule, solution_list):
......
......@@ -153,7 +153,7 @@ An ERP5 Rule..."""
"""
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule):
def expand(self, applied_rule, **kw):
"""
Expands the current movement downward.
......@@ -219,7 +219,7 @@ An ERP5 Rule..."""
my_context_movement.getVariationCategoryList())
# Create one submovement which sources the transformation
Rule.expand(self, applied_rule)
Rule.expand(self, applied_rule, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'solve')
def solve(self, applied_rule, solution_list):
......
......@@ -123,7 +123,7 @@ An ERP5 Rule..."""
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule):
def expand(self, applied_rule, **kw):
"""
An applied rule can be expanded only if its parent movement
is expanded.
......
......@@ -505,10 +505,12 @@ class SimulationTool (Folder, UniqueObject):
if movement_group is not None:
for order_group in movement_group.group_list:
# Order should never be None
LOG("buildDeliveryList", 0, str(order_group.__dict__))
if order_group.order is not None:
order = self.portal_categories.resolveCategory(order_group.order)
if order is not None:
# define some variables
LOG("order", 0, str(order.__dict__))
if order.getPortalType() == 'Purchase Order' :
delivery_module = order.getPortalObject().livraison_achat
delivery_type = 'Purchase Packing List'
......@@ -519,139 +521,151 @@ class SimulationTool (Folder, UniqueObject):
delivery_type = 'Sales Packing List'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
else:
#LOG("ERP5 Simulation", 100, "None order makes no sense")
else : # should never be none
LOG("order is None", 0, str(order.__dict__))
return delivery_list
else: # order is None
order = None
# possible when we build deliveries for tranfer of property
delivery_module = self.getPortalObject().livraison_vente
delivery_type = 'Sales Packing List'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
for path_group in order_group.group_list :
# we create a new delivery for each DateGroup
# if path is internal ???
# JPS NEW
if path_group.source is None or path_group.destination is None:
# Production Path
LOG("Builder",0, "Strange Path %s " % path_group.source)
LOG("Builder",0, "Strange Path %s " % path_group.destination)
if path_group.source is None or path_group.destination is None:
delivery_module = self.rapport_fabrication
delivery_type = 'Production Report'
delivery_line_type = 'Production Report Line'
delivery_cell_type = 'Production Report Cell'
elif path_group.destination.find('site/Stock_PF') >= 0 and \
path_group.source.find('site/Piquage') >= 0:
delivery_module = self.livraison_fabrication
delivery_type = 'Production Packing List'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
elif path_group.source.find('site/Stock_MP') >= 0 and \
path_group.destination.find('site/Piquage') >= 0:
delivery_module = self.livraison_fabrication
delivery_type = 'Production Packing List'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
for date_group in path_group.group_list :
# Create a new packing list
new_delivery_id = str(delivery_module.generateNewId())
self.portal_types.constructContent(type_name = delivery_type,
container = delivery_module,
id = new_delivery_id,
target_start_date = date_group.start_date,
target_stop_date = date_group.stop_date,
start_date = date_group.start_date,
stop_date = date_group.stop_date,
source = path_group.source,
destination = path_group.destination,
source_section = path_group.source_section,
destination_section = path_group.destination_section
)
delivery = delivery_module[new_delivery_id]
if order is not None :
delivery.edit(title = order.getTitle(),
causality_value = order,
incoterm = order.getIncoterm(),
delivery_mode = order.getDeliveryMode()
)
# the new delivery is added to the delivery_list
delivery_list.append(delivery)
# LOG('Livraison cre',0,str(delivery.getId()))
# Create each delivery_line in the new delivery
for resource_group in date_group.group_list :
if delivery_type == 'Production Report':
if resource_group.resource.find('operation') == 0:
delivery_line_type = 'Production Report Operation'
else:
delivery_line_type = 'Production Report Component'
new_delivery_line_id = str(delivery.generateNewId())
self.portal_types.constructContent(type_name = delivery_line_type,
container = delivery,
id = new_delivery_line_id,
resource = resource_group.resource,
)
delivery_line = delivery[new_delivery_line_id]
#LOG('Ligne cre',0,str(delivery_line.getId())+' '+str(delivery_line.getResource()))
line_variation_category_list = []
line_variation_base_category_dict = {}
# compute line_variation_base_category_list and
# line_variation_category_list for new delivery_line
for variant_group in resource_group.group_list :
for variation_item in variant_group.category_list :
if not variation_item in line_variation_category_list :
line_variation_category_list.append(variation_item)
variation_base_category_items = variation_item.split('/')
if len(variation_base_category_items) > 0 :
line_variation_base_category_dict[variation_base_category_items[0]] = 1
# update variation_base_category_list and line_variation_category_list for delivery_line
line_variation_base_category_list = line_variation_base_category_dict.keys()
delivery_line._setVariationBaseCategoryList(line_variation_base_category_list)
delivery_line.setVariationCategoryList(line_variation_category_list)
# IMPORTANT : delivery cells are automatically created during setVariationCategoryList
# update target_quantity for each delivery_cell
for variant_group in resource_group.group_list :
#LOG('Variant_group examin?,0,str(variant_group.category_list))
object_to_update = None
# if there is no variation of the resource, update delivery_line with quantities and price
if len(variant_group.category_list) == 0 :
object_to_update = delivery_line
# else find which delivery_cell is represented by variant_group
else :
categories_identity = 0
#LOG('Before Check cell',0,str(delivery_cell_type))
#LOG('Before Check cell',0,str(delivery_line.contentValues()))
for delivery_cell in delivery_line.contentValues(
filter={'portal_type':delivery_cell_type}) :
#LOG('Check cell',0,str(delivery_cell))
if len(variant_group.category_list) == len(delivery_cell.getVariationCategoryList()) :
#LOG('Parse category',0,str(delivery_cell.getVariationCategoryList()))
for category in delivery_cell.getVariationCategoryList() :
if not category in variant_group.category_list :
#LOG('Not found category',0,str(category))
break
else :
categories_identity = 1
if categories_identity :
object_to_update = delivery_cell
break
for path_group in order_group.group_list :
# we create a new delivery for each DateGroup
# if path is internal ???
# JPS NEW
if path_group.source is None or path_group.destination is None:
# Production Path
#LOG("Builder",0, "Strange Path %s " % path_group.source)
#LOG("Builder",0, "Strange Path %s " % path_group.destination)
delivery_module = self.rapport_fabrication
delivery_type = 'Production Report'
delivery_line_type = 'Production Report Line'
delivery_cell_type = 'Production Report Cell'
elif path_group.destination.find('site/Stock_PF') >= 0 and \
path_group.source.find('site/Piquage') >= 0:
delivery_module = self.livraison_fabrication
delivery_type = 'Production Packing List'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
elif path_group.source.find('site/Stock_MP') >= 0 and \
path_group.destination.find('site/Piquage') >= 0:
delivery_module = self.livraison_fabrication
delivery_type = 'Production Packing List'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
for date_group in path_group.group_list :
# Create a new packing list
new_delivery_id = str(delivery_module.generateNewId())
self.portal_types.constructContent(type_name = delivery_type,
container = delivery_module,
id = new_delivery_id,
title = order.getTitle(),
causality_value = order,
incoterm = order.getIncoterm(),
delivery_mode = order.getDeliveryMode(),
target_start_date = date_group.start_date,
target_stop_date = date_group.stop_date,
start_date = date_group.start_date,
stop_date = date_group.stop_date,
source = path_group.source,
destination = path_group.destination,
source_section = path_group.source_section,
destination_section = path_group.destination_section
)
delivery = delivery_module[new_delivery_id]
# the new delivery is added to the delivery_list
delivery_list.append(delivery)
# LOG('Livraison cre',0,str(delivery.getId()))
# Create each delivery_line in the new delivery
for resource_group in date_group.group_list :
if delivery_type == 'Production Report':
if resource_group.resource.find('operation') == 0:
delivery_line_type = 'Production Report Operation'
else:
delivery_line_type = 'Production Report Component'
new_delivery_line_id = str(delivery.generateNewId())
self.portal_types.constructContent(type_name = delivery_line_type,
container = delivery,
id = new_delivery_line_id,
resource = resource_group.resource,
)
delivery_line = delivery[new_delivery_line_id]
#LOG('Ligne cre',0,str(delivery_line.getId())+' '+str(delivery_line.getResource()))
line_variation_category_list = []
line_variation_base_category_dict = {}
# compute line_variation_base_category_list and
# line_variation_category_list for new delivery_line
for variant_group in resource_group.group_list :
for variation_item in variant_group.category_list :
if not variation_item in line_variation_category_list :
line_variation_category_list.append(variation_item)
variation_base_category_items = variation_item.split('/')
if len(variation_base_category_items) > 0 :
line_variation_base_category_dict[variation_base_category_items[0]] = 1
# update variation_base_category_list and line_variation_category_list for delivery_line
line_variation_base_category_list = line_variation_base_category_dict.keys()
delivery_line._setVariationBaseCategoryList(line_variation_base_category_list)
delivery_line.setVariationCategoryList(line_variation_category_list)
# IMPORTANT : delivery cells are automatically created during setVariationCategoryList
# update target_quantity for each delivery_cell
for variant_group in resource_group.group_list :
#LOG('Variant_group examin',0,str(variant_group.category_list))
object_to_update = None
# if there is no variation of the resource, update delivery_line with quantities and price
if len(variant_group.category_list) == 0 :
object_to_update = delivery_line
# else find which delivery_cell is represented by variant_group
else :
categories_identity = 0
#LOG('Before Check cell',0,str(delivery_cell_type))
#LOG('Before Check cell',0,str(delivery_line.contentValues()))
for delivery_cell in delivery_line.contentValues(
filter={'portal_type':delivery_cell_type}) :
#LOG('Check cell',0,str(delivery_cell))
if len(variant_group.category_list) == len(delivery_cell.getVariationCategoryList()) :
#LOG('Parse category',0,str(delivery_cell.getVariationCategoryList()))
for category in delivery_cell.getVariationCategoryList() :
if not category in variant_group.category_list :
#LOG('Not found category',0,str(category))
break
else :
categories_identity = 1
if categories_identity :
object_to_update = delivery_cell
break
# compute target_quantity, quantity and price for delivery_cell or delivery_line and
# build relation between simulation_movement and delivery_cell or delivery_line
if object_to_update is not None :
cell_target_quantity = 0
cell_total_price = 0
for movement in variant_group.movement_list :
cell_target_quantity += movement.getNetConvertedTargetQuantity()
try:
cell_total_price += movement.getNetConvertedTargetQuantity()*movement.getPrice() # XXX WARNING - ADD PRICED QUANTITY
except:
cell_total_price = None
# compute target_quantity, quantity and price for delivery_cell or delivery_line and
# build relation between simulation_movement and delivery_cell or delivery_line
if object_to_update is not None :
cell_target_quantity = 0
cell_total_price = 0
for movement in variant_group.movement_list :
cell_target_quantity += movement.getNetConvertedTargetQuantity()
try:
cell_total_price += movement.getNetConvertedTargetQuantity()*movement.getPrice() # XXX WARNING - ADD PRICED QUANTITY
except:
cell_total_price = None
if movement.getPortalType() == 'Simulation Movement' :
# update every simulation_movement
# we set delivery_value and target dates and quantity
movement._setDeliveryValue(object_to_update)
......@@ -665,16 +679,16 @@ class SimulationTool (Folder, UniqueObject):
# We will reindex later
reindexable_movement_list.append(movement)
if cell_target_quantity <> 0 and cell_total_price is not None:
average_price = cell_total_price/cell_target_quantity
else :
average_price = 0
#LOG('object mis ?jour',0,str(object_to_update.getRelativeUrl()))
object_to_update._edit(target_quantity = cell_target_quantity,
quantity = cell_target_quantity,
price = average_price,
force_update = 1,
)
if cell_target_quantity <> 0 and cell_total_price is not None:
average_price = cell_total_price/cell_target_quantity
else :
average_price = 0
#LOG('object mis ?jour',0,str(object_to_update.getRelativeUrl()))
object_to_update._edit(target_quantity = cell_target_quantity,
quantity = cell_target_quantity,
price = average_price,
force_update = 1,
)
# If we reach this point, it means we could
# create deliveries
......
......@@ -495,6 +495,7 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana
security.declareProtected( Permissions.ModifyPortalContent, 'edit' )
def edit(self, REQUEST=None, force_update = 0, reindex_object=1, **kw):
return self._edit(REQUEST=REQUEST, force_update=force_update, reindex_object=reindex_object, **kw)
edit = WorkflowMethod( edit )
# Accessing object property Ids
......
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