Open purchase requests for quotations created from wizard
Closes #12927
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Open requests for quotations created from wizard
|
||||
|
||||
Version 7.6.0 - 2025-04-28
|
||||
--------------------------
|
||||
|
||||
@@ -17,7 +17,8 @@ from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Bool, Eval, Id, If
|
||||
from trytond.tools import sortable_values
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Button, StateTransition, StateView, Wizard
|
||||
from trytond.wizard import (
|
||||
Button, StateAction, StateTransition, StateView, Wizard)
|
||||
|
||||
from .exceptions import PreviousQuotation
|
||||
|
||||
@@ -478,13 +479,8 @@ class CreatePurchaseRequestQuotation(Wizard):
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Process', 'create_quotations', 'tryton-ok', default=True),
|
||||
])
|
||||
create_quotations = StateTransition()
|
||||
succeed = StateView(
|
||||
'purchase.request.quotation.create.succeed',
|
||||
'purchase_request_quotation.'
|
||||
'purchase_request_quotation_create_succeed', [
|
||||
Button('Close', 'end', 'tryton-close', True),
|
||||
])
|
||||
create_quotations = StateAction(
|
||||
'purchase_request_quotation.act_purchase_request_quotation_form')
|
||||
|
||||
def transition_start(self):
|
||||
pool = Pool()
|
||||
@@ -521,7 +517,7 @@ class CreatePurchaseRequestQuotation(Wizard):
|
||||
def _group_request_key(self, request):
|
||||
return (('company', request.company),)
|
||||
|
||||
def transition_create_quotations(self):
|
||||
def do_create_quotations(self, action):
|
||||
pool = Pool()
|
||||
Quotation = pool.get('purchase.request.quotation')
|
||||
QuotationLine = pool.get('purchase.request.quotation.line')
|
||||
@@ -547,8 +543,12 @@ class CreatePurchaseRequestQuotation(Wizard):
|
||||
QuotationLine.save(lines)
|
||||
|
||||
self.model.update_state(requests)
|
||||
self.succeed.number_quotations = len(quotations)
|
||||
return 'succeed'
|
||||
action['domain'] = []
|
||||
if len(quotations) == 1:
|
||||
action['views'].reverse()
|
||||
return action, {
|
||||
'res_id': list(map(int, quotations))
|
||||
}
|
||||
|
||||
def get_quotation(self, supplier, key):
|
||||
pool = Pool()
|
||||
|
||||
@@ -90,12 +90,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">reject</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view"
|
||||
id="purchase_request_quotation_create_succeed">
|
||||
<field name="model">purchase.request.quotation.create.succeed</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">purchase_request_quotation_create_succeed_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view"
|
||||
id="purchase_request_quotation_create_ask_suppliers">
|
||||
<field name="model">purchase.request.quotation.create.ask_suppliers</field>
|
||||
|
||||
@@ -108,24 +108,20 @@ add another supplier::
|
||||
>>> assertEqual(create_quotation.form.suppliers, [supplier])
|
||||
>>> create_quotation.form.suppliers.append(Party(supplier2.id))
|
||||
>>> create_quotation.execute('create_quotations')
|
||||
>>> create_quotation.execute('end')
|
||||
>>> quotations = create_quotation.actions[0]
|
||||
>>> len(quotations)
|
||||
2
|
||||
>>> purchase_request.state
|
||||
'quotation'
|
||||
|
||||
Check Quotation Lines (1 Request with 2 Suppliers = 2 Quotation Lines)::
|
||||
|
||||
>>> QuotationLine = Model.get('purchase.request.quotation.line')
|
||||
>>> quotation_lines = QuotationLine.find(
|
||||
... [('quotation_state', '=', 'draft')])
|
||||
>>> len(quotation_lines)
|
||||
2
|
||||
>>> len(quotations[0].lines), len(quotations[1].lines)
|
||||
(1, 1)
|
||||
|
||||
Send Quotations::
|
||||
|
||||
>>> Quotation = Model.get('purchase.request.quotation')
|
||||
>>> quotations = Quotation.find([('state', '=', 'draft')])
|
||||
>>> len(quotations)
|
||||
2
|
||||
>>> for quotation in quotations:
|
||||
... quotation.click('send')
|
||||
>>> quotations = Quotation.find([('state', '=', 'sent')])
|
||||
|
||||
@@ -21,7 +21,6 @@ model:
|
||||
purchase.Quotation
|
||||
purchase.QuotationLine
|
||||
purchase.CreatePurchaseRequestQuotationAskSuppliers
|
||||
purchase.CreatePurchaseRequestQuotationSucceed
|
||||
purchase.PurchaseRequest
|
||||
wizard:
|
||||
purchase.CreatePurchaseRequestQuotation
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form >
|
||||
<image name="tryton-info" xexpand="0" xfill="0"/>
|
||||
<label name="number_quotations"/>
|
||||
<field name="number_quotations"/>
|
||||
</form>
|
||||
Reference in New Issue
Block a user