解决供货路线选择报错
This commit is contained in:
3
jikimo_purchase_request_tier_validation/__init__.py
Normal file
3
jikimo_purchase_request_tier_validation/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import models
|
||||||
28
jikimo_purchase_request_tier_validation/__manifest__.py
Normal file
28
jikimo_purchase_request_tier_validation/__manifest__.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
{
|
||||||
|
'name': "机企猫 采购审批流程",
|
||||||
|
|
||||||
|
'summary': """
|
||||||
|
Short (1 phrase/line) summary of the module's purpose, used as
|
||||||
|
subtitle on modules listing or apps.openerp.com""",
|
||||||
|
|
||||||
|
'description': """
|
||||||
|
Long description of module's purpose
|
||||||
|
""",
|
||||||
|
|
||||||
|
'author': "My Company",
|
||||||
|
'website': "https://www.yourcompany.com",
|
||||||
|
|
||||||
|
# Categories can be used to filter modules in modules listing
|
||||||
|
# Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml
|
||||||
|
# for the full list
|
||||||
|
'category': 'Uncategorized',
|
||||||
|
'version': '0.1',
|
||||||
|
|
||||||
|
# any module necessary for this one to work correctly
|
||||||
|
'depends': ['purchase_request_tier_validation'],
|
||||||
|
|
||||||
|
# always loaded
|
||||||
|
'data': [
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import models
|
||||||
24
jikimo_purchase_request_tier_validation/models/models.py
Normal file
24
jikimo_purchase_request_tier_validation/models/models.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from odoo import models, fields, api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class PurchaseRequestTierValidation(models.Model):
|
||||||
|
_name = 'purchase.request.tier.validation'
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_tier(self, tiers=False):
|
||||||
|
res = super(PurchaseRequestTierValidation, self)._validate_tier(tiers)
|
||||||
|
|
||||||
|
# 检查是否所有审批都已通过
|
||||||
|
all_approved = all(
|
||||||
|
tier_review.status == 'approved'
|
||||||
|
for tier_review in self.review_ids
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.review_ids and all_approved: # 确保有审批记录
|
||||||
|
self.state = 'approved'
|
||||||
|
|
||||||
|
return res
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import {registerPatch} from "@mail/model/model_core";
|
||||||
|
|
||||||
|
registerPatch({
|
||||||
|
name: "ir.model.review",
|
||||||
|
fields: {
|
||||||
|
availableWebViews: {
|
||||||
|
compute() {
|
||||||
|
return ["list", "form", "activity"];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -59,15 +59,14 @@ class PurchaseOrder(models.Model):
|
|||||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||||
purchase.production_count = len(production_id)
|
purchase.production_count = len(production_id)
|
||||||
|
|
||||||
def write(self, vals):
|
def button_confirm(self):
|
||||||
res = super(PurchaseOrder, self).write(vals)
|
|
||||||
for record in self:
|
for record in self:
|
||||||
for line in record.order_line:
|
for line in record.order_line:
|
||||||
if line.product_qty <= 0:
|
if line.product_qty <= 0:
|
||||||
raise UserError('请对【产品】中的【数量】进行输入')
|
raise UserError('请对【产品】中的【数量】进行输入')
|
||||||
if line.price_unit <= 0:
|
if line.price_unit <= 0:
|
||||||
raise UserError('请对【产品】中的【单价】进行输入')
|
raise UserError('请对【产品】中的【单价】进行输入')
|
||||||
return res
|
return super(PurchaseOrder, self).button_confirm()
|
||||||
|
|
||||||
|
|
||||||
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')
|
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')
|
||||||
|
|||||||
Reference in New Issue
Block a user