diff --git a/modules/purchase_request_quotation/CHANGELOG b/modules/purchase_request_quotation/CHANGELOG index 707672c988..fe0ee0e7ee 100644 --- a/modules/purchase_request_quotation/CHANGELOG +++ b/modules/purchase_request_quotation/CHANGELOG @@ -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 --git a/modules/purchase_request_quotation/exceptions.py b/modules/purchase_request_quotation/exceptions.py index dd8d642abf..cd91abdef6 100644 --- a/modules/purchase_request_quotation/exceptions.py +++ b/modules/purchase_request_quotation/exceptions.py @@ -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 --git a/modules/purchase_request_quotation/message.xml b/modules/purchase_request_quotation/message.xml index 2ecbb9dd9a..b399c1ad4d 100644 --- a/modules/purchase_request_quotation/message.xml +++ b/modules/purchase_request_quotation/message.xml @@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. --> - A quotation was already made for request "%(request)s". + Quotations have already been made for the requests "%(requests)s". diff --git a/modules/purchase_request_quotation/purchase.py b/modules/purchase_request_quotation/purchase.py index dc505b72b4..1f2d26cddd 100644 --- a/modules/purchase_request_quotation/purchase.py +++ b/modules/purchase_request_quotation/purchase.py @@ -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)]