新增同步mrs的表面工艺类别接口
This commit is contained in:
@@ -38,6 +38,17 @@ class MrsMaterialModel(models.Model):
|
||||
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):
|
||||
_name = 'sf.production.process'
|
||||
@@ -51,6 +62,7 @@ class MrsProductionProcess(models.Model):
|
||||
active = fields.Boolean('有效', default=True)
|
||||
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
|
||||
gain_way = fields.Selection([("自加工", "自加工"), ("外协", "外协")], default="", string="获取方式")
|
||||
category_id = fields.Many2one('sf.production.process.category')
|
||||
|
||||
|
||||
class MrsProcessingTechnology(models.Model):
|
||||
|
||||
@@ -39,6 +39,59 @@
|
||||
</search>
|
||||
</field>
|
||||
</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">
|
||||
<field name="model">sf.production.process</field>
|
||||
@@ -95,8 +148,6 @@
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
|
||||
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
@@ -231,26 +282,6 @@
|
||||
</field>
|
||||
</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">
|
||||
<field name="name">材料</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
@@ -290,13 +321,24 @@
|
||||
<field name="res_model">sf.processing.technology</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="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">
|
||||
<field name="name">托盘</field>
|
||||
|
||||
@@ -63,6 +63,13 @@
|
||||
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
|
||||
id="menu_sf_production_materials"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
""",
|
||||
'category': 'sf',
|
||||
'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/product_data.xml',
|
||||
'views/product_template_view.xml',
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
<record id="view_mrp_bom_form_inherit_sf" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.form.inherit.sf</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="subcontractor_ids" position="replace">
|
||||
<field name="subcontractor_id"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import base64
|
||||
from io import BytesIO
|
||||
from odoo import api, fields, models
|
||||
from pystrich.code128 import Code128Encoder
|
||||
#from pystrich.code128 import Code128Encoder
|
||||
|
||||
|
||||
class Tray(models.Model):
|
||||
|
||||
@@ -77,16 +77,16 @@
|
||||
<field name="doall" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- <record model="ir.cron" id="sf_cron8">-->
|
||||
<!-- <field name="name">同步注册机床</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrs_machine_tool"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model.enroll_machine_tool()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">days</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- </record>-->
|
||||
<record model="ir.cron" id="sf_cron8">
|
||||
<field name="name">同步表面工艺类别</field>
|
||||
<field name="model_id" ref="model_sf_production_process_category"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.sync_production_process_category()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="sf_cron9">
|
||||
<field name="name">同步资源库机床型号</field>
|
||||
|
||||
@@ -26,6 +26,8 @@ class ResConfigSettings(models.TransientModel):
|
||||
_logger.info("同步资源库材料型号")
|
||||
self.env['sf.production.process'].sync_all_production_process()
|
||||
_logger.info("同步资源库表面工艺")
|
||||
self.env['sf.production.process.category'].sync_all_production_process_category()
|
||||
_logger.info("同步资源库表面工艺类别")
|
||||
self.env['sf.processing.technology'].sync_all_processing_technology()
|
||||
_logger.info("同步资源库加工工艺")
|
||||
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
|
||||
|
||||
@@ -6,6 +6,7 @@ from odoo import models
|
||||
from odoo.exceptions import ValidationError
|
||||
import logging
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -162,6 +163,66 @@ class sfMaterialModel(models.Model):
|
||||
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):
|
||||
_inherit = 'sf.production.process'
|
||||
_description = '表面工艺'
|
||||
@@ -184,21 +245,21 @@ class sfProductionProcess(models.Model):
|
||||
brand = self.env['sf.production.process'].search(
|
||||
[("process_encode", '=', item['process_encode'])])
|
||||
if brand:
|
||||
brand.id = item['id'],
|
||||
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.remark = item['remark'],
|
||||
brand.active = item['active'],
|
||||
brand.remark = item['remark']
|
||||
else:
|
||||
self.env['sf.production.process'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"category_id": self.env['sf.production.process.category'].search(
|
||||
[("code", '=', item['category_code'])]).id,
|
||||
"process_encode": item['process_encode'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过") # 定时同步表面工艺
|
||||
@@ -221,8 +282,9 @@ class sfProductionProcess(models.Model):
|
||||
[("process_encode", '=', item['process_encode'])])
|
||||
if not brand:
|
||||
self.env['sf.production.process'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"category_id": self.env['sf.production.process.category'].search(
|
||||
[("code", '=', item['category_code'])]).id,
|
||||
"process_encode": item['process_encode'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
@@ -949,6 +1011,7 @@ class sfProcessingOrder(models.Model):
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
class sfProductionProcessParameter(models.Model):
|
||||
_inherit = 'sf.production.process.parameter'
|
||||
_description = '表面工艺可选参数'
|
||||
@@ -980,7 +1043,7 @@ class sfProductionProcessParameter(models.Model):
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"active": item['active'],
|
||||
"price" : item['price'],
|
||||
"price": item['price'],
|
||||
"process_id": self.env['sf.production.process'].search(
|
||||
[('process_encode', '=', item['process_id_code'])]).id,
|
||||
'materials_model_ids': self.env['sf.materials.model'].search(
|
||||
|
||||
Reference in New Issue
Block a user