Merge branch develop into feature/优化代码:工单显示机床信息等

This commit is contained in:
马广威
2023-01-31 10:42:32 +08:00
21 changed files with 312 additions and 241 deletions

View File

@@ -23,13 +23,11 @@ class Sf_Bf_Connect(http.Controller):
# ret = json.loads(datas)
# ret = json.loads(ret['result'])
product_id = request.env.ref('sf_dlm.product_template_sf').sudo()
logging.info('product_id:%s' % product_id)
self_machining_id = request.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
outsource_id = request.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
purchase_id = request.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
company_id = request.env.ref('base.main_company').sudo()
user_id = request.env.ref('base.user_admin').sudo()
logging.info('user_id:%s' % user_id)
bfm_process_order_list = json.loads(kw['bfm_process_order_list'])
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],

View File

@@ -25,5 +25,4 @@ class ResPartner(models.Model):
return ran_str
sf_token = fields.Char(u'Token', default=get_token)
sf_secret_key = fields.Char(u'密钥', default=get_secret)
sf_secret_key = fields.Char(u'密钥', default=get_secret)

View File

@@ -45,7 +45,6 @@
<field name="company_id" ref="base.main_company"/>
<field name="single_manufacturing">true</field>
<field name="tracking">serial</field>
<!-- <field name="active" eval="False"/>-->
</record>
<record id="product_embryo_sf_outsource" model="product.product">
@@ -61,7 +60,6 @@
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="tracking">serial</field>
<!-- <field name="active" eval="False"/>-->
</record>
<record id="product_embryo_sf_purchase" model="product.product">
<field name="name">胚料采购模板</field>
@@ -76,7 +74,6 @@
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="tracking">serial</field>
<!-- <field name="active" eval="False"/>-->
</record>
</data>
</odoo>

View File

@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="1">
<record id="product_template_sf" model="product.product">
<field name="name">CNC加工产品模板</field>
<!-- <field name="categ_id" ref="product.product_category_5"/>-->
<field name="invoice_policy">delivery</field>
<field name="detailed_type">product</field>
<field name="purchase_ok">false</field>
<field name="uom_id" ref="uom.product_uom_unit"/>
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="active">False</field>
</record>
<record id="product_category_embryo_sf" model="product.category">
<field name="name">胚料</field>
<field name="type">胚料</field>
</record>
<record id="product_embryo_sf_self_machining" model="product.product">
<field name="name">自加工</field>
<!-- <field name="categ_id" ref="product_category_embryo_sf"/>-->
<field name="invoice_policy">delivery</field>
<field name="detailed_type">product</field>
<field name="purchase_ok">false</field>
<field name="uom_id" ref="uom.product_uom_unit"/>
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="active">False</field>
</record>
<record id="product_embryo_sf_outsource" model="product.product">
<field name="name">外协</field>
<!-- <field name="categ_id" ref="product_category_embryo_sf"/>-->
<field name="invoice_policy">delivery</field>
<field name="detailed_type">product</field>
<field name="purchase_ok">false</field>
<field name="uom_id" ref="uom.product_uom_unit"/>
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="active">False</field>
</record>
<record id="product_embryo_sf_purchase" model="product.product">
<field name="name">采购</field>
<!-- <field name="categ_id" ref="product_category_embryo_sf"/>-->
<field name="invoice_policy">delivery</field>
<field name="detailed_type">product</field>
<field name="purchase_ok">false</field>
<field name="uom_id" ref="uom.product_uom_unit"/>
<field name="uom_po_id" ref="uom.product_uom_unit"/>
<field name="company_id" ref="base.main_company"/>
<field name="active">False</field>
</record>
</data>
</odoo>

View File

@@ -1,3 +1,5 @@
from. import product_template
from. import product_supplierinfo

View File

@@ -0,0 +1,11 @@
from odoo import models, fields, api
class ResSupplierInfo(models.Model):
_inherit = 'product.supplierinfo'
def _compute_is_subcontractor(self):
for supplier in self:
boms = supplier.product_id.variant_bom_ids
boms |= supplier.product_tmpl_id.bom_ids.filtered(lambda b: not b.product_id or b.product_id in (supplier.product_id or supplier.product_tmpl_id.product_variant_ids))
supplier.is_subcontractor = supplier.partner_id in boms.subcontractor_id

View File

@@ -22,7 +22,8 @@ class ResProductTemplate(models.Model):
('0.03', '±0.03mm'),
('0.02', '±0.02mm'),
('0.01', '±0.01mm')], string='加工精度')
model_type_id = fields.Many2one('sf.model.type', string='模型类型')
product_model_type_id = fields.Many2one('sf.model.type', string='产品模型类型')
embryo_model_type_id = fields.Many2one('sf.model.type', string='胚料模型类型')
model_processing_panel = fields.Char('模型加工面板')
model_surface_process_id = fields.Many2one('sf.production.process', string='表面工艺')
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
@@ -36,6 +37,7 @@ class ResProductTemplate(models.Model):
single_manufacturing = fields.Boolean(string="单个制造")
upload_model_file = fields.Many2many('ir.attachment', 'upload_model_file_attachment_ref', string='上传模型文件')
model_code = fields.Char('模型编码')
is_bfm = fields.Boolean('业务平台是否自动创建', default=False)
def _get_volume_uom_id_from_ir_config_parameter(self):
product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet')
@@ -73,16 +75,16 @@ class ResProductTemplate(models.Model):
model_type = self.env['sf.model.type'].search([], limit=1)
attachment = self.attachment_create(item['model_name'], item['model_data'])
vals = {
'name': '%s-%s' % (order_id.name, i),
'name': '%s-%s-%s' % ('P', order_id.name, i),
'model_long': item['model_long'] + model_type.embryo_tolerance,
'model_width': item['model_width'] + model_type.embryo_tolerance,
'model_height': item['model_height'] + model_type.embryo_tolerance,
'model_volume': (item['model_long'] + model_type.embryo_tolerance) * (
item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance),
'model_type_id': model_type.id,
'product_model_type_id': model_type.id,
'model_processing_panel': 'R',
'model_machining_precision': item['model_machining_precision'],
'model_machining_precision': item['model_machining_precision'],
'model_code': item['barcode'],
'length': item['model_long'],
'width': item['model_width'],
@@ -92,7 +94,7 @@ class ResProductTemplate(models.Model):
'model_name': attachment.name,
'upload_model_file': [(6, 0, [attachment.id])],
# 'single_manufacturing': True,
'tracking': 'serial',
# 'tracking': 'serial',
'list_price': item['price'],
# 'categ_id': self.env.ref('sf_dlm.product_category_finished_sf').id,
'materials_id': self.env['sf.production.materials'].search(
@@ -135,20 +137,22 @@ class ResProductTemplate(models.Model):
supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
vals = {
'name': '%s-%s %s %s %s * %s * %s' % (
order_id.name, i, materials_id.name, materials_type_id.name,
item['model_long'] + model_type.embryo_tolerance, item['model_width'] + model_type.embryo_tolerance,
item['model_height'] + model_type.embryo_tolerance),
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
order_id.name, i, materials_id.name, materials_type_id.name,
item['model_long'] + model_type.embryo_tolerance,
item['model_width'] + model_type.embryo_tolerance,
item['model_height'] + model_type.embryo_tolerance),
'length': item['model_long'] + model_type.embryo_tolerance,
'width': item['model_width'] + model_type.embryo_tolerance,
'height': item['model_height'] + model_type.embryo_tolerance,
'volume': (item['model_long'] + model_type.embryo_tolerance) * (
item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance),
# 'model_price': item['price'],
'embryo_model_type_id': model_type.id,
'list_price': item['price'],
'materials_id': materials_id.id,
'materials_type_id': materials_type_id.id,
'is_bfm': True,
# 'route_ids': self._get_routes(route_type),
# 'categ_id': self.env.ref('sf_dlm.product_category_embryo_sf').id,
# 'model_surface_process_id': self.env['sf.production.process'].search(
@@ -158,14 +162,13 @@ class ResProductTemplate(models.Model):
'active': True
}
# 外协和采购生成的胚料需要根据材料型号绑定供应商
if route_type == 'subcontract':
no_bom_copy_product_id.purchase_ok = True
no_bom_copy_product_id.seller_ids = [
(0, 0, {'partner_id': supplier.partner_id.id, 'delay': 1.0, 'is_subcontractor': True})]
elif route_type == 'purchase':
if route_type == 'subcontract' or route_type == 'purchase':
no_bom_copy_product_id.purchase_ok = True
no_bom_copy_product_id.seller_ids = [
(0, 0, {'partner_id': supplier.partner_id.id, 'delay': 1.0})]
if route_type == 'subcontract':
partner = self.env['res.partner'].search([('id', '=', supplier.partner_id.id)])
partner.is_subcontractor = True
no_bom_copy_product_id.write(vals)
logging.info('no_bom_copy_product_id-vals:%s' % vals)
# product_id.product_tmpl_id.active = False
@@ -209,7 +212,6 @@ class ResMrpBom(models.Model):
'product_qty': 1,
'product_uom_id': 1
}
logging.info('bom_create_line_has-vals:%s' % vals)
return self.env['mrp.bom.line'].create(vals)
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
@@ -224,7 +226,6 @@ class ResMrpBom(models.Model):
if bom_type == 'subcontract' and product_type != False:
subcontract = self.get_supplier(product.materials_type_id)
bom_id.subcontractor_id = subcontract.partner_id.id
logging.info('bom_create-vals:%s' % bom_id)
return bom_id
# 胚料BOM组件选取当前胚料原材料
@@ -240,7 +241,6 @@ class ResMrpBom(models.Model):
'product_qty': bom_line.volume * bom_line.materials_type_id.density * 1000,
'product_uom_id': bom_line.uom_id.id
}
logging.info('bom_create_line-vals1:%s' % vals)
return self.env['mrp.bom.line'].create(vals)
# 查询材料型号默认排第一的供应商
@@ -249,7 +249,6 @@ class ResMrpBom(models.Model):
[('materials_model_id', '=', materials_type.id)],
limit=1,
order='sequence asc')
logging.info('get_supplier-vals:%s' % seller_id)
return seller_id
# 匹配bom
@@ -257,7 +256,7 @@ class ResMrpBom(models.Model):
embryo_has = self.env['product.product'].search(
[('categ_id.type', '=', '胚料'), ('materials_type_id', '=', product.materials_type_id.id),
('length', '>', product.length), ('width', '>', product.width),
('height', '>', product.height)
('height', '>', product.height), ('is_bfm', '=', False)
],
limit=1,
order='volume desc'

View File

@@ -6,13 +6,14 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<!-- <field name="image_1920" position="replace">-->
<!-- <field name="upload_model_file" required="True"-->
<!-- widget='many2many_binary'/>-->
<!-- </field>-->
<!-- <field name="image_1920" position="replace">-->
<!-- <field name="upload_model_file" required="True"-->
<!-- widget='many2many_binary'/>-->
<!-- </field>-->
<field name="invoice_policy" position="after">
<field name="model_file" required="True" widget="model_viewer"/>
<!-- <field name="model_file" widget="model_viewer" attrs="{'invisible': [('categ_id', 'child_of', '成品')]}"/>-->
<field name="embryo_model_type_id"/>
<field name="materials_id" string="材料"/>
<field name="materials_type_id" string="型号"
domain="[('materials_id', '=', materials_id)]"/>
@@ -36,18 +37,31 @@
<xpath expr="//page[last()]" position="after">
<page string="加工参数">
<group string="模型">
<field name="model_long" string="长[mm]"/>
<field name="model_width" string="[mm]"/>
<field name="model_height" string="高[mm]"/>
<field name="model_volume" string="体积[m³]"/>
<field name="model_type_id" string="模型类型"/>
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
<field name="model_machining_precision"/>
<field name="model_surface_process_id" string="表面工艺"/>
<field name="model_process_parameters_id" string="工艺参数"
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
<field name="model_remark" string="备注说明"/>
<group>
<group string="模型">
<label for="model_long" string="尺寸[mm]"/>
<div class="o_address_format">
<label for="model_long" string=""/>
<field name="model_long" class="o_address_zip"/>
<!-- <span>&amp;nbsp;</span>-->
<label for="model_width" string="宽"/>
<field name="model_width" class="o_address_zip"/>
<!-- <span>&amp;nbsp;</span>-->
<label for="model_height" string="高"/>
<field name="model_height" class="o_address_zip"/>
</div>
<!-- <field name="model_long" string="长[mm]"/>-->
<!-- <field name="model_width" string="宽[mm]"/>-->
<!-- <field name="model_height" string="高[mm]"/>-->
<field name="model_volume" string="体积[mm³]"/>
<field name="product_model_type_id" string="模型类型"/>
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
<field name="model_machining_precision"/>
<field name="model_surface_process_id" string="表面工艺"/>
<field name="model_process_parameters_id" string="工艺参数"
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
<field name="model_remark" string="备注说明"/>
</group>
</group>
</page>
</xpath>
@@ -71,8 +85,6 @@
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='operations']" position="inside">
<group>
</group>
<group string="订单规则">
<field name="single_manufacturing" string="单个制造" widget="checkbox"/>
</group>
@@ -112,5 +124,19 @@
</field>
</field>
</record>
<record id="product_template_search_view_sf" model="ir.ui.view">
<field name="name">product.template.search</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<xpath expr="//filter[@name='consumable']" position="after">
<separator/>
<filter name="finish_product" string="成品" domain="[('categ_id.type','=','成品')]"/>
<filter name="embryo" string="胚料" domain="[('categ_id.type','=','胚料')]"/>
<filter name="raw_bom" string="原材料" domain="[('categ_id.type','=','原材料')]"/>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -7,7 +7,7 @@
<field name="arch" type="xml">
<xpath expr="//page[last()-3]" position="before">
<page string="机床信息" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<group string="基本信息">
<group string="机床信息">
<field name="machine_tool_name"/>
<field name="machine_tool_type_id"/>
<field name="machine_tool_machine_ip"/>

View File

@@ -6,13 +6,16 @@ class ModelType(models.Model):
_description = '模型类型'
name = fields.Char('名称')
embryo_tolerance = fields.Boolean('胚料容余', default=False)
routing_tmpl_ids = fields.One2many('sf.model.type.routing.sort', 'model_type_id', '工序模板')
embryo_tolerance = fields.Integer('胚料容余')
product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id',
'成品工序模板')
embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id',
'胚料工序模板')
class ModelTypeRoutingSort(models.Model):
_name = 'sf.model.type.routing.sort'
_description = '工序排序'
class ProductModelTypeRoutingSort(models.Model):
_name = 'sf.product.model.type.routing.sort'
_description = '成品工序排序'
sequence = fields.Integer('Sequence')
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
@@ -23,11 +26,34 @@ class ModelTypeRoutingSort(models.Model):
('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('解除装夹', '解除装夹'), ('切割', '切割')
], string="工序类型", related='route_workcenter_id.routing_type')
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
model_type_id = fields.Many2one('sf.model.type')
product_model_type_id = fields.Many2one('sf.model.type')
_sql_constraints = [
('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
('route_model_type_uniq', 'unique (route_workcenter_id,product_model_type_id)', '成品工序不能重复!')
]
class EmbryoModelTypeRoutingSort(models.Model):
_name = 'sf.embryo.model.type.routing.sort'
_description = '胚料工序排序'
sequence = fields.Integer('Sequence')
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
routing_type = fields.Selection([
('获取CNC加工程序', '获取CNC加工程序'),
('装夹', '装夹'),
('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'), ('切割', '切割')
], string="工序类型", related='route_workcenter_id.routing_type')
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
embryo_model_type_id = fields.Many2one('sf.model.type')
_sql_constraints = [
('route_model_type_uniq', 'unique (route_workcenter_id,embryo_model_type_id)', '胚料工序不能重复!')
]

View File

@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models,_
from odoo import api, fields, models, _
class resProduct(models.Model):
_inherit = 'product.template'
model_file = fields.Binary('模型文件')
class MrpProduction(models.Model):
_inherit = 'mrp.production'
_description = "制造订单"
@@ -102,25 +103,34 @@ class MrpProduction(models.Model):
'operation_id': operation.id,
'state': 'pending',
}]
# 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
for k in (production.product_id.model_processing_panel.split(',')):
routingworkcenter = self.env['sf.model.type.routing.sort'].search(
[('model_type_id', '=', production.product_id.model_type_id.id)],
if production.product_id.categ_id.type == '成品':
# 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
for k in (production.product_id.model_processing_panel.split(',')):
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
[('product_model_type_id', '=', production.product_id.product_model_type_id.id)],
order='sequence asc'
)
i += 1
for route in product_routing_workcenter:
if i == 1 and route.routing_type == '获取CNC加工程序':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route))
if route.is_repeat == True:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
if i == processing_panel_len and route.routing_type == '解除装夹':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
elif production.product_id.categ_id.type == '胚料':
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
[('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
order='sequence asc'
)
i += 1
for route in routingworkcenter:
if i == 1 and route.routing_type == '获取CNC加工程序':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route))
if route.is_repeat == True:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
if i == processing_panel_len and route.routing_type == '解除装夹':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
for route in embryo_routing_workcenter:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route))
production.workorder_ids = workorders_values
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
@@ -181,7 +191,7 @@ class MrpProduction(models.Model):
'operation_id': operation.id,
'state': 'pending',
}]
# 根据加工面板的面数及对应的工序模板生成工单
# 根据加工面板的面数及对应的成品工序模板生成工单
i = 0
production.product_id.model_processing_panel = k
processing_panel_len = len(k)

View File

@@ -11,6 +11,7 @@ class ResMrpRoutingWorkcenter(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('切割', '切割')
], string="工序类型")
is_repeat = fields.Boolean('重复', default=False)
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
@@ -38,26 +39,3 @@ class ResMrpRoutingWorkcenter(models.Model):
in %s group by workcenter_id
order by count(*),workcenter_id asc limit 1 """, [tuple(workcenter_ids)])
return self.env.cr.dictfetchall()[0].get('workcenter_id')
# class ModelTypeRoutingSort(models.Model):
# _name = 'sf.model.type.routing.sort'
# _description = '工序排序'
#
# sequence = fields.Integer('Sequence')
# route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
# is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
# routing_type = fields.Selection([
# ('获取CNC加工程序', '获取CNC加工程序'),
# ('装夹', '装夹'),
# ('前置三元定位检测', '前置三元定位检测'),
# ('CNC加工', 'CNC加工'),
# ('后置三元质量检测', '后置三元质量检测'),
# ('解除装夹', '解除装夹'),
# ], string="工序类型", related='route_workcenter_id.routing_type')
# workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
# model_type_id = fields.Many2one('sf.model.type')
#
# _sql_constraints = [
# ('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
# ]

View File

@@ -13,6 +13,24 @@ class ResWorkcenter(models.Model):
'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment",
check_company=True)
@api.onchange('machine_tool_id')
def update_machine_tool_is_binding(self):
machine_tool = self.env["sf.machine_tool"].search([('is_binding', '=', True)])
if machine_tool:
for item in machine_tool:
workcenter_machine_tool = self.env["mrp.workcenter"].search([('machine_tool_id', '=', item.id)])
if workcenter_machine_tool:
if self.machine_tool_id.id:
if workcenter_machine_tool.id != self.machine_tool_id.id:
self.machine_tool_id.is_binding = True
else:
self.machine_tool_id.is_binding = True
else:
self.machine_tool_id.is_binding = True
item.is_binding = False
else:
self.machine_tool_id.is_binding = True
def action_work_order(self):
if not self.env.context.get('desktop_list_view', False):
action = self.env["ir.actions.actions"]._for_xml_id("sf_manufacturing.mrp_workorder_action_tablet")

View File

@@ -29,6 +29,7 @@ class ResMrpWorkOrder(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('切割', '切割')
], string="工序类型")
@api.onchange('users_ids')
@@ -89,7 +90,6 @@ class ResMrpWorkOrder(models.Model):
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工")
tray_code = fields.Char(string="托盘")
# 计算配料中心点和与x轴倾斜度方法
def getcenter(self):
try:
@@ -135,7 +135,6 @@ class ResMrpWorkOrder(models.Model):
except:
raise UserError("参数计算有误")
def json_workorder_str(self, k, production, route):
workorders_values_str = [0, '', {
'product_uom_id': production.product_uom_id.id,
@@ -171,7 +170,9 @@ class ResMrpWorkOrder(models.Model):
'target': 'new',
'domain': [('workorder_id', '=', self.id)]
}
tray_id = fields.Many2one('sf.tray', string="托盘信息")
# 扫码绑定托盘方法
def gettray(self):
@@ -230,7 +231,6 @@ class ResMrpWorkOrder(models.Model):
tray.unclamp()
self.tray_id = tray
# return {
# 'name': _('New Maintenance Request'),
# 'view_mode': 'form',
@@ -288,7 +288,6 @@ class ResMrpWorkOrder(models.Model):
else:
return True
# cnc程序获取
def fetchCNC(self):
try:
@@ -499,7 +498,6 @@ class CNCprocessing(models.Model):
download_state = ftp.download_file_tree(remotepath, serverdir)
return download_state
# 将nc文件存到attach的datas里
def write_file(self, nc_file_path, cnc):
if os.path.exists(nc_file_path):

View File

@@ -1,7 +1,8 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,base.group_user,1,1,1,1
access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
access_sf_model_type_routing_sort,sf_model_type_routing_sort,model_sf_model_type_routing_sort,base.group_user,1,1,1,1
access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,base.group_user,1,1,1,1
access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_cnc_processing sf_cnc_processing model_sf_cnc_processing base.group_user 1 1 1 1
3 access_sf_model_type sf_model_type model_sf_model_type base.group_user 1 1 1 1
4 access_sf_model_type_routing_sort access_sf_product_model_type_routing_sort sf_model_type_routing_sort sf_product_model_type_routing_sort model_sf_model_type_routing_sort model_sf_product_model_type_routing_sort base.group_user 1 1 1 1
5 access_sf_embryo_model_type_routing_sort sf_embryo_model_type_routing_sort model_sf_embryo_model_type_routing_sort base.group_user 1 1 1 1
6
7
8

View File

@@ -31,10 +31,21 @@
<form string="模型类型">
<group>
<field name="name" required="1"/>
<field name="embryo_tolerance" required="1"/>
<field name="embryo_tolerance" required="1" string="胚料容余(mm)"/>
</group>
<group>
<field name='routing_tmpl_ids'>
<field name='product_routing_tmpl_ids'>
<tree editable='bottom'>
<field name="sequence" widget="handle" string="序号"/>
<field name="route_workcenter_id" string="工序"/>
<field name="routing_type" string="类型"/>
<field name="is_repeat" string="重复"/>
<field name="workcenter_ids" string="工作中心" widget="many2many_tags"/>
</tree>
</field>
</group>
<group>
<field name='embryo_routing_tmpl_ids'>
<tree editable='bottom'>
<field name="sequence" widget="handle" string="序号"/>
<field name="route_workcenter_id" string="工序"/>

View File

@@ -56,10 +56,10 @@
</field>
</record>
<record id="mrp_workcenter_kanban_action1" model="ir.actions.act_window">
<field name="name">工作中心看板</field>
<field name="name">Work Centers Overview</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.workcenter</field>
<field name="view_mode">kanban,form,tree</field>
<field name="view_mode">kanban,form</field>
<field name="view_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="search_view_id" ref="mrp.view_mrp_workcenter_search"/>
<field name="domain">[('users_ids','in',uid)]</field>
@@ -107,7 +107,7 @@
</xpath>
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
<field name="machine_tool_id"/>
<field name="machine_tool_id" domain="[('is_binding','=',False)]"/>
</xpath>
</field>
</record>

View File

@@ -12,7 +12,7 @@
<field name="name" position="after">
<field name="processing_panel"/>
</field>
<field name="state" position="after">
<field name="state" position="after">
<field name="work_state"/>
</field>
<xpath expr="//button[@name='button_start']" position="attributes">
@@ -22,7 +22,7 @@
</attribute>
</xpath>
<xpath expr="//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="attributes">
<attribute name="attrs">{'invisible': [("user_permissions","=",False)]} </attribute>
<attribute name="attrs">{'invisible': [("user_permissions","=",False)]}</attribute>
<attribute name="string">停工</attribute>
</xpath>
<xpath expr="//button[@name='action_open_wizard']" position="attributes">
@@ -52,10 +52,10 @@
<field name="name">Work Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.workorder</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_mode">tree,kanban,form</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')}),
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}) ]"/>
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}),
(0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')}) ]"/>
<field name="target">fullscreen</field>
<field name="domain">[('state', 'not in', ['done', 'cancel'])]</field>
<field name="context">{'search_default_workcenter_id': active_id}</field>
@@ -94,23 +94,25 @@
<sheet position="before">
<field name='user_permissions' invisible="1"/>
<button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done',
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done',
'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),
('is_user_working', '!=', False),('user_permissions','=',False)]}"/>
<button name="button_pending" type="object" string="暂停" class="btn-warning"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
<button name="button_finish" type="object" string="完成" class="btn-success"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False)]}"/>
<button name="button_unblock" type="object" string="Unblock" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False)]}"/>
<button name="button_unblock" type="object" string="Unblock"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
</sheet>
<xpath expr="//page[1]" position="before">
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
<group>
<group>
<field name="programming_no" readonly="1"
attrs='{"invisible": [("programming_no","=",False)]}'/>
<field name="programming_state" readonly="1"
@@ -118,16 +120,16 @@
</group>
<group>
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"
attrs='{"invisible": ["|", "|", ("state","!=","progress"),("user_permissions","=",False),("programming_no","!=",False)]}'/>
</div>
</div>
</group>
</page>
</xpath>
<!-- <page string="Components" name="components">-->
<!-- <page string="Components" name="components">-->
<xpath expr="//page[1]" position="before">
<page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>
<group>
@@ -155,98 +157,142 @@
<div>左面:</div>
<div class="o_address_format">
<label for="X1_axis" string="x"/>
<field name="X1_axis" class="o_form_label"/>
<field name="X1_axis" class="o_form_label"
decoration-success="X1_axis > 0"
decoration-warning="X1_axis &lt; 0"/>
<label for="Y1_axis" string="y"/>
<field name="Y1_axis" class="o_form_label"/>
<field name="Y1_axis" class="o_form_label"
decoration-success="Y1_axis > 0"
decoration-warning="Y1_axis &lt; 0"/>
<label for="Z1_axis" string="z"/>
<field name="Z1_axis" class="o_form_label"/>
<field name="Z1_axis" class="o_form_label"
decoration-success="Z1_axis > 0"
decoration-warning="Z1_axis &lt; 0"/>
<div></div>
<label for="X2_axis" string="x"/>
<field name="X2_axis" class="o_form_label"/>
<field name="X2_axis" class="o_form_label"
decoration-success="X2_axis > 0"
decoration-warning="X2_axis &lt; 0"/>
<label for="Y2_axis" string="y"/>
<field name="Y2_axis" class="o_form_label"/>
<field name="Y2_axis" class="o_form_label"
decoration-success="Y2_axis > 0"
decoration-warning="Y2_axis &lt; 0"/>
<label for="Z2_axis" string="z"/>
<field name="Z2_axis" class="o_form_label"/>
<field name="Z2_axis" class="o_form_label"
decoration-success="Z2_axis > 0"
decoration-warning="Z2_axis &lt; 0"/>
</div>
<div>前面:</div>
<div class="o_address_format">
<label for="X3_axis" string="x"/>
<field name="X3_axis" class="o_form_label"/>
<field name="X3_axis" class="o_form_label"
decoration-success="X3_axis > 0"
decoration-warning="X3_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y3_axis" string="y"/>
<field name="Y3_axis" class="o_form_label"/>
<field name="Y3_axis" class="o_form_label"
decoration-success="Y3_axis > 0"
decoration-warning="Y3_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z3_axis" string="z"/>
<field name="Z3_axis" class="o_form_label"/>
<field name="Z3_axis" class="o_form_label"
decoration-success="Z3_axis > 0"
decoration-warning="Z3_axis &lt; 0"/>
<div></div>
<label for="X4_axis" string="x"/>
<field name="X4_axis" class="o_form_label"/>
<field name="X4_axis" class="o_form_label"
decoration-success="X4_axis > 0"
decoration-warning="X4_axis &lt; 0"
/>
<span>&amp;nbsp;</span>
<label for="Y4_axis" string="y"/>
<field name="Y4_axis" class="o_form_label"/>
<field name="Y4_axis" class="o_form_label"
decoration-success="Y4_axis > 0"
decoration-warning="Y4_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z4_axis" string="z"/>
<field name="Z4_axis" class="o_form_label"/>
<field name="Z4_axis" class="o_form_label"
decoration-success="Z4_axis > 0"
decoration-warning="Z4_axis &lt; 0"/>
</div>
<div>右面:</div>
<div class="o_address_format">
<label for="X5_axis" string="x"/>
<field name="X5_axis" class="o_form_label"/>
<field name="X5_axis" class="o_form_label"
decoration-success="X5_axis > 0"
decoration-warning="X5_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y5_axis" string="y"/>
<field name="Y5_axis" class="o_form_label"/>
<field name="Y5_axis" class="o_form_label" decoration-success="Y5_axis > 0"
decoration-warning="Y5_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z5_axis" string="z"/>
<field name="Z5_axis" class="o_form_label"/>
<field name="Z5_axis" class="o_form_label" decoration-success="Z5_axis > 0"
decoration-warning="Z5_axis &lt; 0"/>
<div></div>
<label for="X6_axis" string="x"/>
<field name="X6_axis" class="o_form_label"/>
<field name="X6_axis" class="o_form_label" decoration-success="X6_axis > 0"
decoration-warning="X6_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y6_axis" string="y"/>
<field name="Y6_axis" class="o_form_label"/>
<field name="Y6_axis" class="o_form_label" decoration-success="Y6_axis > 0"
decoration-warning="Y6_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z6_axis" string="z"/>
<field name="Z6_axis" class="o_form_label"/>
<field name="Z6_axis" class="o_form_label" decoration-success="Z6_axis > 0"
decoration-warning="Z6_axis &lt; 0"/>
</div>
<div>后面:</div>
<div class="o_address_format">
<label for="X7_axis" string="x"/>
<field name="X7_axis" class="o_form_label"/>
<field name="X7_axis" class="o_form_label" decoration-success="X7_axis > 0"
decoration-warning="X7_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y7_axis" string="y"/>
<field name="Y7_axis" class="o_form_label"/>
<field name="Y7_axis" class="o_form_label" decoration-success="Y7_axis > 0"
decoration-warning="Y7_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z7_axis" string="z"/>
<field name="Z7_axis" class="o_form_label"/>
<field name="Z7_axis" class="o_form_label" decoration-success="Z7_axis > 0"
decoration-warning="Z7_axis &lt; 0"/>
<div></div>
<label for="X8_axis" string="x"/>
<field name="X8_axis" class="o_form_label"/>
<field name="X8_axis" class="o_form_label" decoration-success="X8_axis > 0"
decoration-warning="X8_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y8_axis" string="y"/>
<field name="Y8_axis" class="o_form_label"/>
<field name="Y8_axis" class="o_form_label" decoration-success="Y8_axis > 0"
decoration-warning="Y8_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z8_axis" string="z"/>
<field name="Z8_axis" class="o_form_label"/>
<field name="Z8_axis" class="o_form_label" decoration-success="Z8_axis > 0"
decoration-warning="Z8_axis &lt; 0"/>
</div>
<div>上面:</div>
<div class="o_address_format">
<label for="X9_axis" string="x"/>
<field name="X9_axis" class="o_form_label"/>
<field name="X9_axis" class="o_form_label" decoration-success="X9_axis > 0"
decoration-warning="X9_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y9_axis" string="y"/>
<field name="Y9_axis" class="o_form_label"/>
<field name="Y9_axis" class="o_form_label" decoration-success="Y9_axis > 0"
decoration-warning="Y9_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z9_axis" string="z"/>
<field name="Z9_axis" class="o_form_label"/>
<field name="Z9_axis" class="o_form_label" decoration-success="Z9_axis > 0"
decoration-warning="Z9_axis &lt; 0"/>
<div></div>
<label for="X10_axis" string="x"/>
<field name="X10_axis" class="o_form_label"/>
<field name="X10_axis" class="o_form_label" decoration-success="X10_axis > 0"
decoration-warning="X10_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Y10_axis" string="y"/>
<field name="Y10_axis" class="o_form_label"/>
<field name="Y10_axis" class="o_form_label" decoration-success="Y10_axis > 0"
decoration-warning="Y10_axis &lt; 0"/>
<span>&amp;nbsp;</span>
<label for="Z10_axis" string="z"/>
<field name="Z10_axis" class="o_form_label"/>
<field name="Z10_axis" class="o_form_label" decoration-success="Z10_axis > 0"
decoration-warning="Z10_axis &lt; 0"/>
</div>
<div class="col-12 col-lg-6 o_setting_box">
@@ -262,6 +308,9 @@
</xpath>
<xpath expr="//page[1]" position="before">
<field name="production_id" position="after">
<field name="processing_panel" readonly="1"/>
</field>
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<group>
<field name="cnc_ids" widget="one2many" string="工作程序">
@@ -281,6 +330,8 @@
<field name="remark"/>
</tree>
</field>
</group>
<group>
<field name="cnc_worksheet" string="工作指令" widget="pdf_viewer"/>
</group>
</page>
@@ -289,11 +340,11 @@
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
<group>
<field name="test_results" widget="selection"/>
</group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认" attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
string="检测确认"
attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
</div>
</page>
</xpath>
@@ -306,7 +357,8 @@
</div>
<div class="col-12 col-lg-6 o_setting_box">
<button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"
string="打印标签" attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
string="打印标签"
attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>
</div>
</page>
@@ -314,3 +366,4 @@
</field>
</record>
</odoo>

View File

@@ -27,7 +27,8 @@ class Sf_Mrs_Connect(http.Controller):
# 查询状态为进行中且类型为获取CNC加工程序的工单
cnc_workorder = request.env['mrp.workorder'].with_user(
request.env.ref("base.user_admin")).search([('production_id.name', '=', ret['production_order_no']),
('routing_type', '=', '获取CNC加工程序')])
('routing_type', '=', '获取CNC加工程序'),
('state', '=', 'progress')])
if cnc_workorder:
# 拉取所有加工面的程序文件
# i = 1

View File

@@ -111,7 +111,7 @@ class sfMaterialModel(models.Model):
brand.active = item['active'],
brand.mf_materia_post = item['mf_materia_post'],
brand.materials_id = self.env['sf.production.materials'].search(
[("materials_no", '=', item['materials_id.materials_no'])]).id,
[("materials_no", '=', item['materials_id.materials_no'])]).id,
brand.need_h = item['need_h'],
brand.density = item['density']
else:
@@ -158,9 +158,9 @@ class sfMaterialModel(models.Model):
"need_h": item['need_h'],
"mf_materia_post": item['mf_materia_post'],
"density": item['density'],
# "tag_ids": item['tag_ids']
# "tag_ids": item['tag_ids']
})
})
else:
raise ValidationError("认证未通过")
@@ -392,7 +392,7 @@ class MachineControlSystem(models.Model):
brand.id = item['id'],
brand.name = item['name'],
brand.code = item['code'],
brand.brand_id=self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
brand.active = item['active']
else:
self.env['sf.machine.control_system'].create({
@@ -500,12 +500,9 @@ class MachineBrand(models.Model):
"id": item['id'],
"name": item['name'],
"code": item['code'],
# "image_brand": item['image_brand'],
"active": item['active'],
"image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand),
"tag_ids": self.env['sf.machine.brand.tags'].search(
[("name", 'in', item['tag_ids'])]).ids
[("name", 'in', item['tag_ids'])]).ids
})
else:
raise ValidationError("认证未通过")
@@ -517,8 +514,6 @@ class MachineTool(models.Model):
url = '/api/machine_tool/list'
crea_url = '/api/machine_tool/create'
# 定时同步机床
def sync_machine_tool(self):
sf_sync_config = self.env['res.config.settings'].get_values()
@@ -657,7 +652,8 @@ class MachineToolType(models.Model):
brand.number_of_knife_library = item['number_of_knife_library'],
brand.rotate_speed = item['rotate_speed'],
brand.number_of_axles = item['number_of_axles'],
brand.control_system_id = self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id,
brand.control_system_id = self.env['sf.machine.control_system'].search(
[('code', '=', item['control_system_id'])]).id,
brand.x_axis = item['x_axis'],
brand.y_axis = item['y_axis'],
@@ -666,8 +662,9 @@ class MachineToolType(models.Model):
brand.c_axis = item['c_axis'],
brand.active = item['active'],
brand.remark = item['remark'],
brand.brand_id=self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
brand.machine_tool_id = self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
brand.machine_tool_id = self.env['sf.machine_tool'].search(
[('code', '=', item['machine_tool_id'])]).id
else:
self.env['sf.machine_tool.type'].create({
@@ -677,7 +674,8 @@ class MachineToolType(models.Model):
"number_of_knife_library": item['number_of_knife_library'],
"rotate_speed": item['rotate_speed'],
'machine_tool_id' : self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id,
'machine_tool_id': self.env['sf.machine_tool'].search(
[('code', '=', item['machine_tool_id'])]).id,
"number_of_axles": item['number_of_axles'],
"x_axis": item['x_axis'],
"y_axis": item['y_axis'],
@@ -686,7 +684,8 @@ class MachineToolType(models.Model):
"c_axis": item['c_axis'],
"remark": item['remark'],
"precision": item['precision'],
'control_system_id' : self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id,
'control_system_id': self.env['sf.machine.control_system'].search(
[('code', '=', item['control_system_id'])]).id,
"active": item['active'],
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
@@ -716,7 +715,8 @@ class MachineToolType(models.Model):
"code": item['code'],
"number_of_knife_library": item['number_of_knife_library'],
"rotate_speed": item['rotate_speed'],
'machine_tool_id' : self.env['sf.machine_tool'].search([('code', '=', item['machine_tool_id'])]).id,
'machine_tool_id': self.env['sf.machine_tool'].search(
[('code', '=', item['machine_tool_id'])]).id,
"number_of_axles": item['number_of_axles'],
"x_axis": item['x_axis'],
"y_axis": item['y_axis'],
@@ -725,7 +725,8 @@ class MachineToolType(models.Model):
"c_axis": item['c_axis'],
"remark": item['remark'],
"precision": item['precision'],
'control_system_id' : self.env['sf.machine.control_system'].search([('code', '=', item['control_system_id'])]).id,
'control_system_id': self.env['sf.machine.control_system'].search(
[('code', '=', item['control_system_id'])]).id,
"active": item['active'],
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
@@ -836,7 +837,8 @@ class CuttingToolType(models.Model):
brand.tool_length = item['tool_length'],
brand.blade_number = item['blade_number']
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
brand.category_id = self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id
brand.category_id = self.env['sf.cutting_tool.category'].search(
[('code', '=', item['category_id'])]).id
else:
self.env['sf.cutting_tool.type'].create({
"id": item['id'],
@@ -852,7 +854,8 @@ class CuttingToolType(models.Model):
"tool_length": item['tool_length'],
"blade_number": item['blade_number'],
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
"category_id": self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id,
"category_id": self.env['sf.cutting_tool.category'].search(
[('code', '=', item['category_id'])]).id,
})
else:
raise ValidationError("认证未通过")
@@ -887,13 +890,13 @@ class CuttingToolType(models.Model):
"tool_length": item['tool_length'],
"blade_number": item['blade_number'],
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
"category_id": self.env['sf.cutting_tool.category'].search([('code', '=', item['category_id'])]).id,
"category_id": self.env['sf.cutting_tool.category'].search(
[('code', '=', item['category_id'])]).id,
})
else:
raise ValidationError("认证未通过")
class sfProcessingOrder(models.Model):
_inherit = 'sf.processing.order'
_description = '工序'
@@ -948,4 +951,3 @@ class sfProcessingOrder(models.Model):
})
else:
raise ValidationError("认证未通过")

View File

@@ -15,10 +15,9 @@ class ReSaleOrder(models.Model):
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
deadline_of_delivery,user_id):
deadline_of_delivery, user_id):
now_time = datetime.datetime.now()
partner = self.env.user.partner_id
logging.info('partner:%s' % partner)
order_id = self.env['sale.order'].sudo().create({
'company_id': company_id.id,
'date_order': now_time,
@@ -31,7 +30,6 @@ class ReSaleOrder(models.Model):
'address_of_delivery': delivery_address,
'deadline_of_delivery': deadline_of_delivery
})
logging.info('sale_order_create:%s' % order_id)
return order_id
# 业务平台分配工厂时在创建完产品后再创建销售明细信息