交期状态
This commit is contained in:
@@ -10,8 +10,10 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','jikimo_attachment_viewer', 'jikimo_sale_multiple_supply_methods'],
|
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse', 'jikimo_attachment_viewer',
|
||||||
|
'jikimo_sale_multiple_supply_methods'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'data/cron_data.xml',
|
||||||
'data/stock_data.xml',
|
'data/stock_data.xml',
|
||||||
'data/empty_racks_data.xml',
|
'data/empty_racks_data.xml',
|
||||||
'data/panel_data.xml',
|
'data/panel_data.xml',
|
||||||
|
|||||||
29
sf_manufacturing/data/cron_data.xml
Normal file
29
sf_manufacturing/data/cron_data.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record model="ir.cron" id="ir_cron_update_construction_period_status">
|
||||||
|
<field name="name">工期状态变更</field>
|
||||||
|
<field name="model_id" ref="model_mrp_workorder"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model._corn_update_construction_period_status()</field>
|
||||||
|
<field name="interval_number">12</field>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="ir_cron_update_delivery_status">
|
||||||
|
<field name="name">交期状态变更</field>
|
||||||
|
<field name="model_id" ref="model_mrp_production"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model._corn_update_delivery_status()</field>
|
||||||
|
<field name="interval_number">12</field>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -60,6 +60,42 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
@api.depends('state', 'deadline_of_delivery')
|
@api.depends('state', 'deadline_of_delivery')
|
||||||
def _compute_delivery_status(self):
|
def _compute_delivery_status(self):
|
||||||
|
for production in self:
|
||||||
|
delivery_status = production._compute_default_delivery_status()
|
||||||
|
if delivery_status and production.delivery_status != delivery_status:
|
||||||
|
production.delivery_status = delivery_status
|
||||||
|
|
||||||
|
delivery_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')], string='交期状态',
|
||||||
|
store=True,
|
||||||
|
compute='_compute_delivery_status',
|
||||||
|
default=lambda self: self._compute_default_delivery_status())
|
||||||
|
|
||||||
|
def get_page_all_records(self, model_name, func, domain, page_size=100):
|
||||||
|
# 获取模型对象
|
||||||
|
model = self.env[model_name].sudo()
|
||||||
|
|
||||||
|
# 初始化分页参数
|
||||||
|
page_number = 1
|
||||||
|
while True:
|
||||||
|
# 计算偏移量
|
||||||
|
offset = (page_number - 1) * page_size
|
||||||
|
|
||||||
|
# 获取当前页的数据
|
||||||
|
records = model.search(domain, limit=page_size, offset=offset)
|
||||||
|
|
||||||
|
# 如果没有更多记录,退出循环
|
||||||
|
if not records:
|
||||||
|
break
|
||||||
|
|
||||||
|
# 将当前页的数据添加到结果列表
|
||||||
|
func(records)
|
||||||
|
# 增加页码
|
||||||
|
page_number += 1
|
||||||
|
|
||||||
|
def run_compute_delivery_status(self, records):
|
||||||
|
records._compute_delivery_status()
|
||||||
|
|
||||||
|
def _corn_update_delivery_status(self):
|
||||||
need_list = [
|
need_list = [
|
||||||
'pending_cam',
|
'pending_cam',
|
||||||
'progress',
|
'progress',
|
||||||
@@ -67,13 +103,9 @@ class MrpProduction(models.Model):
|
|||||||
'scrap',
|
'scrap',
|
||||||
'to_close',
|
'to_close',
|
||||||
]
|
]
|
||||||
for production in self:
|
# previous_workorder = self.env['mrp.production'].search([('state', 'in', need_list)])
|
||||||
production.delivery_status = production._compute_default_delivery_status()
|
self.get_page_all_records('mrp.production', self.run_compute_delivery_status,
|
||||||
|
[('state', 'in', need_list)], 100)
|
||||||
delivery_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')], string='交期状态',
|
|
||||||
store=True,
|
|
||||||
compute='_compute_delivery_status',
|
|
||||||
default=lambda self: self._compute_default_delivery_status())
|
|
||||||
|
|
||||||
def get_hours_diff(self):
|
def get_hours_diff(self):
|
||||||
# 获取当前日期和时间
|
# 获取当前日期和时间
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
def _compute_default_construction_period_status(self):
|
def _compute_default_construction_period_status(self):
|
||||||
need_list = [
|
need_list = [
|
||||||
'progress',
|
'progress',
|
||||||
'to be detected']
|
'to be detected']
|
||||||
try:
|
try:
|
||||||
if self.state not in need_list:
|
if self.state not in need_list:
|
||||||
return False
|
return False
|
||||||
@@ -170,12 +170,45 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
@api.depends('state', 'date_planned_finished')
|
@api.depends('state', 'date_planned_finished')
|
||||||
def _compute_construction_period_status(self):
|
def _compute_construction_period_status(self):
|
||||||
for worker in self:
|
for worker in self:
|
||||||
worker.construction_period_status = worker._compute_default_construction_period_status()
|
construction_period_status = worker._compute_default_construction_period_status()
|
||||||
|
if construction_period_status and worker.construction_period_status!=construction_period_status:
|
||||||
|
worker.construction_period_status = construction_period_status
|
||||||
|
|
||||||
construction_period_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')], string='工期状态',
|
construction_period_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')],
|
||||||
store=True,
|
string='工期状态',
|
||||||
compute='_compute_construction_period_status',
|
store=True,
|
||||||
default=lambda self: self._compute_default_construction_period_status())
|
compute='_compute_construction_period_status',
|
||||||
|
default=lambda
|
||||||
|
self: self._compute_default_construction_period_status())
|
||||||
|
|
||||||
|
def get_page_all_records(self, model_name, func, domain, page_size=100):
|
||||||
|
# 获取模型对象
|
||||||
|
model = self.env[model_name].sudo()
|
||||||
|
|
||||||
|
# 初始化分页参数
|
||||||
|
page_number = 1
|
||||||
|
while True:
|
||||||
|
# 计算偏移量
|
||||||
|
offset = (page_number - 1) * page_size
|
||||||
|
|
||||||
|
# 获取当前页的数据
|
||||||
|
records = model.search(domain, limit=page_size, offset=offset)
|
||||||
|
|
||||||
|
# 如果没有更多记录,退出循环
|
||||||
|
if not records:
|
||||||
|
break
|
||||||
|
|
||||||
|
# 将当前页的数据添加到结果列表
|
||||||
|
func(records)
|
||||||
|
# 增加页码
|
||||||
|
page_number += 1
|
||||||
|
def run_compute_construction_period_status(self,records):
|
||||||
|
records._compute_construction_period_status()
|
||||||
|
def _corn_update_construction_period_status(self):
|
||||||
|
need_list = [
|
||||||
|
'progress',
|
||||||
|
'to be detected']
|
||||||
|
self.get_page_all_records('mrp.workorder',self.run_compute_construction_period_status,[('state', 'in', need_list)],100)
|
||||||
|
|
||||||
def get_hours_diff(self):
|
def get_hours_diff(self):
|
||||||
# 获取当前日期和时间
|
# 获取当前日期和时间
|
||||||
|
|||||||
Reference in New Issue
Block a user