Compare commits
6 Commits
feature/坯料
...
307e860fe0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
307e860fe0 | ||
|
|
bd27f288f7 | ||
|
|
5bb6fcd4f7 | ||
|
|
b33c992b25 | ||
|
|
788183e239 | ||
|
|
f38f60a6a8 |
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_batch', '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()
|
||||||
@@ -190,7 +190,7 @@ def _create(self, data_list):
|
|||||||
# 如果该用户组被限制创建或更新操作
|
# 如果该用户组被限制创建或更新操作
|
||||||
if rec['is_create_or_update']:
|
if rec['is_create_or_update']:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
_("您没有执行此操作的权限。请联系管理员"))
|
_("您没有执行此操作(%s)的权限。请联系管理员" % group_xml_id))
|
||||||
else:
|
else:
|
||||||
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
||||||
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -196,14 +196,11 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
line.model_long = None
|
line.model_long = None
|
||||||
|
|
||||||
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height', 'product_id.blank_type')
|
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height')
|
||||||
def _compute_embryo_long(self):
|
def _compute_embryo_long(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
if line.product_id.blank_type == '圆料':
|
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
||||||
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
|
|
||||||
else:
|
|
||||||
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
|
||||||
else:
|
else:
|
||||||
line.embryo_long = None
|
line.embryo_long = None
|
||||||
|
|
||||||
@@ -326,8 +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
|
||||||
for pro_plan in pro_plan_list:
|
self._do_production_schedule(pro_plan_list)
|
||||||
pro_plan.do_production_schedule()
|
|
||||||
|
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):
|
def button_action_print(self):
|
||||||
return {
|
return {
|
||||||
@@ -402,30 +403,29 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
outsourcing_purchase_request.extend(pr_ids.ids)
|
outsourcing_purchase_request.extend(pr_ids.ids)
|
||||||
if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material:
|
if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material:
|
||||||
bom_line_ids = record.product_id.bom_ids.bom_line_ids
|
bom_line_ids = record.product_id.bom_ids.bom_line_ids
|
||||||
if bom_line_ids:
|
# BOM_数量
|
||||||
# BOM_数量
|
total_product_qty = sum(line.product_qty for line in bom_line_ids)
|
||||||
total_product_qty = sum(line.product_qty for line in bom_line_ids)
|
bom_product_ids = bom_line_ids.mapped('product_id')
|
||||||
bom_product_ids = bom_line_ids.mapped('product_id')
|
product_purchase_orders = self.env['purchase.order'].sudo().search([
|
||||||
product_purchase_orders = self.env['purchase.order'].sudo().search([
|
('state', 'in', ('purchase', 'done')),
|
||||||
('state', 'in', ('purchase', 'done')),
|
('order_line.product_id', 'in', bom_product_ids.ids)
|
||||||
('order_line.product_id', 'in', bom_product_ids.ids)
|
])
|
||||||
])
|
# 购订单_数量
|
||||||
# 购订单_数量
|
total_outsourcing_purchase_quantity = sum(
|
||||||
total_outsourcing_purchase_quantity = sum(
|
sum(
|
||||||
sum(
|
order.order_line.filtered(
|
||||||
order.order_line.filtered(
|
lambda line: line.product_id in bom_product_ids
|
||||||
lambda line: line.product_id in bom_product_ids
|
).mapped('product_qty')
|
||||||
).mapped('product_qty')
|
|
||||||
)
|
|
||||||
for order in product_purchase_orders
|
|
||||||
)
|
)
|
||||||
quantity = total_outsourcing_purchase_quantity / total_product_qty
|
for order in product_purchase_orders
|
||||||
if float_compare(quantity, record.product_uom_qty,
|
)
|
||||||
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
quantity = total_outsourcing_purchase_quantity / total_product_qty
|
||||||
purchase_request = self.env['purchase.request'].sudo().search(
|
if float_compare(quantity, record.product_uom_qty,
|
||||||
[('line_ids.product_id', 'in', bom_product_ids.ids),
|
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
||||||
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])
|
purchase_request = self.env['purchase.request'].sudo().search(
|
||||||
outsourcing_purchase_request.extend(purchase_request.ids)
|
[('line_ids.product_id', 'in', bom_product_ids.ids),
|
||||||
|
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])
|
||||||
|
outsourcing_purchase_request.extend(purchase_request.ids)
|
||||||
record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request)
|
record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request)
|
||||||
if outsourcing_purchase_request:
|
if outsourcing_purchase_request:
|
||||||
record.hide_action_purchase_orders = True
|
record.hide_action_purchase_orders = True
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<field name="qty_delivered"/>
|
<field name="qty_delivered"/>
|
||||||
<field name="qty_to_deliver"/>
|
<field name="qty_to_deliver"/>
|
||||||
<field name="model_long"/>
|
<field name="model_long"/>
|
||||||
<field name="blank_type" optional="hide"/>
|
<field name="blank_type"/>
|
||||||
<field name="embryo_long"/>
|
<field name="embryo_long"/>
|
||||||
<field name="materials_id"/>
|
<field name="materials_id"/>
|
||||||
<field name="model_machining_precision"/>
|
<field name="model_machining_precision"/>
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
|
|
||||||
# 工单返工数量
|
# 工单返工数量
|
||||||
|
|
||||||
plan_data_rework = work_order_obj.search(work_order_domain + [
|
plan_data_rework = work_order_obj.search(plan_domain + [
|
||||||
('state', 'in', ['rework'])
|
('state', 'in', ['rework'])
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -857,6 +857,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
:param kw:
|
:param kw:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
request.env['stock.warehouse'].browse(request.env.company.id).pbm_loc_id
|
||||||
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
|
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
|
||||||
res = {'status': 1, 'message': '成功', 'data': {}}
|
res = {'status': 1, 'message': '成功', 'data': {}}
|
||||||
plan_obj = request.env['sf.production.plan'].sudo()
|
plan_obj = request.env['sf.production.plan'].sudo()
|
||||||
|
|||||||
Reference in New Issue
Block a user