Compare commits
13 Commits
feature/au
...
feature/pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5dfb50da5 | ||
|
|
1f938292f5 | ||
|
|
e73e9d6960 | ||
|
|
61339da204 | ||
|
|
745fd429c2 | ||
|
|
5c59a27a81 | ||
|
|
1467dbf88c | ||
|
|
aa1353cf99 | ||
|
|
3f84972bfd | ||
|
|
ed15958319 | ||
|
|
0b70447333 | ||
|
|
1026c0edd0 | ||
|
|
a28d20b3bf |
@@ -43,7 +43,7 @@ class WorkorderExceptionConroller(http.Controller):
|
|||||||
})
|
})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': str(e)}
|
||||||
_logger.info('workder_exception error:%s' % e)
|
_logger.info('workder_exception error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class StatusChange(models.Model):
|
|||||||
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
||||||
try:
|
try:
|
||||||
res = super(StatusChange, self).action_confirm()
|
res = super(StatusChange, self).action_confirm()
|
||||||
|
logging.info('原生方法返回结果:%s' % res)
|
||||||
# 原有方法执行后,进行额外的操作(如调用外部API)
|
# 原有方法执行后,进行额外的操作(如调用外部API)
|
||||||
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
@@ -61,6 +62,7 @@ class StatusChange(models.Model):
|
|||||||
traceback_error = traceback.format_exc()
|
traceback_error = traceback.format_exc()
|
||||||
logging.error("工厂加工同步订单状态失败:%s " % traceback_error)
|
logging.error("工厂加工同步订单状态失败:%s " % traceback_error)
|
||||||
raise UserError(e)
|
raise UserError(e)
|
||||||
|
logging.info('最终返回值:%s' % res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
<field name='is_bfm' invisible="1"/>
|
<field name='is_bfm' invisible="1"/>
|
||||||
<field name='categ_type' invisible="1"/>
|
<field name='categ_type' invisible="1"/>
|
||||||
<field name='part_number' attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
<field name='part_number' attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||||
|
<field name='machining_drawings' attrs="{'invisible': [('categ_type', '!=', '成品')]}" widget="adaptive_viewer"/>
|
||||||
|
<field name='quality_standard' attrs="{'invisible': [('categ_type', '!=', '成品')]}" widget="adaptive_viewer"/>
|
||||||
<field name='manual_quotation' attrs="{'invisible':[('upload_model_file', '=', [])]}"/>
|
<field name='manual_quotation' attrs="{'invisible':[('upload_model_file', '=', [])]}"/>
|
||||||
<field name="upload_model_file"
|
<field name="upload_model_file"
|
||||||
widget="many2many_binary"
|
widget="many2many_binary"
|
||||||
@@ -109,19 +111,6 @@
|
|||||||
'刀具')], 'required': True}
|
'刀具')], 'required': True}
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
|
||||||
<page string="2D加工图纸">
|
|
||||||
<field name='machining_drawings' attrs="{'invisible': [('categ_type', '!=', '成品')]}"
|
|
||||||
widget="adaptive_viewer"/>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
|
||||||
<page string="质检标准">
|
|
||||||
<field name='quality_standard' attrs="{'invisible': [('categ_type', '!=', '成品')]}"
|
|
||||||
widget="adaptive_viewer"/>
|
|
||||||
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
<!-- <xpath expr="//field[@name='default_code']" position="attributes">-->
|
<!-- <xpath expr="//field[@name='default_code']" position="attributes">-->
|
||||||
<!-- <attribute name="attrs">{'readonly': [('categ_type', '=', '刀具')], 'invisible':-->
|
<!-- <attribute name="attrs">{'readonly': [('categ_type', '=', '刀具')], 'invisible':-->
|
||||||
<!-- [('product_variant_count', '>' , 1)]}-->
|
<!-- [('product_variant_count', '>' , 1)]}-->
|
||||||
|
|||||||
@@ -776,8 +776,6 @@ class ResProductMo(models.Model):
|
|||||||
part_number = fields.Char(string='零件图号', readonly=True)
|
part_number = fields.Char(string='零件图号', readonly=True)
|
||||||
machining_drawings = fields.Binary('2D加工图纸', readonly=True)
|
machining_drawings = fields.Binary('2D加工图纸', readonly=True)
|
||||||
quality_standard = fields.Binary('质检标准', readonly=True)
|
quality_standard = fields.Binary('质检标准', readonly=True)
|
||||||
machining_drawings_name = fields.Char('2D加工图纸名', readonly=True)
|
|
||||||
quality_standard_name = fields.Char('质检标准名', readonly=True)
|
|
||||||
|
|
||||||
@api.constrains('tool_length')
|
@api.constrains('tool_length')
|
||||||
def _check_tool_length_size(self):
|
def _check_tool_length_size(self):
|
||||||
@@ -839,11 +837,6 @@ class ResProductMo(models.Model):
|
|||||||
else:
|
else:
|
||||||
return self.env.ref('sf_dlm.product_uom_cubic_millimeter')
|
return self.env.ref('sf_dlm.product_uom_cubic_millimeter')
|
||||||
|
|
||||||
def attachment_update(self, name, res_id, res_field):
|
|
||||||
attachment_info = self.env['ir.attachment'].sudo().search(
|
|
||||||
[('res_id', '=', res_id), ('res_field', '=', res_field)], limit=1)
|
|
||||||
attachment_info.write({'name': name})
|
|
||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||||
def product_create(self, product_id, item, order_id, order_number, i):
|
def product_create(self, product_id, item, order_id, order_number, i):
|
||||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||||
@@ -882,11 +875,8 @@ class ResProductMo(models.Model):
|
|||||||
'manual_quotation': item['manual_quotation'] or False,
|
'manual_quotation': item['manual_quotation'] or False,
|
||||||
'part_number': item.get('part_number') or '',
|
'part_number': item.get('part_number') or '',
|
||||||
'active': True,
|
'active': True,
|
||||||
'machining_drawings_name': item['machining_drawings_name'],
|
'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']),
|
||||||
'quality_standard_name': item['quality_standard_name'],
|
'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']),
|
||||||
'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(
|
|
||||||
item['machining_drawings']),
|
|
||||||
'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']),
|
|
||||||
}
|
}
|
||||||
tax_id = self.env['account.tax'].sudo().search(
|
tax_id = self.env['account.tax'].sudo().search(
|
||||||
[('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')])
|
[('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')])
|
||||||
@@ -894,12 +884,6 @@ class ResProductMo(models.Model):
|
|||||||
vals.update({'taxes_id': [(6, 0, [int(tax_id)])]})
|
vals.update({'taxes_id': [(6, 0, [int(tax_id)])]})
|
||||||
copy_product_id.sudo().write(vals)
|
copy_product_id.sudo().write(vals)
|
||||||
product_id.product_tmpl_id.active = False
|
product_id.product_tmpl_id.active = False
|
||||||
if item['machining_drawings'] and item['machining_drawings_name']:
|
|
||||||
self.attachment_update(item['machining_drawings_name'], copy_product_id.product_tmpl_id.id,
|
|
||||||
'machining_drawings')
|
|
||||||
if item['quality_standard'] and item['quality_standard_name']:
|
|
||||||
self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id,
|
|
||||||
'quality_standard')
|
|
||||||
return copy_product_id
|
return copy_product_id
|
||||||
|
|
||||||
def _get_ids(self, param):
|
def _get_ids(self, param):
|
||||||
|
|||||||
@@ -182,11 +182,6 @@ class StockRule(models.Model):
|
|||||||
moves._action_confirm()
|
moves._action_confirm()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def attachment_update(self, name, res_id, res_field):
|
|
||||||
attachment_info = self.env['ir.attachment'].sudo().search(
|
|
||||||
[('res_id', '=', res_id), ('res_field', '=', res_field)], limit=1)
|
|
||||||
attachment_info.write({'name': name})
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _run_manufacture(self, procurements):
|
def _run_manufacture(self, procurements):
|
||||||
productions_values_by_company = defaultdict(list)
|
productions_values_by_company = defaultdict(list)
|
||||||
@@ -281,12 +276,6 @@ class StockRule(models.Model):
|
|||||||
production.write({'part_number': production.product_id.part_number,
|
production.write({'part_number': production.product_id.part_number,
|
||||||
'part_drawing': production.product_id.machining_drawings,
|
'part_drawing': production.product_id.machining_drawings,
|
||||||
'quality_standard': production.product_id.quality_standard})
|
'quality_standard': production.product_id.quality_standard})
|
||||||
if production.product_id.machining_drawings and production.product_id.machining_drawings_name:
|
|
||||||
self.attachment_update(production.product_id.machining_drawings_name, production.id,
|
|
||||||
'part_drawing')
|
|
||||||
if production.product_id.quality_standard and production.product_id.quality_standard_name:
|
|
||||||
self.attachment_update(production.product_id.quality_standard_name, production.id,
|
|
||||||
'quality_standard')
|
|
||||||
if sale_order:
|
if sale_order:
|
||||||
# sale_order.write({'schedule_status': 'to schedule'})
|
# sale_order.write({'schedule_status': 'to schedule'})
|
||||||
self.env['sf.production.plan'].sudo().with_company(company_id).create({
|
self.env['sf.production.plan'].sudo().with_company(company_id).create({
|
||||||
|
|||||||
@@ -98,6 +98,8 @@
|
|||||||
<field name="production_line_id" readonly="1"/>
|
<field name="production_line_id" readonly="1"/>
|
||||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||||
<field name="part_number" string="成品的零件图号"/>
|
<field name="part_number" string="成品的零件图号"/>
|
||||||
|
<field name="part_drawing" widget="adaptive_viewer"/>
|
||||||
|
<field name="quality_standard" widget="adaptive_viewer"/>
|
||||||
<field name="tool_state"/>
|
<field name="tool_state"/>
|
||||||
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
||||||
<field name="deadline_of_delivery" readonly="1"/>
|
<field name="deadline_of_delivery" readonly="1"/>
|
||||||
@@ -328,16 +330,6 @@
|
|||||||
<xpath expr="//field[@name='components_availability']" position="attributes">
|
<xpath expr="//field[@name='components_availability']" position="attributes">
|
||||||
<attribute name="string">投料状态</attribute>
|
<attribute name="string">投料状态</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
|
||||||
<page string="零件图纸">
|
|
||||||
<field name="part_drawing" widget="adaptive_viewer"/>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
|
||||||
<page string="质检标准">
|
|
||||||
<field name="quality_standard" widget="adaptive_viewer"/>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -268,6 +268,8 @@
|
|||||||
<field name="material_height" class="o_address_zip"/>
|
<field name="material_height" class="o_address_zip"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="part_number" string="成品的零件图号"/>
|
<field name="part_number" string="成品的零件图号"/>
|
||||||
|
<field name="machining_drawings" widget="adaptive_viewer" attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||||
|
<field name="quality_standard" widget="adaptive_viewer" attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//label[1]" position="attributes">
|
<xpath expr="//label[1]" position="attributes">
|
||||||
<attribute name="string">计划加工时间</attribute>
|
<attribute name="string">计划加工时间</attribute>
|
||||||
@@ -589,18 +591,7 @@
|
|||||||
mrp.group_mrp_manager,sf_base.group_sf_mrp_manager,sf_base.group_sf_equipment_user,sf_base.group_sf_order_user
|
mrp.group_mrp_manager,sf_base.group_sf_mrp_manager,sf_base.group_sf_equipment_user,sf_base.group_sf_order_user
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
|
||||||
<page string="2D加工图纸">
|
|
||||||
<field name="machining_drawings" widget="adaptive_viewer"
|
|
||||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
|
||||||
<page string="质检标准">
|
|
||||||
<field name="quality_standard" widget="adaptive_viewer"
|
|
||||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class SFMessageSale(models.Model):
|
|||||||
purchase_order_info.add_queue('坯料采购提醒')
|
purchase_order_info.add_queue('坯料采购提醒')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('add_queue error:%s' % e)
|
logging.info('add_queue error:%s' % e)
|
||||||
|
logging.info('action_confirm res:%s' % res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||||
|
|||||||
@@ -5,24 +5,28 @@ access_jikimo_message_template_group_purchase,jikimo_message_template,jikimo_mes
|
|||||||
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_template_group_purchase_director,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_bussiness_node_group_purchase_director,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_queue_group_purchase_director,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_reminder_time_group_purchase_director,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -219,7 +219,7 @@ class sf_production_plan(models.Model):
|
|||||||
|
|
||||||
return num
|
return num
|
||||||
|
|
||||||
def do_production_schedule(self, count=1):
|
def do_production_schedule(self):
|
||||||
"""
|
"""
|
||||||
排程方法
|
排程方法
|
||||||
"""
|
"""
|
||||||
@@ -227,48 +227,46 @@ class sf_production_plan(models.Model):
|
|||||||
if not record.production_line_id:
|
if not record.production_line_id:
|
||||||
raise ValidationError("未选择生产线")
|
raise ValidationError("未选择生产线")
|
||||||
else:
|
else:
|
||||||
is_schedule = self.deal_processing_schedule(record.date_planned_start, count)
|
if record.production_id.workorder_ids:
|
||||||
if not is_schedule:
|
last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
||||||
raise ValidationError("排程失败")
|
for item in record.production_id.workorder_ids:
|
||||||
workorder_id_list = record.production_id.workorder_ids.ids
|
if item.name == 'CNC加工':
|
||||||
if record.production_id:
|
# 将同一个面的所有工单筛选出来
|
||||||
if record.production_id.workorder_ids:
|
workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
|
||||||
for item in record.production_id.workorder_ids:
|
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
if item.name == 'CNC加工':
|
[('name', '=', 'CNC加工')], limit=1)
|
||||||
item.date_planned_finished = datetime.now() + timedelta(days=100)
|
# 设置一个小的开始时间
|
||||||
item.date_planned_start = self.date_planned_start if self.date_planned_start else datetime.now()
|
item.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
item.date_planned_finished = last_cnc_start + timedelta(
|
||||||
item.date_planned_finished = item.date_planned_start + timedelta(
|
minutes=routing_workcenter.time_cycle)
|
||||||
minutes=record.env['mrp.routing.workcenter'].sudo().search(
|
item.date_planned_start = last_cnc_start
|
||||||
[('name', '=', 'CNC加工')]).time_cycle)
|
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||||
item.duration_expected = record.env['mrp.routing.workcenter'].sudo().search(
|
item.duration_expected = routing_workcenter.time_cycle
|
||||||
[('name', '=', 'CNC加工')]).time_cycle
|
pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
|
||||||
record.calculate_plan_time_before(item, workorder_id_list)
|
record.date_planned_finished = item.date_planned_finished
|
||||||
record.calculate_plan_time_after(item, workorder_id_list)
|
# 计算下一个cnc工单的开始时间
|
||||||
record.date_planned_start, record.date_planned_finished = \
|
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
|
||||||
item.date_planned_start, item.date_planned_finished
|
# 没有工单也能排程
|
||||||
record.state = 'done'
|
record.state = 'done'
|
||||||
record.date_planned_finished = record.date_planned_start + timedelta(
|
# record.production_id.schedule_state = '已排'
|
||||||
minutes=60) if not record.date_planned_finished else record.date_planned_finished
|
record.sudo().production_id.schedule_state = '已排'
|
||||||
# record.production_id.schedule_state = '已排'
|
record.sudo().production_id.process_state = '待装夹'
|
||||||
record.sudo().production_id.schedule_state = '已排'
|
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process'
|
||||||
record.sudo().production_id.process_state = '待装夹'
|
# sale_obj = self.env['sale.order'].search([('name', '=', record.origin)])
|
||||||
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process'
|
# if 'S' in sale_obj.name:
|
||||||
# sale_obj = self.env['sale.order'].search([('name', '=', record.origin)])
|
# sale_obj.schedule_status = 'to process'
|
||||||
# if 'S' in sale_obj.name:
|
mrp_production_ids = record.production_id._get_children().ids
|
||||||
# sale_obj.schedule_status = 'to process'
|
print('mrp_production_ids', mrp_production_ids)
|
||||||
mrp_production_ids = record.production_id._get_children().ids
|
for i in mrp_production_ids:
|
||||||
print('mrp_production_ids', mrp_production_ids)
|
record.env['mrp.production'].sudo().browse(i).schedule_state = '已排'
|
||||||
for i in mrp_production_ids:
|
# record.production_id.date_planned_start = record.date_planned_start
|
||||||
record.env['mrp.production'].sudo().browse(i).schedule_state = '已排'
|
# record.production_id.date_planned_finished = record.date_planned_finished
|
||||||
# record.production_id.date_planned_start = record.date_planned_start
|
record.sudo().production_id.production_line_id = record.production_line_id.id
|
||||||
# record.production_id.date_planned_finished = record.date_planned_finished
|
if record.production_id.workorder_ids:
|
||||||
record.sudo().production_id.production_line_id = record.production_line_id.id
|
record.sudo().production_id.workorder_ids.filtered(
|
||||||
if record.production_id.workorder_ids:
|
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
|
||||||
record.sudo().production_id.workorder_ids.filtered(
|
{'production_line_id': record.production_line_id.id,
|
||||||
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
|
'plan_start_processing_time': record.date_planned_start})
|
||||||
{'production_line_id': record.production_line_id.id,
|
|
||||||
'plan_start_processing_time': record.date_planned_start})
|
|
||||||
|
|
||||||
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)
|
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)
|
||||||
# record.state = 'done'
|
# record.state = 'done'
|
||||||
@@ -282,54 +280,66 @@ class sf_production_plan(models.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 处理是否可排程
|
# 处理是否可排程
|
||||||
def deal_processing_schedule(self, date_planned_start, count):
|
def deal_processing_schedule(self, date_planned_start,):
|
||||||
for record in self:
|
count = len(self)
|
||||||
workcenter_ids = record.production_line_id.mrp_workcenter_ids
|
workcenter_ids = self.production_line_id.mrp_workcenter_ids
|
||||||
if not workcenter_ids:
|
if not workcenter_ids:
|
||||||
raise UserError('生产线没有配置工作中心')
|
raise UserError('生产线没有配置工作中心')
|
||||||
production_lines = workcenter_ids.filtered(lambda b: "自动生产线" in b.name)
|
production_lines = workcenter_ids.filtered(lambda b: "自动生产线" in b.name)
|
||||||
if not production_lines: # 判断是否配置了自动生产线
|
if not production_lines: # 判断是否配置了自动生产线
|
||||||
raise UserError('生产线没有配置自动生产线')
|
raise UserError('生产线没有配置自动生产线')
|
||||||
if date_planned_start < datetime.now(): # 判断计划开始时间是否小于当前时间
|
if date_planned_start < datetime.now(): # 判断计划开始时间是否小于当前时间
|
||||||
raise UserError('计划开始时间不能小于当前时间')
|
raise UserError('计划开始时间不能小于当前时间')
|
||||||
if all(not production_line.deal_with_workcenter_calendar(date_planned_start) for production_line in
|
if all(not production_line.deal_with_workcenter_calendar(date_planned_start) for production_line in
|
||||||
production_lines): # 判断计划开始时间是否在配置的工作中心的工作日历内
|
production_lines): # 判断计划开始时间是否在配置的工作中心的工作日历内
|
||||||
raise UserError('当前计划开始时间不能预约排程,请在工作时间内排程')
|
raise UserError('当前计划开始时间不能预约排程,请在工作时间内排程')
|
||||||
if not production_lines.deal_available_default_capacity(date_planned_start): # 判断生产线是否可排程
|
if not production_lines.deal_available_default_capacity(date_planned_start): # 判断生产线是否可排程
|
||||||
raise UserError('当前计划开始时间不能预约排程,生产线今日没有可排程的资源')
|
raise UserError('当前计划开始时间不能预约排程,生产线今日没有可排程的资源')
|
||||||
if not production_lines.deal_available_single_machine_capacity(date_planned_start, count): # 判断生产线是否可排程
|
if not production_lines.deal_available_single_machine_capacity(date_planned_start, count): # 判断生产线是否可排程
|
||||||
raise UserError('当前计划开始时间不能预约排程,生产线该时间段没有可排程的资源')
|
raise UserError('当前计划开始时间不能预约排程,生产线该时间段没有可排程的资源')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def calculate_plan_time_before(self, item, workorder_id_list):
|
def calculate_plan_time(self, item, workorder_list):
|
||||||
"""
|
"""
|
||||||
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
||||||
"""
|
"""
|
||||||
sequence = workorder_id_list.index(item.id) - 1
|
item_position = 0
|
||||||
# 计算CNC加工之前工单的开始结束时间
|
for index, workorder in enumerate(workorder_list):
|
||||||
for i in range(1 if sequence == 0 else sequence):
|
if workorder.id == item.id:
|
||||||
current_workorder_id = (item.id - (i + 1))
|
item_position = index
|
||||||
current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
break
|
||||||
[('id', '=', current_workorder_id)])
|
routing_workcenters = self.env['mrp.routing.workcenter'].sudo().search([])
|
||||||
old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
# 记录所有前序工序时长
|
||||||
[('id', '=', (current_workorder_id + 1))])
|
previous_workorder_duration = 0
|
||||||
work_order = self.env['mrp.workorder'].sudo().search(
|
for i in range(item_position, -1, -1):
|
||||||
[('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
if i < 1:
|
||||||
work_order.date_planned_finished = datetime.now() + timedelta(days=100)
|
break
|
||||||
work_order.date_planned_start = old_workorder_obj.date_planned_start - timedelta(
|
current_workorder = workorder_list[i]
|
||||||
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
next_workorder = workorder_list[i - 1]
|
||||||
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
||||||
work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
# 设置一个小的开始时间
|
||||||
work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
[('name', '=', current_workorder_obj.name)]).time_cycle
|
next_workorder.date_planned_finished = current_workorder.date_planned_start
|
||||||
first_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id_list[0])])
|
next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta(
|
||||||
second_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id_list[1])])
|
minutes=routing_workcenter.time_cycle)
|
||||||
if second_workorder.date_planned_start < first_workorder.date_planned_finished:
|
next_workorder.duration_expected = routing_workcenter.time_cycle
|
||||||
item.date_planned_start += timedelta(minutes=60)
|
previous_workorder_duration += routing_workcenter.time_cycle
|
||||||
item.date_planned_finished += timedelta(minutes=60)
|
# 记录所有后续工序时长
|
||||||
item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
next_workorder_duration = 0
|
||||||
[('name', '=', 'CNC加工')]).time_cycle
|
for i in range(item_position, len(workorder_list) - 1):
|
||||||
self.calculate_plan_time_before(item, workorder_id_list)
|
if i > len(workorder_list) - 1:
|
||||||
|
break
|
||||||
|
current_workorder = workorder_list[i]
|
||||||
|
next_workorder = workorder_list[i + 1]
|
||||||
|
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
||||||
|
# 设置一个小的开始时间
|
||||||
|
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
|
next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta(
|
||||||
|
minutes=routing_workcenter.time_cycle)
|
||||||
|
next_workorder.date_planned_start = current_workorder.date_planned_finished
|
||||||
|
next_workorder.duration_expected = routing_workcenter.time_cycle
|
||||||
|
next_workorder_duration += routing_workcenter.time_cycle
|
||||||
|
return previous_workorder_duration, next_workorder_duration
|
||||||
|
|
||||||
def calculate_plan_time_after(self, item, workorder_id_list):
|
def calculate_plan_time_after(self, item, workorder_id_list):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -31,46 +31,10 @@ class Action_Plan_All_Wizard(models.TransientModel):
|
|||||||
# 确认排程按钮
|
# 确认排程按钮
|
||||||
def action_plan_all(self):
|
def action_plan_all(self):
|
||||||
# 使用传递过来的计划ID
|
# 使用传递过来的计划ID
|
||||||
temp_plan_ids = self.plan_ids
|
self.plan_ids.production_line_id = self.production_line_id.id
|
||||||
|
self.plan_ids.date_planned_start = self.date_planned_start
|
||||||
# 在这里添加您的逻辑来处理这些ID
|
# 在这里添加您的逻辑来处理这些ID
|
||||||
count = len(temp_plan_ids) + 1
|
# 判断能否排成
|
||||||
for plan in temp_plan_ids:
|
self.plan_ids.deal_processing_schedule(self.date_planned_start)
|
||||||
count = count - 1
|
self.plan_ids.do_production_schedule()
|
||||||
# 处理每个计划
|
_logger.info('处理计划: %s 完成', self.plan_ids.ids)
|
||||||
# 比如更新计划状态、分配资源等
|
|
||||||
# 示例:plan.state = 'scheduled'
|
|
||||||
print('处理计划:', plan.id)
|
|
||||||
# 拿到计划对象
|
|
||||||
plan_obj = self.env['sf.production.plan'].browse(plan.id)
|
|
||||||
plan_obj.production_line_id = self.production_line_id.id
|
|
||||||
plan.date_planned_start = self.date_planned_start
|
|
||||||
plan_obj.do_production_schedule(count)
|
|
||||||
# plan_obj.state = 'done'
|
|
||||||
print('处理计划:', plan.id, '完成')
|
|
||||||
|
|
||||||
# # 获取当前生产线
|
|
||||||
# production_line_id = self.production_line_id
|
|
||||||
# # 获取当前生产线的所有生产订单
|
|
||||||
# production_order_ids = self.env['mrp.production'].search([('production_line_id', '=', production_line_id.id)])
|
|
||||||
# # 获取当前生产线的所有生产订单的id
|
|
||||||
# production_order_id_list = []
|
|
||||||
# for production_order_id in production_order_ids:
|
|
||||||
# production_order_id_list.append(production_order_id.id)
|
|
||||||
# # 获取当前生产线的所有生产订单的排程状态
|
|
||||||
# production_order_plan_state_list = []
|
|
||||||
# for production_order_id in production_order_ids:
|
|
||||||
# production_order_plan_state_list.append(production_order_id.plan_state)
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已排程,则报错
|
|
||||||
# if all(production_order_plan_state == '已排程' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已排程,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是未排程,则报错
|
|
||||||
# if all(production_order_plan_state == '未排程' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都未排程,请先排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错
|
|
||||||
# if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错
|
|
||||||
# if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错
|
|
||||||
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
{
|
{
|
||||||
'name': "sf_stock",
|
'name': "机企猫 库存/代发货",
|
||||||
|
|
||||||
'summary': """
|
'summary': """
|
||||||
处理仓库 -代发货业务""",
|
处理仓库 -代发货业务""",
|
||||||
|
|||||||
Reference in New Issue
Block a user