Allow creating quotation from purchase request in received state

Closes #12630
This commit is contained in:
Sergio Hervás
2024-03-17 12:27:03 +01:00
parent d4c6400c26
commit f6ad52aebc
4 changed files with 26 additions and 12 deletions
@@ -1,3 +1,4 @@
* Allow creating quotation from request in received state
* Open requests for quotations created from wizard
Version 7.6.0 - 2025-04-28
@@ -1,8 +1,12 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.exceptions import UserWarning
from trytond.exceptions import UserError, UserWarning
class PreviousQuotation(UserWarning):
pass
class RequestStateCreateQuotationError(UserError):
pass
@@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<tryton>
<data grouped="1">
<record model="ir.message" id="msg_previous_quotation">
<field name="text">A quotation was already made for request "%(request)s".</field>
<field name="text">Quotations have already been made for the requests "%(requests)s".</field>
</record>
</data>
</tryton>
+19 -10
View File
@@ -486,22 +486,30 @@ class CreatePurchaseRequestQuotation(Wizard):
pool = Pool()
Warning = pool.get('res.user.warning')
reqs = [r for r in self.records if r.state in {'draft', 'quotation'}]
reqs = [
r for r in self.records
if r.state in {'draft', 'quotation', 'received'}]
if reqs:
for r in reqs:
if r.state == 'quotation':
if Warning.check(str(r)):
raise PreviousQuotation(str(r),
gettext('purchase_request_quotation'
'.msg_previous_quotation',
request=r.rec_name))
reqs = [r for r in reqs if r.state in {'quotation', 'received'}]
if reqs:
warning_key = Warning.format(
'purchase_request_quotation_create', reqs)
if Warning.check(warning_key):
names = ', '.join(r.rec_name for r in reqs[:5])
if len(reqs) > 5:
names += '...'
raise PreviousQuotation(
warning_key,
gettext('purchase_request_quotation'
'.msg_previous_quotation',
requests=names))
return 'ask_suppliers'
return 'end'
def default_ask_suppliers(self, fields):
reqs = [
r for r in self.records
if r.party and r.state in ['draft', 'quotation']]
if r.party and r.state in {'draft', 'quotation', 'received'}]
return {
'suppliers': [r.party.id for r in reqs],
}
@@ -525,7 +533,8 @@ class CreatePurchaseRequestQuotation(Wizard):
lines = []
requests = [
r for r in self.records if r.state in ['draft', 'quotation']]
r for r in self.records
if r.state in {'draft', 'quotation', 'received'}]
for supplier in self.ask_suppliers.suppliers:
sub_requests = [
r for r in requests if self.filter_request(r, supplier)]