Compare commits

...

14 Commits

Author SHA1 Message Date
陈赓
d580f47885 追溯 2025-07-16 14:34:07 +08:00
管欢
7dd44ca12c Accept Merge Request #2288: (feature/物料需求计划管理 -> develop)
Merge Request: 下达计划按钮重复点击生成重复数据

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2288
2025-07-16 09:41:06 +08:00
guanhuan
5a98b20988 下达计划按钮重复点击生成重复数据 2025-07-16 09:32:28 +08:00
李晓斌
2738085a1e Accept Merge Request #2287: (feature/7253 -> develop)
Merge Request: Bug_7276_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2287?initial=true
2025-07-15 16:56:26 +08:00
lixiaobin@jikimo.com
61c1fdbd05 Bug_7276_lxb_commit 2025-07-15 16:53:52 +08:00
hyyy
7eea5a0ff2 重复点击 2025-07-15 16:25:28 +08:00
李晓斌
714c68c0c1 Accept Merge Request #2286: (feature/7253 -> develop)
Merge Request: BUG_7276_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2286
2025-07-15 14:35:11 +08:00
lixiaobin@jikimo.com
f3e7ba7f68 BUG_7276_lxb_commit 2025-07-15 14:17:38 +08:00
lixiaobin@jikimo.com
df589b43e7 BUG_7276_lxb_commit 2025-07-15 14:13:01 +08:00
lixiaobin@jikimo.com
8bdc65c626 BUG_7276_lxb_commit 2025-07-15 14:09:14 +08:00
guanhuan
0c3407572f 需求计划详情 2025-07-15 11:51:14 +08:00
hyyy
e5404efb60 批量下达计划禁用 2025-07-15 11:39:20 +08:00
guanhuan
46f60028aa 需求位置修改 2025-07-15 10:40:19 +08:00
guanhuan
bfc071debd 需求位置修改 2025-07-15 10:34:28 +08:00
8 changed files with 228 additions and 107 deletions

View File

@@ -30,6 +30,7 @@
'web.assets_backend': [ 'web.assets_backend': [
'sf_demand_plan/static/src/scss/style.css', 'sf_demand_plan/static/src/scss/style.css',
'sf_demand_plan/static/src/js/print_demand.js', 'sf_demand_plan/static/src/js/print_demand.js',
'sf_demand_plan/static/src/js/custom_button.js',
] ]
}, },
'license': 'LGPL-3', 'license': 'LGPL-3',

View File

@@ -36,7 +36,7 @@ class PurchaseOrderLine(models.Model):
@api.model @api.model
def create(self, vals): def create(self, vals):
res = super(PurchaseOrderLine, self).create(vals) res = super(PurchaseOrderLine, self).create(vals)
if not res.demand_plan_line_id: if not res.demand_plan_line_id and res.order_id.origin:
origin = [origin.replace(' ', '') for origin in res.order_id.origin.split(',')] origin = [origin.replace(' ', '') for origin in res.order_id.origin.split(',')]
if self.env.context.get('demand_plan_line_id'): if self.env.context.get('demand_plan_line_id'):
res.demand_plan_line_id = self.env.context.get('demand_plan_line_id') res.demand_plan_line_id = self.env.context.get('demand_plan_line_id')

View File

@@ -7,7 +7,29 @@ from odoo.tools import float_compare
from datetime import datetime, timedelta from datetime import datetime, timedelta
from odoo.exceptions import UserError from odoo.exceptions import UserError
import re import re
#本地环境问题 不加报错
class ProductCategory(models.Model):
_inherit = 'product.category'
negative_inventory_allowed = fields.Boolean(string="允许负库存", default=False)
class StockPicking(models.Model):
_inherit = 'stock.picking'
whether_show_quality_check = fields.Boolean(string="是否显示质检")
class ProductTemplate(models.Model):
_inherit = 'product.template'
blank_type = fields.Selection([
('圆料', '圆料'),
('方料', '方料'),
], string='坯料分类')
blank_precision = fields.Selection([
('精坯', '精坯'),
('粗坯', '粗坯'),
], string='坯料类型')
class SfProductionDemandPlan(models.Model): class SfProductionDemandPlan(models.Model):
_name = 'sf.production.demand.plan' _name = 'sf.production.demand.plan'
@@ -688,19 +710,49 @@ class SfProductionDemandPlan(models.Model):
self.action_confirm() self.action_confirm()
def action_confirm(self): def action_confirm(self):
self = self.with_context( """
demand_plan_line_id=self.id 确认需求计划行,创建 BOM、触发库存规则并更新状态。
) """
# 将当前需求计划行 ID 写入上下文,便于后续方法使用
self = self.with_context(demand_plan_line_id=self.id)
# 创建物料清单BOM根据供货方式进行不同的处理
self.mrp_bom_create() self.mrp_bom_create()
# 启动库存规则(创建采购、生产等)
self._action_launch_stock_rule() self._action_launch_stock_rule()
# 根据供货方式设置状态字段
if self.supply_method in ('automation', 'manual'): if self.supply_method in ('automation', 'manual'):
self.write({'status': '50'}) self.write({'status': '50'}) # 自动/手工 供货:待排产
self.update_sale_order_state() self.update_sale_order_state()
else: else:
self.write({'status': '60'}) self.write({'status': '60'}) # 外购/外协/客户自供:无需排产
self.update_sale_order_state() self.update_sale_order_state()
def _get_embryo_template_by_supply_method(self):
"""
根据供货方式返回对应的胚料模板 product.template 记录。
"""
supply_map = {
'automation': self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo(),
'outsourcing': self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo(),
'purchase': self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo(),
'manual': self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo(),
'material_customer_provided': self.env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo(),
}
template = supply_map.get(self.supply_method)
if not template:
raise UserError(f"未配置供货方式 {self.supply_method} 对应的胚料模板")
return template
def mrp_bom_create(self): def mrp_bom_create(self):
"""
创建 BOM包含胚料与成品 BOM用于后续生产或采购流程。
"""
# 如果同一计划中已有对应的 BOM 可复用,则直接使用
if self.supply_method in ('automation', 'manual'): if self.supply_method in ('automation', 'manual'):
line_ids = self.demand_plan_id.line_ids.filtered( line_ids = self.demand_plan_id.line_ids.filtered(
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60')) lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
@@ -713,32 +765,32 @@ class SfProductionDemandPlan(models.Model):
if line_ids: if line_ids:
self.bom_id = line_ids[0].bom_id.id self.bom_id = line_ids[0].bom_id.id
return return
# 根据供货方式选择模板和 BOM 类型
bom_type = '' bom_type = ''
# 根据供货方式修改成品模板
if self.supply_method == 'automation': if self.supply_method == 'automation':
bom_type = 'normal' bom_type = 'normal'
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id
elif self.supply_method == 'outsourcing': elif self.supply_method == 'outsourcing':
bom_type = 'subcontract' bom_type = 'subcontract'
product_template_id = self.env.ref( product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
'jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
elif self.supply_method == 'purchase': elif self.supply_method == 'purchase':
product_template_id = self.env.ref( product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
'jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
elif self.supply_method == 'manual': elif self.supply_method == 'manual':
bom_type = 'normal' bom_type = 'normal'
product_template_id = self.env.ref( product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
'jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
# 复制成品模板上的属性 # 使用模板复制内容到当前产品
self.product_id.product_tmpl_id.copy_template(product_template_id) self.product_id.product_tmpl_id.copy_template(product_template_id)
# 构造 BOM 编码(包含时间戳)
future_time = datetime.now() + timedelta(hours=8) future_time = datetime.now() + timedelta(hours=8)
# 生成BOM单据编码
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}" code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
order_id = self.sale_order_id order_id = self.sale_order_id
product = self.product_id product = self.product_id
# 拼接方法需要的item结构成品的模型数据信息就是坯料的数据信息
# 构造胚料产品的参数
item = { item = {
'texture_code': product.materials_id.materials_no, 'texture_code': product.materials_id.materials_no,
'texture_type_code': product.materials_type_id.materials_no, 'texture_type_code': product.materials_type_id.materials_no,
@@ -751,110 +803,84 @@ class SfProductionDemandPlan(models.Model):
'embryo_redundancy_id': self.sale_order_line_id.embryo_redundancy_id, 'embryo_redundancy_id': self.sale_order_line_id.embryo_redundancy_id,
'model_id': self.model_id 'model_id': self.model_id
} }
# 从产品名中提取编号(如 S12345-3
product_name = '' product_name = ''
match = re.search(r'(S\d{5}-\d+)', product.name) match = re.search(r'(S\d{5}-\d+)', product.name)
product_seria = 0 product_seria = 0
# 如果匹配成功,提取结果
if match: if match:
product_name = match.group(0) product_name = match.group(0)
# 获取成品名结尾-n的n
product_seria = int(product_name.split('-')[-1]) product_seria = int(product_name.split('-')[-1])
# 成品供货方式为采购则不生成bom # 如果供货方式不是采购,则需要先创建胚料产品
if self.supply_method != 'purchase': if self.supply_method != 'purchase':
# 当成品上带有客供料选项时,生成坯料时选择“客供料”路线 # 判断是否为客户自供
if self.sale_order_line_id.embryo_redundancy_id: if self.sale_order_line_id.embryo_redundancy_id:
# 将成品模板的内容复制到成品上 embryo_template = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo()
customer_provided_embryo = self.env.ref( embryo_key = 'material_customer_provided'
'jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo() else:
# 创建坯料客供料的批量不需要创建bom embryo_template = self._get_embryo_template_by_supply_method()
material_customer_provided_embryo = self.env['product.template'].sudo().no_bom_product_create( embryo_key = self.supply_method
customer_provided_embryo.with_context(active_test=False).product_variant_id,
item, # 获取批次追踪方式 依据模版
order_id, 'material_customer_provided', product_seria, product) tracking_method = embryo_template.tracking
# 成品配置bom
product_bom_material_customer_provided = self.env['mrp.bom'].with_user( # 创建胚料产品(无 BOM 产品)
self.env.ref("base.user_admin")).bom_create( embryo_product = self.env['product.template'].sudo().no_bom_product_create(
product, bom_type, 'product', code) embryo_template.with_context(active_test=False).product_variant_id,
product_bom_material_customer_provided.with_user( item,
self.env.ref("base.user_admin")).bom_create_line_has( order_id,
material_customer_provided_embryo) embryo_key,
self.bom_id = product_bom_material_customer_provided.id product_seria,
elif self.product_id.materials_type_id.gain_way == '自加工': product
self_machining_id = self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo() )
# 创建坯料
self_machining_embryo = self.env['product.template'].sudo().no_bom_product_create( if isinstance(embryo_product, models.Model): # 确保返回的是记录而非错误码
self_machining_id, embryo_product.write({'tracking': tracking_method})
item,
order_id, 'self_machining', product_seria, product) if embryo_product == -3:
# 创建坯料的bom raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
self_machining_bom = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create( # 设置胚料 BOM 类型
self_machining_embryo, 'normal', False) if embryo_key in ('automation', 'manual', 'material_customer_provided'):
# 创建坯料里bom的组件 embryo_bom_type = 'normal'
self_machining_bom_line = self_machining_bom.with_user( elif embryo_key == 'outsourcing':
self.env.ref("base.user_admin")).bom_create_line( embryo_bom_type = 'subcontract'
self_machining_embryo) elif embryo_key == 'purchase':
if not self_machining_bom_line: embryo_bom_type = 'purchase'
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配') else:
# 产品配置bom embryo_bom_type = 'normal'
product_bom_self_machining = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create( # 创建胚料 BOM 及 BOM 行
product, bom_type, 'product', code) embryo_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
product_bom_self_machining.with_user(self.env.ref("base.user_admin")).bom_create_line_has( embryo_product, embryo_bom_type, True, tracking=tracking_method)
self_machining_embryo)
self.bom_id = product_bom_self_machining.id embryo_bom_line = embryo_bom.with_user(self.env.ref("base.user_admin")).bom_create_line(embryo_product)
elif self.product_id.materials_type_id.gain_way == '外协': if not embryo_bom_line:
outsource_id = self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo() raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
# 创建坯料
outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id, # 创建成品 BOM包含胚料
item, product_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
order_id, product, bom_type, 'product', code, tracking=tracking_method)
'subcontract', product_bom.with_user(self.env.ref("base.user_admin")).bom_create_line_has(embryo_product)
product_seria,
product) # 赋值 BOM ID
if outsource_embryo == -3: self.bom_id = product_bom.id
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
# 创建坯料的bom
outsource_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
outsource_embryo,
'subcontract', True)
# 创建坯料的bom的组件
outsource_bom_line = outsource_bom.with_user(
self.env.ref("base.user_admin")).bom_create_line(outsource_embryo)
if not outsource_bom_line:
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
# 产品配置bom
product_bom_outsource = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product', code)
product_bom_outsource.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
outsource_embryo)
self.bom_id = product_bom_outsource.id
elif self.product_id.materials_type_id.gain_way == '采购':
purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id,
item,
order_id,
'purchase',
product_seria,
product)
if purchase_embryo and purchase_embryo == -3:
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
else:
# 产品配置bom
product_bom_purchase = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product', code)
product_bom_purchase.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
purchase_embryo)
self.bom_id = product_bom_purchase.id
def _action_launch_stock_rule(self): def _action_launch_stock_rule(self):
"""
触发库存规则(如采购、生产),并确认相关拣货单。
"""
procurements = [] procurements = []
group_id = self.sale_order_id.procurement_group_id group_id = self.sale_order_id.procurement_group_id
if not group_id: if not group_id:
# 没有分组则创建
group_id = self.env['procurement.group'].create(self._prepare_procurement_group_vals()) group_id = self.env['procurement.group'].create(self._prepare_procurement_group_vals())
self.sale_order_id.procurement_group_id = group_id self.sale_order_id.procurement_group_id = group_id
else: else:
# 若已有分组但字段有变动则更新
updated_vals = {} updated_vals = {}
if group_id.partner_id != self.sale_order_id.partner_shipping_id: if group_id.partner_id != self.sale_order_id.partner_shipping_id:
updated_vals.update({'partner_id': self.sale_order_id.partner_shipping_id.id}) updated_vals.update({'partner_id': self.sale_order_id.partner_shipping_id.id})
@@ -862,27 +888,42 @@ class SfProductionDemandPlan(models.Model):
updated_vals.update({'move_type': self.sale_order_id.picking_policy}) updated_vals.update({'move_type': self.sale_order_id.picking_policy})
if updated_vals: if updated_vals:
group_id.write(updated_vals) group_id.write(updated_vals)
# 构造 procurement 所需的字段
values = self._prepare_procurement_values(group_id=group_id) values = self._prepare_procurement_values(group_id=group_id)
# 单位换算
line_uom = self.sale_order_line_id.product_uom line_uom = self.sale_order_line_id.product_uom
quant_uom = self.product_id.uom_id quant_uom = self.product_id.uom_id
plan_uom_qty, procurement_uom = line_uom._adjust_uom_quantities(self.plan_uom_qty, quant_uom) plan_uom_qty, procurement_uom = line_uom._adjust_uom_quantities(self.plan_uom_qty, quant_uom)
# 创建 procurement 请求
procurements.append(self.env['procurement.group'].Procurement( procurements.append(self.env['procurement.group'].Procurement(
self.product_id, plan_uom_qty, procurement_uom, self.product_id, plan_uom_qty, procurement_uom,
self.sale_order_id.partner_shipping_id.property_stock_customer, self.sale_order_id.partner_shipping_id.property_stock_customer,
self.product_id.display_name, self.sale_order_id.name, self.sale_order_id.company_id, values)) self.product_id.display_name, self.sale_order_id.name, self.sale_order_id.company_id, values))
# 执行调度
if procurements: if procurements:
procurement_group = self.env['procurement.group'] procurement_group = self.env['procurement.group']
if self.env.context.get('import_file'): if self.env.context.get('import_file'):
procurement_group = procurement_group.with_context(import_file=False) procurement_group = procurement_group.with_context(import_file=False)
procurement_group.run(procurements) procurement_group.run(procurements)
# 确认相关的拣货单
orders = self.mapped('sale_order_id') orders = self.mapped('sale_order_id')
for order in orders: for order in orders:
pickings_to_confirm = order.picking_ids.filtered(lambda p: p.state not in ['cancel', 'done']) pickings_to_confirm = order.picking_ids.filtered(lambda p: p.state not in ['cancel', 'done'])
if pickings_to_confirm: if pickings_to_confirm:
pickings_to_confirm.action_confirm() pickings_to_confirm.action_confirm()
return True return True
def _prepare_procurement_group_vals(self): def _prepare_procurement_group_vals(self):
"""
构造创建 procurement group 所需的字段。
"""
return { return {
'name': self.sale_order_id.name, 'name': self.sale_order_id.name,
'move_type': self.sale_order_id.picking_policy, 'move_type': self.sale_order_id.picking_policy,
@@ -890,11 +931,18 @@ class SfProductionDemandPlan(models.Model):
'partner_id': self.sale_order_id.partner_shipping_id.id, 'partner_id': self.sale_order_id.partner_shipping_id.id,
} }
def _prepare_procurement_values(self, group_id=False): def _prepare_procurement_values(self, group_id=False):
"""
构造单个 procurement 请求所需的字段字典。
"""
self.ensure_one() self.ensure_one()
# 交货日期与计划日期
date_deadline = self.sale_order_id.commitment_date or ( date_deadline = self.sale_order_id.commitment_date or (
self.sale_order_id.date_order + timedelta(days=self.sale_order_line_id.customer_lead or 0.0)) self.sale_order_id.date_order + timedelta(days=self.sale_order_line_id.customer_lead or 0.0))
date_planned = date_deadline - timedelta(days=self.sale_order_id.company_id.security_lead) date_planned = date_deadline - timedelta(days=self.sale_order_id.company_id.security_lead)
values = { values = {
'group_id': group_id, 'group_id': group_id,
'sale_line_id': self.sale_order_line_id.id, 'sale_line_id': self.sale_order_line_id.id,
@@ -910,4 +958,6 @@ class SfProductionDemandPlan(models.Model):
'sequence': self.sale_order_line_id.sequence, 'sequence': self.sale_order_line_id.sequence,
'demand_plan_line_id': self.id 'demand_plan_line_id': self.id
} }
return values return values

View File

@@ -0,0 +1,59 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { ListRenderer } from "@web/views/list/list_renderer";
import { useService } from "@web/core/utils/hooks";
import { useEffect } from "@odoo/owl";
export class CustomDemandPlanListRenderer extends ListRenderer {
setup() {
super.setup();
this.orm = useService("orm");
this.notification = useService("notification");
console.log('setup', this.props);
// 监听selection属性的变化
useEffect(() => {
this.updateButtonState();
}, () => [this.props.list.selection]);
}
/**
* 更新按钮状态
*/
async updateButtonState() {
const selectedRecords = this.props.list.selection;
const isStatus30 = selectedRecords.some(record => record.data.status != "30");
const button = $(this.__owl__.parent.bdom.parentEl).find('button[name="button_batch_release_plan"]');
console.log('isStatus30', isStatus30, button);
if (isStatus30) {
// 禁用按钮
button.attr('disabled', true);
} else {
button.attr('disabled', false);
}
}
}
// 使用setTimeout延迟注册避免在模块加载时立即执行
setTimeout(() => {
const registerCustomRenderer = () => {
try {
const listView = registry.category("views").get("list");
if (listView) {
registry.category("views").add("custom_demand_plan_list", {
...listView,
Renderer: CustomDemandPlanListRenderer,
});
console.log("Custom demand plan list renderer registered successfully");
} else {
console.warn("List view not found, retrying...");
// 如果还没找到,再等一段时间
setTimeout(registerCustomRenderer, 1000);
}
} catch (error) {
console.error("Error registering custom renderer:", error);
}
};
registerCustomRenderer();
}, 1000);

View File

@@ -4,7 +4,8 @@
<field name="model">sf.production.demand.plan</field> <field name="model">sf.production.demand.plan</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom" <tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false"> class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false"
js_class="custom_demand_plan_list">
<header> <header>
<button string="打印" name="button_action_print" type="object" <button string="打印" name="button_action_print" type="object"
class="btn-primary"/> class="btn-primary"/>

View File

@@ -108,6 +108,9 @@
class="btn-primary" class="btn-primary"
attrs="{'invisible': [('hide_release_production_order', '=', False)]}" attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
/> />
<button string="详情" name="button_plan_detail" type="object"
class="btn-primary"
/>
</tree> </tree>
</field> </field>
</page> </page>

View File

@@ -37,7 +37,7 @@ class SfDemandPlanPrintWizard(models.TransientModel):
if pdf_data: if pdf_data:
try: try:
# 执行打印 # 执行打印
self.env['jikimo.printing'].sudo().print_pdf(pdf_data) # self.env['jikimo.printing'].sudo().print_pdf(pdf_data)
record.status = 'success' record.status = 'success'
production_demand_plan_id = self.env['sf.production.demand.plan'].sudo().search( production_demand_plan_id = self.env['sf.production.demand.plan'].sudo().search(
[('model_id', '=', record.model_id)]) [('model_id', '=', record.model_id)])

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging import logging
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from werkzeug.exceptions import InternalServerError
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -17,4 +18,10 @@ class SfReleasePlanWizard(models.TransientModel):
def confirm(self): def confirm(self):
if self.demand_plan_line_id: if self.demand_plan_line_id:
for demand_plan_line_id in self.demand_plan_line_id: for demand_plan_line_id in self.demand_plan_line_id:
demand_plan_line_id.action_confirm() try:
demand_plan_line_id.action_confirm()
except Exception as e:
self.env.cr.rollback()
demand_plan_line_id.write({'is_processing': False})
self.env.cr.commit()
raise InternalServerError('操作失败', e)