Fix required computation when line has no purchase
issue7281 review41221002
This commit is contained in:
+4
-3
@@ -91,9 +91,10 @@ class AnalyticAccountEntry:
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
required = super(AnalyticAccountEntry, self).on_change_with_required(
|
||||
name)
|
||||
if (self.origin and isinstance(self.origin, PurchaseLine)
|
||||
and self.origin.purchase.state in ['cancel', 'draft']):
|
||||
return False
|
||||
if isinstance(self.origin, PurchaseLine):
|
||||
if (not self.origin.purchase
|
||||
or self.origin.purchase.state in ['cancel', 'draft']):
|
||||
return False
|
||||
return required
|
||||
|
||||
@fields.depends('origin')
|
||||
|
||||
@@ -112,11 +112,16 @@ Purchase with analytic accounts::
|
||||
>>> mandatory_entry.root == mandatory_root
|
||||
True
|
||||
>>> bool(mandatory_entry.required)
|
||||
True
|
||||
False
|
||||
>>> purchase_line.product = product
|
||||
>>> purchase_line.quantity = 5
|
||||
>>> mandatory_entry.account = mandatory_analytic_account
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase_line, = purchase.lines
|
||||
>>> mandatory_entry, = [a for a in purchase_line.analytic_accounts
|
||||
... if a.root == mandatory_root]
|
||||
>>> bool(mandatory_entry.required)
|
||||
True
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.click('process')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user