Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug
# Conflicts: # sf_manufacturing/models/product_template.py
This commit is contained in:
@@ -17,9 +17,32 @@ class MrpProduction(models.Model):
|
||||
maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests")
|
||||
request_ids = fields.One2many('maintenance.request', 'production_id')
|
||||
model_file = fields.Binary('模型文件', related='product_id.model_file')
|
||||
schedule_state = fields.Selection([('未排', '未排'), ('已排', '已排')],
|
||||
schedule_state = fields.Selection([('未排', '未排'), ('已排', '已排'), ('已完成', '已完成')],
|
||||
string='排程状态', default='未排')
|
||||
|
||||
# state = fields.Selection(selection_add=[
|
||||
# ('pending_scheduling', '待排程'),
|
||||
# ('pending_processing', '待加工'),
|
||||
# ('completed', '已完工')
|
||||
# ])
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('confirmed', 'Confirmed'),
|
||||
('progress', '待排程'),
|
||||
('pending_processing', '待加工'),
|
||||
('completed', '已完工'),
|
||||
('to_close', 'To Close'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')], string='State',
|
||||
compute='_compute_state', copy=False, index=True, readonly=True,
|
||||
store=True, tracking=True,
|
||||
help=" * Draft: The MO is not confirmed yet.\n"
|
||||
" * Confirmed: The MO is confirmed, the stock rules and the reordering of the components are trigerred.\n"
|
||||
" * In Progress: The production has started (on the MO or on the WO).\n"
|
||||
" * To Close: The production is done, the MO has to be closed.\n"
|
||||
" * Done: The MO is closed, the stock moves are posted. \n"
|
||||
" * Cancelled: The MO has been cancelled, can't be confirmed anymore.")
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
programming_no = fields.Char('编程单号')
|
||||
@@ -27,6 +50,45 @@ class MrpProduction(models.Model):
|
||||
programming_state = fields.Char('编程状态')
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
|
||||
@api.depends(
|
||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
|
||||
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
|
||||
def _compute_state(self):
|
||||
for production in self:
|
||||
if not production.state or not production.product_uom_id:
|
||||
production.state = 'draft'
|
||||
elif production.state == 'cancel' or (production.move_finished_ids and all(
|
||||
move.state == 'cancel' for move in production.move_finished_ids)):
|
||||
production.state = 'cancel'
|
||||
elif (
|
||||
production.state == 'done'
|
||||
or (production.move_raw_ids and all(
|
||||
move.state in ('cancel', 'done') for move in production.move_raw_ids))
|
||||
and all(move.state in ('cancel', 'done') for move in production.move_finished_ids)
|
||||
):
|
||||
production.state = 'done'
|
||||
elif production.workorder_ids and all(
|
||||
wo_state in ('done', 'cancel') for wo_state in production.workorder_ids.mapped('state')):
|
||||
production.state = 'to_close'
|
||||
elif not production.workorder_ids and float_compare(production.qty_producing, production.product_qty,
|
||||
precision_rounding=production.product_uom_id.rounding) >= 0:
|
||||
production.state = 'to_close'
|
||||
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
|
||||
production.state = 'progress'
|
||||
elif production.product_uom_id and not float_is_zero(production.qty_producing,
|
||||
precision_rounding=production.product_uom_id.rounding):
|
||||
production.state = 'progress'
|
||||
elif any(not float_is_zero(move.quantity_done,
|
||||
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
|
||||
for move in production.move_raw_ids):
|
||||
production.state = 'progress'
|
||||
|
||||
# 新添加的状态逻辑
|
||||
if production.state == 'progress' and production.schedule_state == '已排':
|
||||
production.state = 'pending_processing'
|
||||
elif production.state == 'progress' and production.schedule_state == '已完成':
|
||||
production.state = 'completed'
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
|
||||
@@ -62,7 +62,6 @@ class ResProductMo(models.Model):
|
||||
tool_thickness = fields.Float('厚度(mm)')
|
||||
tool_weight = fields.Float('重量(kg)')
|
||||
tool_hardness = fields.Integer('硬度(hrc)')
|
||||
|
||||
coating_material = fields.Char('涂层材质')
|
||||
# 整体式刀具特有字段
|
||||
cutting_tool_total_length = fields.Float('总长度(mm)', digits=(6, 1))
|
||||
@@ -263,7 +262,18 @@ class ResProductMo(models.Model):
|
||||
self.cutting_tool_rear_angle = self.specification_id.relief_angle
|
||||
self.cutting_tool_main_included_angle = self.specification_id.main_included_angle
|
||||
self.cutting_tool_top_angle = self.specification_id.top_angle
|
||||
|
||||
self.cutting_tool_blade_tip_dip_angle = self.specification_id.blade_tip_dip_angle
|
||||
|
||||
self.cutting_tool_screw = self.specification_id.screw
|
||||
self.cutting_tool_wrench = self.specification_id.wrench
|
||||
self.cutting_tool_blade_id = self.specification_id.blade_id.id
|
||||
self.cutting_tool_is_cooling_hole = self.specification_id.is_cooling_hole
|
||||
self.cutting_tool_locating_slot_code = self.specification_id.locating_slot_code
|
||||
self.cutting_tool_install_blade_tip_num = self.specification_id.install_blade_tip_num
|
||||
self.cutting_tool_installing_structure = self.specification_id.installing_structure
|
||||
self.cutting_tool_cut_depth_max = self.specification_id.cut_depth_max
|
||||
|
||||
if self.cutting_tool_type == '刀盘':
|
||||
self.cutting_tool_blade_length = self.specification_id.blade_length
|
||||
self.cutting_tool_cutter_head_diameter = self.specification_id.cutter_head_diameter
|
||||
|
||||
Reference in New Issue
Block a user