取消采购申请部分确认生成的反向单据
This commit is contained in:
@@ -13,4 +13,14 @@ class PurchaseOrder(models.Model):
|
|||||||
('done', '完成'),
|
('done', '完成'),
|
||||||
('cancel', '取消'),
|
('cancel', '取消'),
|
||||||
('rejected', '已驳回')
|
('rejected', '已驳回')
|
||||||
], string='Status', readonly=True, index=True, copy=False, default='draft', tracking=True)
|
], 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
|
||||||
|
|
||||||
|
|||||||
@@ -79,12 +79,4 @@ class StockRule(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
res = super(StockRule, self)._run_buy(new_procurements)
|
res = super(StockRule, self)._run_buy(new_procurements)
|
||||||
# 判断是否根据规则生成新的采购申请单据,如果生成则修改状态为 approved
|
|
||||||
origins = list(set([procurement[0].origin for procurement in procurements]))
|
|
||||||
for origin in origins:
|
|
||||||
pr_ids = self.env["purchase.request"].sudo().search(
|
|
||||||
[('origin', 'like', origin), ('rule_new_add', '=', True), ('state', '=', 'draft')])
|
|
||||||
if pr_ids:
|
|
||||||
pr_ids.write({'need_validation': False})
|
|
||||||
pr_ids.write({"state": "approved", 'need_validation': True, 'rule_new_add': False})
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
{
|
{
|
||||||
'name': "机企猫 采购审批流程",
|
'name': "机企猫 采购申请审批流程",
|
||||||
|
|
||||||
'summary': """
|
'summary': """
|
||||||
Short (1 phrase/line) summary of the module's purpose, used as
|
采购申请审批流程""",
|
||||||
subtitle on modules listing or apps.openerp.com""",
|
|
||||||
|
|
||||||
'description': """
|
'description': """
|
||||||
Long description of module's purpose
|
Long description of module's purpose
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import stock_rule
|
||||||
16
jikimo_purchase_request_tier_validation/models/stock_rule.py
Normal file
16
jikimo_purchase_request_tier_validation/models/stock_rule.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from odoo import models, api
|
||||||
|
|
||||||
|
class StockRule(models.Model):
|
||||||
|
_inherit = 'stock.rule'
|
||||||
|
|
||||||
|
def _run_buy(self, procurements):
|
||||||
|
res = super(StockRule, self)._run_buy(procurements)
|
||||||
|
# 判断是否根据规则生成新的采购申请单据,如果生成则修改状态为 approved
|
||||||
|
origins = list(set([procurement[0].origin for procurement in procurements]))
|
||||||
|
for origin in origins:
|
||||||
|
pr_ids = self.env["purchase.request"].sudo().search(
|
||||||
|
[('origin', 'like', origin), ('rule_new_add', '=', True), ('state', '=', 'draft')])
|
||||||
|
if pr_ids:
|
||||||
|
pr_ids.write({'need_validation': False})
|
||||||
|
pr_ids.write({"state": "approved", 'need_validation': True, 'rule_new_add': False})
|
||||||
|
return res
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
{
|
{
|
||||||
'name': "机企猫 采购申请审批流程",
|
'name': "机企猫 采购审批流程",
|
||||||
|
|
||||||
'summary': """
|
'summary': """
|
||||||
采购申请审批流程""",
|
采购审批流程""",
|
||||||
|
|
||||||
'description': """
|
'description': """
|
||||||
采购申请审批流程""",
|
采购审批流程""",
|
||||||
|
|
||||||
'author': "My Company",
|
'author': "My Company",
|
||||||
'website': "https://www.yourcompany.com",
|
'website': "https://www.yourcompany.com",
|
||||||
|
|||||||
Reference in New Issue
Block a user