Commit 6f8f47d5 authored by Romain Courteaud's avatar Romain Courteaud

Copy the variation category list for the previous simulation movement.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3711 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 950046bc
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2005 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -37,8 +38,7 @@ from zLOG import LOG ...@@ -37,8 +38,7 @@ from zLOG import LOG
class InvoicingRule(Rule): class InvoicingRule(Rule):
""" """
Transformation Sourcing Rule object make sure Invoicing Rule expand simulation created by a order rule.
items required in a Transformation are sourced
""" """
# CMF Type Definition # CMF Type Definition
...@@ -65,64 +65,57 @@ class InvoicingRule(Rule): ...@@ -65,64 +65,57 @@ class InvoicingRule(Rule):
Tests if the rule (still) applies Tests if the rule (still) applies
""" """
parent = movement.getParent() parent = movement.getParent()
if parent.getPortalType()=='Applied Rule' and parent.getSpecialiseId()=='default_order_rule': result = 0
return 1 if (parent.getPortalType() == 'Applied Rule') and \
return 0 (parent.getSpecialiseId() == 'default_order_rule'):
result = 1
return result
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, **kw): def expand(self, applied_rule, **kw):
""" """
Expands the current movement downward. Expands the current movement downward.
-> new status -> expanded -> new status -> expanded
An applied rule can be expanded only if its parent movement An applied rule can be expanded only if its parent movement
is expanded. is expanded.
""" """
delivery_line_type = 'Simulation Movement' delivery_line_type = 'Simulation Movement'
# Source that movement from the next node / stock # Source that movement from the next node / stock
my_context_movement = applied_rule.getParent() my_context_movement = applied_rule.getParent()
#LOG('InvoicingRule.expand, my_context_movement.getPhysicalPath()',0,my_context_movement.getPhysicalPath())
#LOG('InvoicingRule.expand, my_context_movement.getSource()',0,my_context_movement.getSource())
#LOG('InvoicingRule.expand, my_context_movement.showDict()',0,my_context_movement.showDict())
if my_context_movement.getSource() is not None: if my_context_movement.getSource() is not None:
# We should only expand movements if they have a source # We should only expand movements if they have a source
# otherwise, it creates infinite recursion # otherwise, it creates infinite recursion
# This happens for example whenever the source of a movement is acquired # This happens for example whenever the source of a movement is
# from an order which is deleted afterwards # acquired from an order which is deleted afterwards
# LOG('Sourcing', 0, str(my_context_movement.getDefaultResource())) new_id = 'inv_mvt'
new_id = 'invoice_line'
if new_id in applied_rule.objectIds(): if new_id in applied_rule.objectIds():
invoice_line = applied_rule[new_id] invoice_line = applied_rule[new_id]
else: else:
invoice_line = applied_rule.newContent( invoice_line = applied_rule.newContent(
type_name = delivery_line_type, type_name = delivery_line_type,
id = new_id id = new_id
) )
# Edit movement
resource = my_context_movement.getResource()
invoice_line._edit( invoice_line._edit(
price = my_context_movement.getPrice(), price = my_context_movement.getPrice(),
quantity = my_context_movement.getQuantity(), quantity = my_context_movement.getQuantity(),
efficiency = my_context_movement.getEfficiency(), quantity_unit = my_context_movement.getQuantityUnit(),
resource = resource, efficiency = my_context_movement.getEfficiency(),
start_date = my_context_movement.getStartDate(), resource = my_context_movement.getresource(),
stop_date = my_context_movement.getStartDate(), variation_category_list = my_context_movement.\
source = my_context_movement.getSource(), getVariationCategoryList(),
source_section = my_context_movement.getSourceSection(), start_date = my_context_movement.getStartDate(),
quantity_unit = my_context_movement.getQuantityUnit(), stop_date = my_context_movement.getStartDate(),
destination = my_context_movement.getDestination(), source = my_context_movement.getSource(),
destination_section = my_context_movement.getDestinationSection(), source_section = my_context_movement.getSourceSection(),
deliverable = 1 # We do need to collect invoice lines to build invoices destination = my_context_movement.getDestination(),
) destination_section = my_context_movement.getDestinationSection(),
# transformation_source.setVariationCategoryList( # We do need to collect invoice lines to build invoices
# my_context_movement.getVariationCategoryList()) deliverable = 1
)
# Create one submovement which sources the transformation # Create one submovement which sources the transformation
Rule.expand(self, applied_rule, **kw) Rule.expand(self, applied_rule, **kw)
def isDeliverable(self, m): def isDeliverable(self, m):
resource = m.getResource() resource = m.getResource()
if m.getResource() is None: if m.getResource() is None:
......
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