details: https://code.tryton.org/tryton/commit/067b9d88952e
branch: default
user: Sergio Hervás <[email protected]>
date: Sun Mar 17 12:27:03 2024 +0100
description:
Allow creating quotation from purchase request in received state
Closes #12630
diffstat:
modules/purchase_request_quotation/CHANGELOG | 1 +
modules/purchase_request_quotation/exceptions.py | 6 ++++-
modules/purchase_request_quotation/message.xml | 2 +-
modules/purchase_request_quotation/purchase.py | 29 +++++++++++++++--------
4 files changed, 26 insertions(+), 12 deletions(-)
diffs (90 lines):
diff -r 50b48640375f -r 067b9d88952e
modules/purchase_request_quotation/CHANGELOG
--- a/modules/purchase_request_quotation/CHANGELOG Thu Oct 30 01:14:10
2025 +0100
+++ b/modules/purchase_request_quotation/CHANGELOG Sun Mar 17 12:27:03
2024 +0100
@@ -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
diff -r 50b48640375f -r 067b9d88952e
modules/purchase_request_quotation/exceptions.py
--- a/modules/purchase_request_quotation/exceptions.py Thu Oct 30 01:14:10
2025 +0100
+++ b/modules/purchase_request_quotation/exceptions.py Sun Mar 17 12:27:03
2024 +0100
@@ -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
diff -r 50b48640375f -r 067b9d88952e
modules/purchase_request_quotation/message.xml
--- a/modules/purchase_request_quotation/message.xml Thu Oct 30 01:14:10
2025 +0100
+++ b/modules/purchase_request_quotation/message.xml Sun Mar 17 12:27:03
2024 +0100
@@ -4,7 +4,7 @@
<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>
diff -r 50b48640375f -r 067b9d88952e
modules/purchase_request_quotation/purchase.py
--- a/modules/purchase_request_quotation/purchase.py Thu Oct 30 01:14:10
2025 +0100
+++ b/modules/purchase_request_quotation/purchase.py Sun Mar 17 12:27:03
2024 +0100
@@ -486,22 +486,30 @@
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 @@
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)]