[FIX] purchase_requisition: Request Approval on exclusive requisition

Usecase to reproduce:
- Enable 'Managers must approve orders'
- Set agreement type as 'exclusive'
- Connect as purchase user
- Create a requisition and an RFQ linked to it
- Confirm the RFQ

It raises a usererror that ask to close other PO linked
to requisition.

It happens because the purchase requisition code do not take
care of double validation on PO. It will try to close the requisition
once button_confirm is called. However it will only write 'to approve'
on PO state and thus trigger the requistion error will be raise since
all linked PO are not 'done' or 'cancel'.

In order to fix it, the action_done on requisition should be call
on button_approve instead of button_confirm. (button_approve is
automatically called when double validation is not enable).

Task: #1884410
Closes #28068

closes odoo/odoo#29049
This commit is contained in:
Prakash Prajapati
2018-11-28 04:51:02 +00:00
committed by Arnold Moyaux
parent 54472d9c13
commit 679cf0d83f
@@ -257,8 +257,8 @@ class PurchaseOrder(models.Model):
self.order_line = order_lines
@api.multi
def button_confirm(self):
res = super(PurchaseOrder, self).button_confirm()
def button_approve(self, force=False):
res = super(PurchaseOrder, self).button_approve(force=force)
for po in self:
if not po.requisition_id:
continue