去掉非相关代码

This commit is contained in:
jinling.yang
2022-11-08 10:01:53 +08:00
parent cbf1cd8b0b
commit c1d6a24cd9
13 changed files with 91 additions and 255 deletions

View File

@@ -10,13 +10,16 @@
""",
'category': 'YZ',
'website': 'https://www.sf.jikimo.com',
'depends': ['account', 'base', 'mrp'],
'depends': ['account', 'base', 'mrp','sale','sf_manufacturing_orders'],
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',
'views/mrs_base_view.xml',
'views/mrs_common_view.xml',
"views/menu_view.xml"
"views/menu_view.xml",
'views/mrp_routing_workcenter_view.xml',
'views/sale_order_view.xml',
'views/product_template_view.xml',
],
'demo': [

View File

@@ -13,12 +13,13 @@ class ResMrpRoutingWorkcenter(models.Model):
_inherit = 'mrp.routing.workcenter'
routing_type = fields.Selection([
('装夹', '装夹'),
('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('置三元质量检测', '置三元质量检测'),
('解除装夹', '解除装夹'),
], string="工序类型")
('获取CNC加工程序', '获取CNC加工程序'),
('装夹', '装夹'),
('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('置三元质量检测', '置三元质量检测'),
('解除装夹', '解除装夹'),
], string="工序类型")
is_repeat = fields.Boolean('重复', default=False)
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_route', required=True)

View File

@@ -142,13 +142,13 @@
action="action_mrs_machine_control_system"/>
<!-- <menuitem-->
<!-- id="menu_sf_partner_views"-->
<!-- name="工厂token"-->
<!-- parent="menu_mrs_base"-->
<!-- sequence="1"-->
<!-- action="token_factory_view"-->
<!-- />-->
<menuitem
id="menu_sf_model_type"
name="模型类型"
parent="mrp.menu_mrp_configuration"
sequence="10"
action="action_sf_model_type"
/>

View File

@@ -355,11 +355,11 @@
<field name="arch" type="xml">
<form string="机床">
<header>
<button type="object" class="oe_highlight" name ='enroll_machine_tool' string="机床注册" />
<button type="object" class="oe_highlight" name='enroll_machine_tool' string="机床注册"/>
</header>
<group string="基本信息">
<group>
<field name="MTcode" string="编码" />
<field name="MTcode" string="编码"/>
<field name="brand_id"
required="1"
@@ -368,7 +368,8 @@
</group>
<group>
<field name="name" required="1"/>
<field name="type_id" required="1" options="{'no_create': True}" domain="[('brand_id', '=', brand_id)]" attrs="{'invisible': [('brand_id','=',False)]}"/>
<field name="type_id" required="1" options="{'no_create': True}"
domain="[('brand_id', '=', brand_id)]" attrs="{'invisible': [('brand_id','=',False)]}"/>
</group>
<group>
@@ -406,7 +407,7 @@
<field name="rotate_speed" required="1" string="转速(min)" options="{'format': false}"/>
<field name="precision" required="1" string="加工精度(mm)"/>
<field name="control_system_id" required="1" options="{'no_create': True}"/>
<field name="state" widget="selection"/>
<field name="state" widget="selection"/>
</group>
</group>
<group string="其它">
@@ -489,4 +490,61 @@
</p>
</field>
</record>
#------------------模型类型------------------
<record model="ir.ui.view" id="search_sf_model_type_view">
<field name="name">search.sf.model.type</field>
<field name="model">sf.model.type</field>
<field name="arch" type="xml">
<search string="模型类型">
<field name="name" string="模糊搜索"
filter_domain="[('name', 'ilike', self)]"/>
</search>
</field>
</record>
<record model="ir.ui.view" id="tree_sf_model_type_view">
<field name="name">tree.sf.model.type</field>
<field name="model">sf.model.type</field>
<field name="arch" type="xml">
<tree string="模型类型">
<field name="name"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="form_sf_model_type">
<field name="name">form.sf.model.type</field>
<field name="model">sf.model.type</field>
<field name="arch" type="xml">
<form string="模型类型">
<group>
<field name="name" required="1"/>
</group>
<group>
<field name='routing_tmpl_ids'>
<tree editable='bottom'>
<field name="sequence" widget="handle"/>
<field name="route_workcenter_id" string="工序"/>
</tree>
</field>
</group>
</form>
</field>
</record>
<record id="action_sf_model_type" model="ir.actions.act_window">
<field name="name">模型类型</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.model.type</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
[模型类型] 还没有哦!点左上角的[创建]按钮,沙发归你了!
</p>
<p>
</p>
</field>
</record>
</odoo>

View File

@@ -293,24 +293,10 @@
<field name="name">sf.tray.search</field>
<field name="model">sf.tray</field>
<field name="arch" type="xml">
<search string="托盘">
<field name="name" string="名称" filter_domain="[('name','like',self)]"/>
<field name="code" string="编码" filter_domain="[('code','like',self)]"/>
</search>
<group string="分组">
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
</group>
<!-- </group>-->
<search string="托盘">
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
</search>
</field>
</record>
@@ -347,18 +333,5 @@
</record>
<record id="action_sf_tray" model="ir.actions.act_window">
<field name="name">托盘</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.tray</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
创建托盘吧
</p>
</field>
</record>
</data>
</odoo>

View File

@@ -12,9 +12,7 @@
'website': 'https://www.sf.cs.jikimo.com',
'depends': ['sale', 'sf_base'],
'data': [
'data/product_data.xml',
'views/product_template_view.xml',
'views/sale_order_view.xml'
],
'demo': [
],

View File

@@ -1,5 +1,3 @@
from . import sale_order
from . import product_template
from . import http
from . import models

View File

@@ -1,86 +0,0 @@
from odoo import models, fields
from odoo.exceptions import ValidationError
class ResProductTemplate(models.Model):
_inherit = 'product.template'
# 模型的长,宽,高,体积,精度,材料
model_long = fields.Float('长[mm]', digits=(16, 3))
model_width = fields.Float('宽[mm]', digits=(16, 3))
model_height = fields.Float('高[mm]', digits=(16, 3))
model_volume = fields.Float('体积[mm³]', digits=(16, 3))
model_precision = fields.Float('精度要求', digits=(16, 3))
model_materials_id = fields.Many2one('mrs.production.materials', string='材料')
model_materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
# 胚料的长,宽,高
embryo_long = fields.Float('长[mm]', digits=(16, 3))
embryo_width = fields.Float('宽[mm]', digits=(16, 3))
embryo_height = fields.Float('高[mm]', digits=(16, 3))
embryo_materials_id = fields.Many2one('mrs.production.materials', string='材料')
embryo_materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
def product_create(self, product_id, item, order_id, order_number, i):
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
copy_product_id.product_tmpl_id.active = True
vals = {
'name': '%s-%s' % (order_id.name, i),
'model_long': item['model_long'],
'model_width': item['model_width'],
'model_height': item['model_height'],
'model_volume': item['model_volume'],
'list_price': item['price'],
'model_materials_id': self.env['mrs.production.materials'].search(
[('materials_no', '=', item['texture_code'])]).id,
'model_materials_type_id': self.env['mrs.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id,
'default_code': '%s-%s' % (order_number, i),
'barcode': item['barcode'],
'active': True
}
copy_product_id.sudo().write(vals)
return copy_product_id
class ResProductCategory(models.Model):
_inherit = "product.category"
is_embryo = fields.Boolean('胚料')
class ResMrpBom(models.Model):
_inherit = 'mrp.bom'
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
def bom_create(self, product):
bom_id = self.env['mrp.bom'].create({
'product_tmpl_id': product.product_tmpl_id.id,
'type': 'normal',
'product_qty': 1,
'product_uom_id': 1
})
return bom_id
# 生成产品BOM匹配胚料胚料的匹配规则
# 一、匹配的胚料类别需要带有胚料的标签;
# 二、胚料的材料型号与生成产品的材料型号一致;
# 三、胚料的长宽高均要大于模型的长宽高;
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
def bom_create_Line(self, product):
embryo = self.env['product.product'].search(
[('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id),
('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
('embryo_height', '>', product.model_height)
],
limit=1,
order='volume desc'
)
vals = {
'bom_id': self.id,
'product_id': embryo.id,
'product_tmpl_id': embryo.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': 1
}
return self.env['mrp.bom.line'].create(vals)

View File

@@ -1,34 +0,0 @@
from odoo import models, fields
from odoo.exceptions import ValidationError
import datetime
class ReSaleOrder(models.Model):
_inherit = 'sale.order'
deadline_of_delivery = fields.Date('交货截止日期')
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, deadline_of_delivery, company_id):
now_time = datetime.datetime.now()
order_id = self.env['sale.order'].sudo().create({
'company_id': company_id.id,
'date_order': now_time,
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
'partner_id': 8,
'state': 'sale',
'user_id': 6,
'deadline_of_delivery': deadline_of_delivery
})
return order_id
# 业务平台分配工厂时在创建完产品后再创建销售明细信息
def sale_order_create_line(self, product, item):
vals = {
'order_id': self.id,
'product_id': product.id,
'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.model_materials_id.name),
'price_unit': item['price'],
'product_uom_qty': item['number']
}
return self.env['sale.order.line'].create(vals)

View File

@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record model="ir.ui.view" id="view_product_template_form_inherit_sf">
<field name="name">product.template.form.inherit.sf</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[last()]" position="after">
<page string="CNC加工">
<group string="模型">
<group>
<field name="model_long"/>
<field name="model_width"/>
<field name="model_height"/>
<field name="model_volume"/>
</group>
<group>
<field name="model_precision"/>
<field name="model_materials_id"/>
<field name="model_materials_type_id"/>
</group>
</group>
</page>
</xpath>
<xpath expr="//label[@for='volume']" position="before">
<label for="embryo_long" string="尺寸"
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
<div class="o_address_format"
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
<label for="embryo_long" string="长"/>
<field name="embryo_long" class="o_address_zip"/>
<span>&amp;nbsp;</span>
<label for="embryo_width" string="宽"/>
<field name="embryo_width" class="o_address_zip"/>
<span>&amp;nbsp;</span>
<label for="embryo_height" string="高"/>
<field name="embryo_height" class="o_address_zip"/>
</div>
</xpath>
<xpath expr="//label[@for='produce_delay']" position="before">
<label for="embryo_materials_id"
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
<div class="o_row"
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
<field name="embryo_materials_id"/>
</div>
<label for="embryo_materials_type_id"
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
<div class="o_row"
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
<field name="embryo_materials_type_id" domain="[('materials_id', '=', embryo_materials_id)]"/>
</div>
</xpath>
</field>
</record>
<record id="view_product_category_form_inherit_sf" model="ir.ui.view">
<field name="name">product.category.form.inherit.sf</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<field name="parent_id" position="before">
<field name="is_embryo"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record model="ir.ui.view" id="view_sale_order_form_inherit_sf">
<field name="name">sale.order.form.inherit.sf</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="payment_term_id" position="after">
<field name="deadline_of_delivery"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -11,5 +11,13 @@ class ResMrpWorkOrder(models.Model):
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
processing_panel = fields.Char('加工面')
routing_type = fields.Selection([
('获取CNC加工程序', '获取CNC加工程序'),
('装夹', '装夹'),
('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('置三元质量检测', '置三元质量检测'),
('解除装夹', '解除装夹'),
], string="工序类型")

View File

@@ -74,6 +74,7 @@ class MrpProduction(models.Model):
'operation_id': False,
'name': route.route_workcenter_id.name,
'processing_panel': k,
'routing_type': route.route_workcenter_id.routing_type,
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
'date_planned_start': False,
'date_planned_finished': False,