Compare commits

...

6 Commits

Author SHA1 Message Date
胡尧
307e860fe0 增加提示模块 2025-06-20 15:16:43 +08:00
胡尧
bd27f288f7 增加提示模块 2025-06-20 15:16:25 +08:00
胡尧
5bb6fcd4f7 修改依赖 2025-06-20 15:03:42 +08:00
胡尧
b33c992b25 修改需求计划,下达生成的方法 2025-06-20 14:51:58 +08:00
胡尧
788183e239 修改批量大小 2025-06-20 13:52:37 +08:00
胡尧
f38f60a6a8 计划增加队列 2025-06-20 11:24:39 +08:00
7 changed files with 50 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
{
'name': '机企猫 需求计划排程队列',
'version': '1.0',
'summary': """ 使用队列进行排程 """,
'author': 'fox',
'website': '',
'category': '',
'depends': ['queue_job_batch', 'sf_demand_plan'],
'data': [
],
'application': True,
'installable': True,
'auto_install': False,
'license': 'LGPL-3',
}

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import production_demand_plan

View File

@@ -0,0 +1,20 @@
from odoo import models, fields
class ProductionDemandPlan(models.Model):
_inherit = 'sf.production.demand.plan'
def _do_production_schedule(self, pro_plan_list):
"""使用队列进行排程"""
batch_size = 10
current_time = fields.Datetime.now().strftime('%Y%m%d%H%M%S')
index = 1
for i in range(0, len(pro_plan_list), batch_size):
batch = self.env['queue.job.batch'].get_new_batch('plan-%s-%s' % (current_time, index))
pro_plans = pro_plan_list[i:i+batch_size]
pro_plans.with_context(
job_batch=batch
).with_delay().do_production_schedule()
index += 1
batch.enqueue()

View File

@@ -190,7 +190,7 @@ def _create(self, data_list):
# 如果该用户组被限制创建或更新操作
if rec['is_create_or_update']:
raise UserError(
_("您没有执行此操作的权限。请联系管理员"))
_("您没有执行此操作%s的权限。请联系管理员" % group_xml_id))
else:
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑

View File

@@ -10,7 +10,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['sf_plan', 'jikimo_printing'],
'depends': ['sf_plan'],
'data': [
'security/ir.model.access.csv',
'views/demand_plan.xml',

View File

@@ -323,8 +323,12 @@ class SfProductionDemandPlan(models.Model):
date_planned_start = datetime.combine(date_part, time_part)
pro_plan_list.production_line_id = sf_production_line.id
pro_plan_list.date_planned_start = date_planned_start
for pro_plan in pro_plan_list:
pro_plan.do_production_schedule()
self._do_production_schedule(pro_plan_list)
def _do_production_schedule(self, pro_plan_list):
for pro_plan in pro_plan_list:
pro_plan.do_production_schedule()
def button_action_print(self):
return {