修复工作中心绑定机床和胚料外协供应商外包未勾选问题

This commit is contained in:
jinling.yang
2023-01-13 16:47:12 +08:00
12 changed files with 97 additions and 113 deletions

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

@@ -82,7 +82,7 @@ class ResProductTemplate(models.Model):
item['model_height'] + model_type.embryo_tolerance),
'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 +92,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(
@@ -158,14 +158,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
@@ -249,7 +248,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

View File

@@ -6,13 +6,13 @@
<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" />
<field name="materials_id" string="材料"/>
<field name="materials_type_id" string="型号"
domain="[('materials_id', '=', materials_id)]"/>
@@ -36,18 +36,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="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>

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

@@ -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">

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("认证未通过")