Do not crash when calling store_cache and correctly call it
The store_cache method must be called on transition for which the states should be cached. issue6981 review36871002
This commit is contained in:
1 parent
01d8b74b13
commit
c957ce16b4
2 files changed
+9
-7
No files matched your search
+6
-6
@@ -260,12 +260,9 @@ class PurchaseRequisition(Workflow, ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def store_cache(cls, requisitions):
|
||||
to_write = []
|
||||
for requisition in requisitions:
|
||||
to_write.extend([requisition], {
|
||||
'total_amount_cache': requisition.total_amount,
|
||||
})
|
||||
cls.write(*to_write)
|
||||
requisition.total_amount_cache = requisition.total_amount
|
||||
cls.save(requisitions)
|
||||
|
||||
@classmethod
|
||||
def get_amount(cls, requisitions, name):
|
||||
@@ -330,7 +327,7 @@ class PurchaseRequisition(Workflow, ModelSQL, ModelView):
|
||||
@ModelView.button
|
||||
@Workflow.transition('cancel')
|
||||
def cancel(cls, requisitions):
|
||||
pass
|
||||
cls.store_cache(requisitions)
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@@ -365,6 +362,9 @@ class PurchaseRequisition(Workflow, ModelSQL, ModelView):
|
||||
new_requests.append(request)
|
||||
if new_requests:
|
||||
Request.save(new_requests)
|
||||
|
||||
cls.store_cache(requisitions)
|
||||
|
||||
# Update the state to allow transition to processing
|
||||
cls.write(requisitions, {
|
||||
'state': 'approved',
|
||||
|
||||
@@ -120,7 +120,7 @@ Create purchase requisition without product and description::
|
||||
>>> requisition_line.product = None
|
||||
>>> requisition_line.description = None
|
||||
>>> requisition_line.supplier = supplier
|
||||
>>> requisition_line.price = 10.0
|
||||
>>> requisition_line.unit_price = Decimal('10')
|
||||
>>> requisition.click('wait') # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
@@ -178,6 +178,8 @@ Approve workflow with user in approval_group::
|
||||
>>> requisition.click('approve')
|
||||
>>> requisition.state
|
||||
u'processing'
|
||||
>>> requisition.total_amount
|
||||
Decimal('20.00')
|
||||
|
||||
Create Purchase order from Request::
|
||||
|
||||
|
||||
Reference in new issue
Block a user