Commit d838b301 authored by Romain Courteaud's avatar Romain Courteaud

InvoiceRule and DeliveryRule seems to be identical.

Keep it for compatibility only.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3719 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e7fe0313
......@@ -36,9 +36,8 @@ from zLOG import LOG
class InvoiceRule(DeliveryRule):
"""
Invoice Rule object make sure an Invoice in the simulation
is consistent with the real invoice
WARNING: what to do with movement split ?
InvoiceRule and DeliveryRule seems to be identical.
Keep it for compatibility only.
"""
# CMF Type Definition
......@@ -61,75 +60,11 @@ class InvoiceRule(DeliveryRule):
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, **kw):
def expand(self, applied_rule,
movement_type_method='getPortalInvoiceMovementTypeList', **kw):
"""
Expands the current movement downward.
-> new status -> expanded
An applied rule can be expanded only if its parent movement
is expanded.
Call expand defined on DeliveryRule.
"""
invoice_line_type = 'Simulation Movement'
# Get the invoice where we come from
my_invoice = applied_rule.getDefaultCausalityValue()
# Only expand if my_invoice is not None and
# state is not 'confirmed'
if my_invoice is not None:
# First, check each contained movement and make
# a list of invoice_line ids which do not need to be copied
# eventually delete movement which do not exist anylonger
existing_uid_list = []
movement_type_list = applied_rule.getPortalMovementTypeList()
# non generic
invoice_movement_type_list = \
applied_rule.getPortalInvoiceMovementTypeList()
for movement in applied_rule.contentValues(
filter={'portal_type':movement_type_list}):
invoice_element = movement.getDeliveryValue(
portal_type=invoice_movement_type_list)
if (invoice_element is None) or\
(invoice_element.hasCellContent()) or\
(len(invoice_element.getDeliveryRelatedValueList()) > 1):
# Our invoice_element is already related
# to another simulation movement
# Delete ourselve
# movement.flushActivity(invoke=0)
# XXX Make sure this is not deleted if already in delivery
applied_rule._delObject(movement.getId())
else:
existing_uid_list_append(invoice_element.getUid())
# Copy each movement (line or cell) from the invoice
# non generic
for invoice_line_object in my_delivery.getMovementList(
portal_type=self.getPortalInvoiceMovementTypeList()):
try:
# Only create if orphaned movement
if invoice_line_object.getUid() not in existing_uid_list:
# Generate a nicer ID
if invoice_line_object.getParentUid() ==\
invoice_line_object.getExplanationUid():
# We are on a line
new_id = invoice_line_object.getId()
else:
# On a cell
new_id = "%s_%s" % (invoice_line_object.getParentId(),
invoice_line_object.getId())
# Generate the simulation movement
new_sim_mvt = applied_rule.newContent(
portal_type=invoice_line_type,
id=new_id,
order_value=invoice_line_object,
delivery_value=invoice_line_object,
# XXX Do we need to copy the quantity
# Why not the resource, the variation,...
quantity=invoice_line_object.getQuantity(),
delivery_ratio=1,
deliverable=1)
except AttributeError:
LOG('ERP5: WARNING', 0,
'AttributeError during expand on invoice line %s' \
% invoice_line_object.absolute_url())
# Pass to base class
Rule.expand(self, applied_rule, **kw)
DeliveryRule.expand(self, applied_rule,
movement_type_method=movement_type_method,
**kw)
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