12345678910111213141516171819 |
- # -*- encoding: utf-8 -*-
- from openerp import models, api, exceptions, _
- class PurchaseOrder(models.Model):
- _inherit = "purchase.order"
- @api.multi
- def button_purchase_draft(self):
- # go from canceled state to draft state
- for order in self:
- order.order_line.write({'state': 'draft'})
- for line in order.order_line:
- line.procurement_ids.sudo().unlink()
- order.write({'state': 'draft'})
- order.delete_workflow()
- order.create_workflow()
- return True
|