27 lines
849 B
Python
27 lines
849 B
Python
from odoo import api, fields, models, _
|
|
|
|
|
|
class PurchaseOrder(models.Model):
|
|
_inherit = 'purchase.order'
|
|
|
|
state = fields.Selection([
|
|
('draft', '询价'),
|
|
('sent', '发送询价'),
|
|
('to approve', '待批准'),
|
|
("approved", "已批准"),
|
|
('purchase', '采购订单'),
|
|
('done', '完成'),
|
|
('cancel', '取消'),
|
|
('rejected', '已驳回')
|
|
], string='Status', readonly=True, index=True, copy=False, default='draft', tracking=True)
|
|
|
|
|
|
def button_confirm(self):
|
|
res = super(PurchaseOrder, self).button_confirm()
|
|
# 取消反向调拨单
|
|
reverse_move_ids = self.env['stock.move'].search([('origin', '=', self.name), ('purchase_line_id', '=', False)])
|
|
if reverse_move_ids:
|
|
reverse_move_ids.picking_id.action_cancel()
|
|
return res
|
|
|