diff --git a/modules/purchase_request_quotation/CHANGELOG b/modules/purchase_request_quotation/CHANGELOG index fe0ee0e7ee..0fe126e21b 100644 --- a/modules/purchase_request_quotation/CHANGELOG +++ b/modules/purchase_request_quotation/CHANGELOG @@ -1,3 +1,4 @@ +* Prevent running create quotation wizard from request in not allowed state * Allow creating quotation from request in received state * Open requests for quotations created from wizard diff --git a/modules/purchase_request_quotation/purchase.py b/modules/purchase_request_quotation/purchase.py index 1f2d26cddd..b200975e37 100644 --- a/modules/purchase_request_quotation/purchase.py +++ b/modules/purchase_request_quotation/purchase.py @@ -627,6 +627,13 @@ class PurchaseRequest(metaclass=PoolMeta): for s in selection: if s not in cls.state.selection: cls.state.selection.append(s) + cls._buttons.update({ + 'create_quotation': { + 'invisible': Eval('state').in_( + ['draft', 'quotation', 'received']), + 'depends': ['state'], + }, + }) def get_state(self): state = super().get_state() @@ -637,6 +644,12 @@ class PurchaseRequest(metaclass=PoolMeta): state = 'received' return state + @classmethod + @ModelView.button_action( + 'purchase_request_quotation.wizard_create_quotation') + def create_quotation(cls, requests): + pass + class CreatePurchase(Wizard): __name__ = 'purchase.request.create_purchase' diff --git a/modules/purchase_request_quotation/purchase.xml b/modules/purchase_request_quotation/purchase.xml index df39ab78f8..aeb47efa35 100644 --- a/modules/purchase_request_quotation/purchase.xml +++ b/modules/purchase_request_quotation/purchase.xml @@ -100,11 +100,6 @@ this repository contains the full copyright notices and license terms. --> Create Quotation purchase.request.quotation.create - - form_action - purchase.request,-1 - - @@ -176,6 +171,18 @@ this repository contains the full copyright notices and license terms. --> purchase_request_form + + purchase.request + + purchase_request_list + + + + purchase.request + create_quotation + Create Quotations + + purchase.configuration diff --git a/modules/purchase_request_quotation/tests/scenario_purchase_request_quotation.rst b/modules/purchase_request_quotation/tests/scenario_purchase_request_quotation.rst index 2ee3b102e3..4e0c411f11 100644 --- a/modules/purchase_request_quotation/tests/scenario_purchase_request_quotation.rst +++ b/modules/purchase_request_quotation/tests/scenario_purchase_request_quotation.rst @@ -7,7 +7,7 @@ Imports:: >>> import datetime as dt >>> from decimal import Decimal - >>> from proteus import Model, Report, Wizard + >>> from proteus import Model, Report >>> from trytond.modules.account.tests.tools import create_chart, get_accounts >>> from trytond.modules.company.tests.tools import create_company >>> from trytond.tests.tools import activate_modules, assertEqual, set_user @@ -103,8 +103,7 @@ add another supplier:: >>> purchase_request, = PurchaseRequest.find([('state', '=', 'draft')]) >>> purchase_request.state 'draft' - >>> create_quotation = Wizard( - ... 'purchase.request.quotation.create', [purchase_request]) + >>> create_quotation = purchase_request.click('create_quotation') >>> assertEqual(create_quotation.form.suppliers, [supplier]) >>> create_quotation.form.suppliers.append(Party(supplier2.id)) >>> create_quotation.execute('create_quotations') @@ -173,7 +172,7 @@ with a quotation not having the minimum price unit:: Create Purchase Order from Purchase Request and check if supplier with best price from quotations was selected (supplier2 price):: - >>> create_purchase = Wizard('purchase.request.create_purchase', [prequest]) + >>> create_purchase = prequest.click('create_purchase') >>> prequest.state 'purchased' >>> Purchase = Model.get('purchase.purchase') @@ -187,8 +186,7 @@ best price from quotations was selected (supplier2 price):: Create Purchase Order from Purchase Request having a preferred_quotation_line and check if supplier from this quotation was selected:: - >>> create_purchase = Wizard('purchase.request.create_purchase', - ... [prequest2]) + >>> create_purchase = prequest2.click('create_purchase') >>> prequest2.state 'purchased' >>> Purchase = Model.get('purchase.purchase') diff --git a/modules/purchase_request_quotation/view/purchase_request_list.xml b/modules/purchase_request_quotation/view/purchase_request_list.xml new file mode 100644 index 0000000000..f99e528d7c --- /dev/null +++ b/modules/purchase_request_quotation/view/purchase_request_list.xml @@ -0,0 +1,8 @@ + + + + +