新增同步mrs的表面工艺类别接口
This commit is contained in:
@@ -38,6 +38,17 @@ class MrsMaterialModel(models.Model):
|
|||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
|
class MrsProductionProcessCategory(models.Model):
|
||||||
|
_name = 'sf.production.process.category'
|
||||||
|
_description = '表面工艺类别'
|
||||||
|
order = 'id desc'
|
||||||
|
|
||||||
|
name = fields.Char('名称')
|
||||||
|
code = fields.Char("编码")
|
||||||
|
production_process_ids = fields.One2many('sf.production.process', 'category_id', string="表面工艺")
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
# 工艺 编码,名称,备注
|
# 工艺 编码,名称,备注
|
||||||
class MrsProductionProcess(models.Model):
|
class MrsProductionProcess(models.Model):
|
||||||
_name = 'sf.production.process'
|
_name = 'sf.production.process'
|
||||||
@@ -51,6 +62,7 @@ class MrsProductionProcess(models.Model):
|
|||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
|
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
|
||||||
gain_way = fields.Selection([("自加工", "自加工"), ("外协", "外协")], default="", string="获取方式")
|
gain_way = fields.Selection([("自加工", "自加工"), ("外协", "外协")], default="", string="获取方式")
|
||||||
|
category_id = fields.Many2one('sf.production.process.category')
|
||||||
|
|
||||||
|
|
||||||
class MrsProcessingTechnology(models.Model):
|
class MrsProcessingTechnology(models.Model):
|
||||||
|
|||||||
@@ -39,6 +39,59 @@
|
|||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!--表面工艺类别-->
|
||||||
|
<record model="ir.ui.view" id="sf_production_process_category_form">
|
||||||
|
<field name="model">sf.production.process.category</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="表面工艺类别">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="code" readonly="1"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="name" required="1"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<notebook>
|
||||||
|
<page string="表面工艺">
|
||||||
|
<field name='production_process_ids' widget="ony2many">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="process_encode" string="编码号" readonly="1" force_save="1"/>
|
||||||
|
<field name="name" string="名称" required="1"/>
|
||||||
|
<field name='category_id' default="default" invisible="1"/>
|
||||||
|
<field name="remark"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="sf_production_process_category_tree">
|
||||||
|
<field name="model">sf.production.process.category</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="表面工艺类别">
|
||||||
|
<field name="code"/>
|
||||||
|
<field name="name"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="search_sf_production_process_category_view">
|
||||||
|
<field name="name">search.sf.production.process.category</field>
|
||||||
|
<field name="model">sf.production.process.category</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
|
||||||
|
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!--表面工艺-->
|
<!--表面工艺-->
|
||||||
<record model="ir.ui.view" id="sf_production_process_tree">
|
<record model="ir.ui.view" id="sf_production_process_tree">
|
||||||
<field name="model">sf.production.process</field>
|
<field name="model">sf.production.process</field>
|
||||||
@@ -95,8 +148,6 @@
|
|||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
@@ -231,26 +282,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- <record model="ir.ui.view" id="sf_production_materials_form">-->
|
|
||||||
<!-- <field name="model">sf.production.materials</field>-->
|
|
||||||
<!-- <field name="arch" type="xml">-->
|
|
||||||
<!-- <form string="材料">-->
|
|
||||||
|
|
||||||
<!-- <group string="详情">-->
|
|
||||||
<!-- <group>-->
|
|
||||||
<!-- <field name="materials_no" required="1" default="编码"/>-->
|
|
||||||
<!-- </group>-->
|
|
||||||
<!-- <group>-->
|
|
||||||
<!-- <field name="name" required="1"/>-->
|
|
||||||
<!-- </group>-->
|
|
||||||
<!-- <field name="materials_model_ids">-->
|
|
||||||
|
|
||||||
<!-- </field>-->
|
|
||||||
<!-- </group>-->
|
|
||||||
<!-- </form>-->
|
|
||||||
<!-- </field>-->
|
|
||||||
<!-- </record>-->
|
|
||||||
|
|
||||||
<record id="sf_production_materials" model="ir.actions.act_window">
|
<record id="sf_production_materials" model="ir.actions.act_window">
|
||||||
<field name="name">材料</field>
|
<field name="name">材料</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
@@ -290,13 +321,24 @@
|
|||||||
<field name="res_model">sf.processing.technology</field>
|
<field name="res_model">sf.processing.technology</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
|
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
加工工艺!
|
加工工艺!
|
||||||
</p>
|
</p>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_production_process_category" model="ir.actions.act_window">
|
||||||
|
<field name="name">表面工艺类别</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sf.production.process.category</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
表面工艺类别!
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
#------------------托盘------------------
|
#------------------托盘------------------
|
||||||
<record id="action_sf_tray" model="ir.actions.act_window">
|
<record id="action_sf_tray" model="ir.actions.act_window">
|
||||||
<field name="name">托盘</field>
|
<field name="name">托盘</field>
|
||||||
|
|||||||
@@ -63,6 +63,13 @@
|
|||||||
action="sf_production_process"
|
action="sf_production_process"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_sf_production_process_category"
|
||||||
|
name="表面工艺类别"
|
||||||
|
parent="menu_sf_production_process_1"
|
||||||
|
sequence="2"
|
||||||
|
action="sf_production_process_category"
|
||||||
|
/>
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_sf_production_materials"
|
id="menu_sf_production_materials"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['mrp', 'base', 'sf_manufacturing','web_widget_model_viewer'],
|
'depends': ['mrp', 'base', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting'],
|
||||||
'data': [
|
'data': [
|
||||||
'data/product_data.xml',
|
'data/product_data.xml',
|
||||||
'views/product_template_view.xml',
|
'views/product_template_view.xml',
|
||||||
|
|||||||
@@ -123,7 +123,7 @@
|
|||||||
<record id="view_mrp_bom_form_inherit_sf" model="ir.ui.view">
|
<record id="view_mrp_bom_form_inherit_sf" model="ir.ui.view">
|
||||||
<field name="name">mrp.bom.form.inherit.sf</field>
|
<field name="name">mrp.bom.form.inherit.sf</field>
|
||||||
<field name="model">mrp.bom</field>
|
<field name="model">mrp.bom</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
|
<field name="inherit_id" ref="mrp_subcontracting.mrp_bom_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="subcontractor_ids" position="replace">
|
<field name="subcontractor_ids" position="replace">
|
||||||
<field name="subcontractor_id"
|
<field name="subcontractor_id"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import base64
|
import base64
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
from pystrich.code128 import Code128Encoder
|
#from pystrich.code128 import Code128Encoder
|
||||||
|
|
||||||
|
|
||||||
class Tray(models.Model):
|
class Tray(models.Model):
|
||||||
|
|||||||
@@ -77,16 +77,16 @@
|
|||||||
<field name="doall" eval="False"/>
|
<field name="doall" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- <record model="ir.cron" id="sf_cron8">-->
|
<record model="ir.cron" id="sf_cron8">
|
||||||
<!-- <field name="name">同步注册机床</field>-->
|
<field name="name">同步表面工艺类别</field>
|
||||||
<!-- <field name="model_id" ref="model_mrs_machine_tool"/>-->
|
<field name="model_id" ref="model_sf_production_process_category"/>
|
||||||
<!-- <field name="state">code</field>-->
|
<field name="state">code</field>
|
||||||
<!-- <field name="code">model.enroll_machine_tool()</field>-->
|
<field name="code">model.sync_production_process_category()</field>
|
||||||
<!-- <field name="interval_number">1</field>-->
|
<field name="interval_number">1</field>
|
||||||
<!-- <field name="interval_type">days</field>-->
|
<field name="interval_type">days</field>
|
||||||
<!-- <field name="numbercall">-1</field>-->
|
<field name="numbercall">-1</field>
|
||||||
<!-- <field name="doall" eval="False"/>-->
|
<field name="doall" eval="False"/>
|
||||||
<!-- </record>-->
|
</record>
|
||||||
|
|
||||||
<record model="ir.cron" id="sf_cron9">
|
<record model="ir.cron" id="sf_cron9">
|
||||||
<field name="name">同步资源库机床型号</field>
|
<field name="name">同步资源库机床型号</field>
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
<field name="doall" eval="False"/>
|
<field name="doall" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.cron" id="sf_cron13">
|
<record model="ir.cron" id="sf_cron13">
|
||||||
<field name="name">同步表面工艺可选参数</field>
|
<field name="name">同步表面工艺可选参数</field>
|
||||||
<field name="model_id" ref="model_sf_production_process_parameter"/>
|
<field name="model_id" ref="model_sf_production_process_parameter"/>
|
||||||
<field name="state">code</field>
|
<field name="state">code</field>
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
_logger.info("同步资源库材料型号")
|
_logger.info("同步资源库材料型号")
|
||||||
self.env['sf.production.process'].sync_all_production_process()
|
self.env['sf.production.process'].sync_all_production_process()
|
||||||
_logger.info("同步资源库表面工艺")
|
_logger.info("同步资源库表面工艺")
|
||||||
|
self.env['sf.production.process.category'].sync_all_production_process_category()
|
||||||
|
_logger.info("同步资源库表面工艺类别")
|
||||||
self.env['sf.processing.technology'].sync_all_processing_technology()
|
self.env['sf.processing.technology'].sync_all_processing_technology()
|
||||||
_logger.info("同步资源库加工工艺")
|
_logger.info("同步资源库加工工艺")
|
||||||
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
|
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from odoo import models
|
|||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
import logging
|
import logging
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -162,6 +163,66 @@ class sfMaterialModel(models.Model):
|
|||||||
raise ValidationError("认证未通过")
|
raise ValidationError("认证未通过")
|
||||||
|
|
||||||
|
|
||||||
|
class sfProductionProcessCategory(models.Model):
|
||||||
|
_inherit = 'sf.production.process.category'
|
||||||
|
_description = '表面工艺类别'
|
||||||
|
url = '/api/production_process_category/list'
|
||||||
|
|
||||||
|
# 定时同步每日表面工艺类别
|
||||||
|
def sync_production_process_category(self):
|
||||||
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
|
token = sf_sync_config['token']
|
||||||
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
|
|
||||||
|
strUrl = sf_sync_config['sf_url'] + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['production_process_category_yesterday_list']:
|
||||||
|
if item:
|
||||||
|
production_process_category = self.env['sf.production.process.category'].search(
|
||||||
|
[("code", '=', item['code'])])
|
||||||
|
if production_process_category:
|
||||||
|
production_process_category.name = item['name'],
|
||||||
|
production_process_category.code = item['code'],
|
||||||
|
production_process_category.active = item['active']
|
||||||
|
else:
|
||||||
|
self.env['sf.production.process.category'].create({
|
||||||
|
"name": item['name'],
|
||||||
|
"code": item['code'],
|
||||||
|
"active": item['active'],
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("认证未通过") # 定时同步表面工艺
|
||||||
|
|
||||||
|
# 同步所有表面工艺类别
|
||||||
|
def sync_all_production_process_category(self):
|
||||||
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
|
token = sf_sync_config['token']
|
||||||
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
|
|
||||||
|
strUrl = sf_sync_config['sf_url'] + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['production_process_category_all_list']:
|
||||||
|
if item:
|
||||||
|
category = self.env['sf.production.process.category'].search(
|
||||||
|
[("process_encode", '=', item['process_encode'])])
|
||||||
|
if not category:
|
||||||
|
self.env['sf.production.process.category'].create({
|
||||||
|
"name": item['name'],
|
||||||
|
"code": item['code'],
|
||||||
|
"active": item['active'],
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("认证未通过")
|
||||||
|
|
||||||
|
|
||||||
class sfProductionProcess(models.Model):
|
class sfProductionProcess(models.Model):
|
||||||
_inherit = 'sf.production.process'
|
_inherit = 'sf.production.process'
|
||||||
_description = '表面工艺'
|
_description = '表面工艺'
|
||||||
@@ -184,21 +245,21 @@ class sfProductionProcess(models.Model):
|
|||||||
brand = self.env['sf.production.process'].search(
|
brand = self.env['sf.production.process'].search(
|
||||||
[("process_encode", '=', item['process_encode'])])
|
[("process_encode", '=', item['process_encode'])])
|
||||||
if brand:
|
if brand:
|
||||||
brand.id = item['id'],
|
|
||||||
brand.name = item['name'],
|
brand.name = item['name'],
|
||||||
|
brand.category_id = self.env['sf.production.process.category'].search(
|
||||||
|
[("code", '=', item['category_code'])]).id,
|
||||||
brand.process_encode = item['process_encode'],
|
brand.process_encode = item['process_encode'],
|
||||||
brand.remark = item['remark'],
|
brand.remark = item['remark'],
|
||||||
brand.active = item['active'],
|
brand.active = item['active'],
|
||||||
brand.remark = item['remark']
|
brand.remark = item['remark']
|
||||||
else:
|
else:
|
||||||
self.env['sf.production.process'].create({
|
self.env['sf.production.process'].create({
|
||||||
"id": item['id'],
|
|
||||||
"name": item['name'],
|
"name": item['name'],
|
||||||
|
"category_id": self.env['sf.production.process.category'].search(
|
||||||
|
[("code", '=', item['category_code'])]).id,
|
||||||
"process_encode": item['process_encode'],
|
"process_encode": item['process_encode'],
|
||||||
"remark": item['remark'],
|
"remark": item['remark'],
|
||||||
"active": item['active'],
|
"active": item['active'],
|
||||||
# "tag_ids": item['tag_ids']
|
|
||||||
|
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
raise ValidationError("认证未通过") # 定时同步表面工艺
|
raise ValidationError("认证未通过") # 定时同步表面工艺
|
||||||
@@ -221,8 +282,9 @@ class sfProductionProcess(models.Model):
|
|||||||
[("process_encode", '=', item['process_encode'])])
|
[("process_encode", '=', item['process_encode'])])
|
||||||
if not brand:
|
if not brand:
|
||||||
self.env['sf.production.process'].create({
|
self.env['sf.production.process'].create({
|
||||||
"id": item['id'],
|
|
||||||
"name": item['name'],
|
"name": item['name'],
|
||||||
|
"category_id": self.env['sf.production.process.category'].search(
|
||||||
|
[("code", '=', item['category_code'])]).id,
|
||||||
"process_encode": item['process_encode'],
|
"process_encode": item['process_encode'],
|
||||||
"remark": item['remark'],
|
"remark": item['remark'],
|
||||||
"active": item['active'],
|
"active": item['active'],
|
||||||
@@ -949,6 +1011,7 @@ class sfProcessingOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
raise ValidationError("认证未通过")
|
raise ValidationError("认证未通过")
|
||||||
|
|
||||||
|
|
||||||
class sfProductionProcessParameter(models.Model):
|
class sfProductionProcessParameter(models.Model):
|
||||||
_inherit = 'sf.production.process.parameter'
|
_inherit = 'sf.production.process.parameter'
|
||||||
_description = '表面工艺可选参数'
|
_description = '表面工艺可选参数'
|
||||||
@@ -980,7 +1043,7 @@ class sfProductionProcessParameter(models.Model):
|
|||||||
"name": item['name'],
|
"name": item['name'],
|
||||||
"code": item['code'],
|
"code": item['code'],
|
||||||
"active": item['active'],
|
"active": item['active'],
|
||||||
"price" : item['price'],
|
"price": item['price'],
|
||||||
"process_id": self.env['sf.production.process'].search(
|
"process_id": self.env['sf.production.process'].search(
|
||||||
[('process_encode', '=', item['process_id_code'])]).id,
|
[('process_encode', '=', item['process_id_code'])]).id,
|
||||||
'materials_model_ids': self.env['sf.materials.model'].search(
|
'materials_model_ids': self.env['sf.materials.model'].search(
|
||||||
@@ -1019,4 +1082,4 @@ class sfProductionProcessParameter(models.Model):
|
|||||||
|
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
raise ValidationError("认证未通过")
|
raise ValidationError("认证未通过")
|
||||||
|
|||||||
Reference in New Issue
Block a user