Open purchases created from purchase requests

Closes #12796
This commit is contained in:
Cédric Krier
2023-12-02 23:42:08 +01:00
parent 80fac3b031
commit 545e10465f
3 changed files with 16 additions and 10 deletions
+1
View File
@@ -1,3 +1,4 @@
Open purchases created from requests
Version 7.0.0 - 2023-10-30
--------------------------
+12 -2
View File
@@ -15,7 +15,8 @@ from trytond.pool import Pool
from trytond.pyson import Bool, Eval, If
from trytond.tools import firstline, sortable_values
from trytond.transaction import Transaction
from trytond.wizard import Button, StateTransition, StateView, Wizard
from trytond.wizard import (
Button, StateAction, StateTransition, StateView, Wizard)
STATES = {
'readonly': Eval('state') != 'draft',
@@ -359,6 +360,7 @@ class CreatePurchase(Wizard):
Button('Cancel', 'end', 'tryton-cancel'),
Button('Continue', 'start', 'tryton-forward', default=True),
])
open_ = StateAction('purchase.act_purchase_form')
def default_ask_party(self, fields):
for request in self.records:
@@ -475,7 +477,7 @@ class CreatePurchase(Wizard):
Purchase.save(purchases)
Line.save(lines)
Request.set_purchased(requests)
return 'end'
return 'open_'
@classmethod
def compute_purchase_line(cls, key, requests, purchase):
@@ -508,6 +510,14 @@ class CreatePurchase(Wizard):
compute_qty(r.unit, r.quantity, unit, round=False)
for r in requests)
def do_open_(self, action):
purchase_ids = list({
r.purchase.id for r in self.records if r.purchase})
action['domains'] = []
return action, {
'res_id': purchase_ids,
}
def end(self):
return 'reload'
@@ -170,9 +170,7 @@ Create the purchase then cancel it::
>>> create_purchase.execute('start')
>>> pr.state
'purchased'
>>> Purchase = Model.get('purchase.purchase')
>>> purchase, = Purchase.find()
>>> (purchase,), = create_purchase.actions
>>> purchase.click('cancel')
>>> pr.reload()
>>> pr.state
@@ -192,8 +190,7 @@ Recreate a purchase and cancel it again::
... [pr])
>>> pr.state
'purchased'
>>> purchase, = Purchase.find([('state', '=', 'draft')])
>>> (purchase,), = create_purchase.actions
>>> purchase.click('cancel')
>>> pr.reload()
>>> pr.state
@@ -240,9 +237,7 @@ Create the purchase with a unique line::
>>> create_purchase.execute('start')
>>> pr.state
'purchased'
>>> Purchase = Model.get('purchase.purchase')
>>> purchase, = Purchase.find([('state', '=', 'draft')])
>>> (purchase,), = create_purchase.actions
>>> len(purchase.lines)
1
>>> line, = purchase.lines