purchase_order.py 557 B

12345678910111213141516171819
  1. # -*- encoding: utf-8 -*-
  2. from openerp import models, api, exceptions, _
  3. class PurchaseOrder(models.Model):
  4. _inherit = "purchase.order"
  5. @api.multi
  6. def button_purchase_draft(self):
  7. # go from canceled state to draft state
  8. for order in self:
  9. order.order_line.write({'state': 'draft'})
  10. for line in order.order_line:
  11. line.procurement_ids.sudo().unlink()
  12. order.write({'state': 'draft'})
  13. order.delete_workflow()
  14. order.create_workflow()
  15. return True