Commit 4a47c137 authored by Jérome Perrin's avatar Jérome Perrin

get the resource (currency) from the rule for now, this can change in the future


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3712 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6f8f47d5
...@@ -130,19 +130,21 @@ class InvoiceTransactionRule(Rule, XMLMatrix): ...@@ -130,19 +130,21 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
# price_currency from the invoice # price_currency from the invoice
# price_currency from the [parent]+ simulation movement's deliveryValue # price_currency from the [parent]+ simulation movement's deliveryValue
# price_currency from the top level simulation movement's orderValue # price_currency from the top level simulation movement's orderValue
invoice_line = my_invoice_line_simulation.getDeliveryValue() # FIXME: this must be discussed. for now we get the resource
invoice = invoice_line.getExplanationValue() # from the cell
resource = None #invoice_line = my_invoice_line_simulation.getDeliveryValue()
if invoice.getResource() is not None : #invoice = invoice_line.getExplanationValue()
resource = invoice.getResource() #resource = None
elif hasattr(invoice, 'getPriceCurrency') and \ #if invoice.getResource() is not None :
invoice.getPriceCurrency() is not None : # resource = invoice.getResource()
resource = invoice.getPriceCurrency() #elif hasattr(invoice, 'getPriceCurrency') and \
# invoice.getPriceCurrency() is not None :
# resource = invoice.getPriceCurrency()
# still TODO: search resource on parents (Order, Packing List ...) # still TODO: search resource on parents (Order, Packing List ...)
if resource is None : #if resource is None :
LOG("InvoiceTransactionRule", PROBLEM, # LOG("InvoiceTransactionRule", PROBLEM,
"Unable to expand %s: no resource"%applied_rule.getPath()) # "Unable to expand %s: no resource"%applied_rule.getPath())
# Add every movement from the Matrix to the Simulation # Add every movement from the Matrix to the Simulation
for transaction_line in my_cell.objectValues() : for transaction_line in my_cell.objectValues() :
...@@ -151,6 +153,13 @@ class InvoiceTransactionRule(Rule, XMLMatrix): ...@@ -151,6 +153,13 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
else : else :
simulation_movement = applied_rule.newContent( simulation_movement = applied_rule.newContent(
portal_type=invoice_transaction_line_type) portal_type=invoice_transaction_line_type)
resource = transaction_line.getResource() or my_cell.getResource()
if resource in (None, '') :
LOG("InvoiceTransactionRule", PROBLEM,
"Unable to expand %s: no resource"%applied_rule.getPath())
raise ValueError, 'no resource for %s' % \
transaction_line.getPath()
simulation_movement._edit( simulation_movement._edit(
source = transaction_line.getSource() source = transaction_line.getSource()
, destination = transaction_line.getDestination() , destination = transaction_line.getDestination()
...@@ -166,9 +175,6 @@ class InvoiceTransactionRule(Rule, XMLMatrix): ...@@ -166,9 +175,6 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
, stop_date = my_invoice_line_simulation.getStopDate() , stop_date = my_invoice_line_simulation.getStopDate()
, force_update = 1 , force_update = 1
) )
LOG("Simulation mvt edit", 0, "q = %s"% ((my_invoice_line_simulation.getQuantity()
* my_invoice_line_simulation.getPrice())
* transaction_line.getQuantity()))
# Now we can set the last expand simulation state to the current state # Now we can set the last expand simulation state to the current state
#XXX Note : this is wrong, as there isn't always a sale invoice when we expand this rule. #XXX Note : this is wrong, as there isn't always a sale invoice when we expand this rule.
......
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