修改需求计划,下达生成的方法
This commit is contained in:
2
jikimo_demand_plan_queue/__init__.py
Normal file
2
jikimo_demand_plan_queue/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import models
|
||||||
18
jikimo_demand_plan_queue/__manifest__.py
Normal file
18
jikimo_demand_plan_queue/__manifest__.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
{
|
||||||
|
'name': '机企猫 需求计划排程队列',
|
||||||
|
'version': '1.0',
|
||||||
|
'summary': """ 使用队列进行排程 """,
|
||||||
|
'author': 'fox',
|
||||||
|
'website': '',
|
||||||
|
'category': '',
|
||||||
|
'depends': ['queue_job', 'sf_demand_plan'],
|
||||||
|
'data': [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'application': True,
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
}
|
||||||
2
jikimo_demand_plan_queue/models/__init__.py
Normal file
2
jikimo_demand_plan_queue/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import production_demand_plan
|
||||||
20
jikimo_demand_plan_queue/models/production_demand_plan.py
Normal file
20
jikimo_demand_plan_queue/models/production_demand_plan.py
Normal 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()
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_plan', 'jikimo_printing'],
|
'depends': ['sf_plan'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'views/demand_plan.xml',
|
'views/demand_plan.xml',
|
||||||
|
|||||||
@@ -323,15 +323,12 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
date_planned_start = datetime.combine(date_part, time_part)
|
date_planned_start = datetime.combine(date_part, time_part)
|
||||||
pro_plan_list.production_line_id = sf_production_line.id
|
pro_plan_list.production_line_id = sf_production_line.id
|
||||||
pro_plan_list.date_planned_start = date_planned_start
|
pro_plan_list.date_planned_start = date_planned_start
|
||||||
batch_size = 28
|
self._do_production_schedule(pro_plan_list)
|
||||||
for i in range(0, len(pro_plan_list), batch_size):
|
|
||||||
current_time = fields.Datetime.now().strftime('%Y%m%d%H%M%S')
|
def _do_production_schedule(self, pro_plan_list):
|
||||||
batch = self.env['queue.job.batch'].get_new_batch('plan-%s-%s' % (current_time, i))
|
for pro_plan in pro_plan_list:
|
||||||
pro_plans = pro_plan_list[i:i+batch_size]
|
pro_plan.do_production_schedule()
|
||||||
pro_plans.with_context(
|
|
||||||
job_batch=batch
|
|
||||||
).with_delay().do_production_schedule()
|
|
||||||
batch.enqueue()
|
|
||||||
|
|
||||||
def button_action_print(self):
|
def button_action_print(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user