Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -4,15 +4,15 @@ from odoo import fields, models, api, _
|
|||||||
class StatusChange(models.Model):
|
class StatusChange(models.Model):
|
||||||
_inherit = 'sale.order'
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
def action_confirm(self):
|
# def action_confirm(self):
|
||||||
res = super(StatusChange, self).action_confirm()
|
# res = super(StatusChange, self).action_confirm()
|
||||||
# 采购申请自动确认
|
# # 采购申请自动确认
|
||||||
pr_ids = self.env["purchase.request"].sudo().search(
|
# pr_ids = self.env["purchase.request"].sudo().search(
|
||||||
[('origin', 'like', self.name), ('rule_new_add', '=', True)])
|
# [('origin', 'like', self.name), ('rule_new_add', '=', True)])
|
||||||
if pr_ids:
|
# if pr_ids:
|
||||||
pr_ids.write({'need_validation': False})
|
# pr_ids.write({'need_validation': False})
|
||||||
pr_ids.write({"state": "approved"})
|
# pr_ids.write({"state": "approved"})
|
||||||
return res
|
# return res
|
||||||
|
|
||||||
purchase_request_purchase_order_count = fields.Integer('采购申请单数量', compute='_compute_purchase_request_count',
|
purchase_request_purchase_order_count = fields.Integer('采购申请单数量', compute='_compute_purchase_request_count',
|
||||||
store=True)
|
store=True)
|
||||||
|
|||||||
@@ -42,3 +42,15 @@ class StockRule(models.Model):
|
|||||||
request_line_data = rule._prepare_purchase_request_line(pr, procurement)
|
request_line_data = rule._prepare_purchase_request_line(pr, procurement)
|
||||||
request_line_data.update({'origin': procurement.origin})
|
request_line_data.update({'origin': procurement.origin})
|
||||||
purchase_request_line_model.create(request_line_data)
|
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
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class jikimo_purchase_tier_validation(models.Model):
|
|||||||
_inherit = ['purchase.order', 'tier.validation']
|
_inherit = ['purchase.order', 'tier.validation']
|
||||||
_description = "采购订单"
|
_description = "采购订单"
|
||||||
_state_from = ["draft", "to approve", "rejected"]
|
_state_from = ["draft", "to approve", "rejected"]
|
||||||
_state_to = ["approved"]
|
_state_to = ["approved", "purchase"]
|
||||||
|
|
||||||
_tier_validation_buttons_xpath = "/form/header/button[@id='draft_confirm'][1]"
|
_tier_validation_buttons_xpath = "/form/header/button[@id='draft_confirm'][1]"
|
||||||
|
|
||||||
@@ -22,9 +22,9 @@ class jikimo_purchase_tier_validation(models.Model):
|
|||||||
is_upload_contract_file = fields.Boolean(string='是否已上传合同文件', default=False)
|
is_upload_contract_file = fields.Boolean(string='是否已上传合同文件', default=False)
|
||||||
|
|
||||||
def button_confirm(self):
|
def button_confirm(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.need_validation and not record.validation_status == 'validated':
|
# if record.need_validation and not record.validation_status == 'validated':
|
||||||
raise ValidationError(_('请先完成审批。'))
|
# raise ValidationError(_('请先完成审批。'))
|
||||||
res = super(jikimo_purchase_tier_validation, self).button_confirm()
|
res = super(jikimo_purchase_tier_validation, self).button_confirm()
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.state == 'approved':
|
if record.state == 'approved':
|
||||||
|
|||||||
Reference in New Issue
Block a user