Merge branch 'feature/优化加工质检' into develop
This commit is contained in:
@@ -8,7 +8,7 @@ class SFMessageMaintenanceLogs(models.Model):
|
|||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
res = super(SFMessageMaintenanceLogs, self).create(vals_list)
|
res = super(SFMessageMaintenanceLogs, self).create(vals_list)
|
||||||
for rec in res:
|
for rec in res:
|
||||||
rec.add_queue('设备故障')
|
rec.add_queue('<EFBFBD>豸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_message(self, message_queue_ids):
|
def _get_message(self, message_queue_ids):
|
||||||
|
|||||||
@@ -103,39 +103,54 @@ class SFMessageSale(models.Model):
|
|||||||
today = datetime.today().date()
|
today = datetime.today().date()
|
||||||
deadline_check = today + timedelta(days=1)
|
deadline_check = today + timedelta(days=1)
|
||||||
logging.info(f"today: {today}, deadline_check: {deadline_check}")
|
logging.info(f"today: {today}, deadline_check: {deadline_check}")
|
||||||
sale_order = self.sudo().search([('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False)])
|
sale_order = self.sudo().search(
|
||||||
|
[('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')])
|
||||||
for item in sale_order:
|
for item in sale_order:
|
||||||
production = self.env['mrp.production'].search([('origin', '=', item.name)])
|
production = self.env['mrp.production'].search([('origin', '=', item.name)])
|
||||||
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
||||||
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
||||||
if len(production_not_done) != item.mrp_production_count:
|
if len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count:
|
||||||
if deadline_check == item.deadline_of_delivery:
|
logging.info("-----不等于----")
|
||||||
|
logging.info(f"name: {item.name}")
|
||||||
|
logging.info(
|
||||||
|
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||||
|
logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||||
|
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
elif today == item.deadline_of_delivery:
|
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
elif production_done_count == item.mrp_production_count:
|
elif production_done_count == item.mrp_production_count:
|
||||||
|
logging.info("-----等于----")
|
||||||
|
logging.info(f"name: {item.name}")
|
||||||
|
logging.info(
|
||||||
|
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||||
|
logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||||
if item.delivery_status in ['pending', 'partial']:
|
if item.delivery_status in ['pending', 'partial']:
|
||||||
if deadline_check == item.deadline_of_delivery:
|
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
elif today == item.deadline_of_delivery:
|
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
else:
|
else:
|
||||||
|
logging.info("-----1111111----")
|
||||||
continue
|
continue
|
||||||
|
# 获取业务节点
|
||||||
|
business_node_ids = {
|
||||||
|
'warning': self.env.ref('sf_message.bussiness_sale_order_overdue_warning').id,
|
||||||
|
'overdue': self.env.ref('sf_message.bussiness_sale_order_overdue').id
|
||||||
|
}
|
||||||
overdue_orders = self.sudo().search([('delivery_warning', 'in', ['warning', 'overdue'])])
|
overdue_orders = self.sudo().search([('delivery_warning', 'in', ['warning', 'overdue'])])
|
||||||
for wo in overdue_orders:
|
for wo in overdue_orders:
|
||||||
message_template = self.env["jikimo.message.template"].search([
|
business_node_id = business_node_ids.get(wo.delivery_warning)
|
||||||
("model", "=", self._name),
|
if business_node_id:
|
||||||
("bussiness_node_id", "=", self.env.ref('sf_message.bussiness_sale_order_overdue_warning').id)
|
message_template = self.env["jikimo.message.template"].search([
|
||||||
])
|
("model", "=", self._name),
|
||||||
sale_order_has = self.env['jikimo.message.queue'].search([
|
("bussiness_node_id", "=", business_node_id)
|
||||||
('res_id', '=', wo.id),
|
], limit=1)
|
||||||
('message_status', '=', 'pending'),
|
sale_order_has = self.env['jikimo.message.queue'].search([
|
||||||
('message_template_id', '=', message_template.id)
|
('res_id', '=', wo.id),
|
||||||
])
|
('message_status', '=', 'pending'),
|
||||||
if not sale_order_has:
|
('message_template_id', '=', message_template.id)
|
||||||
if wo.delivery_warning == 'warning':
|
])
|
||||||
wo.add_queue('销售订单逾期预警')
|
if not sale_order_has:
|
||||||
elif wo.delivery_warning == 'overdue':
|
message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期'
|
||||||
wo.add_queue('销售订单已逾期')
|
wo.add_queue(message_name)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -115,12 +115,13 @@ class SFMessageWork(models.Model):
|
|||||||
item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S"))
|
item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
date_planned_finished = datetime.strptime(date_planned_finished_str, '%Y-%m-%d %H:%M:%S')
|
date_planned_finished = datetime.strptime(date_planned_finished_str, '%Y-%m-%d %H:%M:%S')
|
||||||
twelve_hours_ago = current_time_datetime - timedelta(hours=12)
|
twelve_hours_ago = current_time_datetime - timedelta(hours=12)
|
||||||
if current_time_datetime >= date_planned_finished:
|
if current_time_datetime >= date_planned_finished and item.delivery_warning not in ['overdue']:
|
||||||
logging.info("------overdue-------")
|
logging.info("------overdue-------")
|
||||||
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
||||||
f"Planned Finish: {date_planned_finished}")
|
f"Planned Finish: {date_planned_finished}")
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
elif twelve_hours_ago <= current_time_datetime <= date_planned_finished:
|
elif twelve_hours_ago <= current_time_datetime <= date_planned_finished and item.delivery_warning not in [
|
||||||
|
'warning']:
|
||||||
logging.info("------warning-------")
|
logging.info("------warning-------")
|
||||||
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
||||||
f"Planned Finish: {date_planned_finished}")
|
f"Planned Finish: {date_planned_finished}")
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class SfQualityCncTest(models.Model):
|
|||||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||||
detailed_reason = fields.Text('详细原因')
|
detailed_reason = fields.Text('详细原因')
|
||||||
|
|
||||||
# machining_drawings = fields.Binary(related='workorder_id.machining_drawings', string='2D加工图纸', readonly=True)
|
machining_drawings = fields.Binary('2D加工图纸', related='workorder_id.machining_drawings', readonly=True)
|
||||||
# quality_standard = fields.Binary(related='workorder_id.quality_standard', string='质检标准', readonly=True)
|
quality_standard = fields.Binary('质检标准', related='workorder_id.quality_standard', readonly=True)
|
||||||
|
|
||||||
def submit_pass(self):
|
def submit_pass(self):
|
||||||
if self.test_results in ['返工', '报废']:
|
if self.test_results in ['返工', '报废']:
|
||||||
|
|||||||
@@ -107,10 +107,10 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="2D图纸">
|
<page string="2D图纸">
|
||||||
<!-- <field name="machining_drawings" string="" widget="pdf_viewer"/>-->
|
<field name="machining_drawings" string="" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="客户质量标准">
|
<page string="客户质量标准">
|
||||||
<!-- <field name="quality_standard" string=""/>-->
|
<field name="quality_standard" string="" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="其他" attrs="{'invisible': [('state','=', 'waiting')]}">
|
<page string="其他" attrs="{'invisible': [('state','=', 'waiting')]}">
|
||||||
<group>
|
<group>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
||||||
</field>
|
</field>
|
||||||
<field name="payment_term_id" position="after">
|
<field name="payment_term_id" position="after">
|
||||||
<field name="deadline_of_delivery" readonly="1"/>
|
<field name="deadline_of_delivery" readonly="0"/>
|
||||||
<field name="payments_way" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
<field name="payments_way" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
||||||
<field name="pay_way" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
<field name="pay_way" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
||||||
<!-- <field name="schedule_status" readonly="1"/> -->
|
<!-- <field name="schedule_status" readonly="1"/> -->
|
||||||
|
|||||||
Reference in New Issue
Block a user