新增按规格生成的采购申请订单跳过审核环节自动更新为已批准状态
This commit is contained in:
@@ -4,15 +4,15 @@ from odoo import fields, models, api, _
|
||||
class StatusChange(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
def action_confirm(self):
|
||||
res = super(StatusChange, self).action_confirm()
|
||||
# 采购申请自动确认
|
||||
pr_ids = self.env["purchase.request"].sudo().search(
|
||||
[('origin', 'like', self.name), ('rule_new_add', '=', True)])
|
||||
if pr_ids:
|
||||
pr_ids.write({'need_validation': False})
|
||||
pr_ids.write({"state": "approved"})
|
||||
return res
|
||||
# def action_confirm(self):
|
||||
# res = super(StatusChange, self).action_confirm()
|
||||
# # 采购申请自动确认
|
||||
# pr_ids = self.env["purchase.request"].sudo().search(
|
||||
# [('origin', 'like', self.name), ('rule_new_add', '=', True)])
|
||||
# if pr_ids:
|
||||
# pr_ids.write({'need_validation': False})
|
||||
# pr_ids.write({"state": "approved"})
|
||||
# return res
|
||||
|
||||
purchase_request_purchase_order_count = fields.Integer('采购申请单数量', compute='_compute_purchase_request_count',
|
||||
store=True)
|
||||
|
||||
@@ -42,3 +42,15 @@ class StockRule(models.Model):
|
||||
request_line_data = rule._prepare_purchase_request_line(pr, procurement)
|
||||
request_line_data.update({'origin': procurement.origin})
|
||||
purchase_request_line_model.create(request_line_data)
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user