修改胚料部分
This commit is contained in:
@@ -196,8 +196,7 @@ class MachineTool(models.Model):
|
|||||||
kw = json.dumps(machine_tool_list, ensure_ascii=False)
|
kw = json.dumps(machine_tool_list, ensure_ascii=False)
|
||||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
self.code = ret['code']
|
self.code = ret['message']
|
||||||
print(r)
|
|
||||||
if r == 200:
|
if r == 200:
|
||||||
return "机床注册成功"
|
return "机床注册成功"
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ class MrsMaterialModel(models.Model):
|
|||||||
density = fields.Float("密度(kg/m³)")
|
density = fields.Float("密度(kg/m³)")
|
||||||
materials_id = fields.Many2one('sf.production.materials', "材料名")
|
materials_id = fields.Many2one('sf.production.materials', "材料名")
|
||||||
remark = fields.Text("备注")
|
remark = fields.Text("备注")
|
||||||
|
gain_way = fields.Selection(
|
||||||
|
[("自加工", "自加工"), ("外协", "外协"), ("采购", "采购")],
|
||||||
|
default="", string="获取方式")
|
||||||
|
supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商')
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +67,6 @@ class MrsProcessingOrder(models.Model):
|
|||||||
_name = 'sf.processing.order'
|
_name = 'sf.processing.order'
|
||||||
_description = '工序'
|
_description = '工序'
|
||||||
sequence = fields.Integer('Sequence')
|
sequence = fields.Integer('Sequence')
|
||||||
|
|
||||||
processing_technology_ids = fields.Many2many('sf.processing.technology', 'sf_associated_processes',
|
processing_technology_ids = fields.Many2many('sf.processing.technology', 'sf_associated_processes',
|
||||||
index=True, string='加工工艺')
|
index=True, string='加工工艺')
|
||||||
production_process_id = fields.Many2one('sf.production.process', string="表面工艺")
|
production_process_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||||
@@ -79,3 +82,17 @@ class Tray(models.Model):
|
|||||||
[("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")],
|
[("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")],
|
||||||
default="空闲", string="状态")
|
default="空闲", string="状态")
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
|
class SupplierSort(models.Model):
|
||||||
|
_name = 'sf.supplier.sort'
|
||||||
|
_description = '供应商排序'
|
||||||
|
|
||||||
|
sequence = fields.Integer('Sequence')
|
||||||
|
partner_id = fields.Many2one('res.partner', domain="[('is_company', '=', True),('supplier_rank', '!=', 0)]")
|
||||||
|
materials_model_id = fields.Many2one('sf.materials.model')
|
||||||
|
|
||||||
|
_sql_constraints = [
|
||||||
|
('supplier_sort_uniq', 'unique (partner_id,materials_model_id)', '排序不能重复!')
|
||||||
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ access_sf_production_materials,sf_production_materials,model_sf_production_mater
|
|||||||
access_sf_materials_model,sf_materials_model,model_sf_materials_model,base.group_user,1,1,1,1
|
access_sf_materials_model,sf_materials_model,model_sf_materials_model,base.group_user,1,1,1,1
|
||||||
access_sf_processing_technology,sf_processing_technology,model_sf_processing_technology,base.group_user,1,1,1,1
|
access_sf_processing_technology,sf_processing_technology,model_sf_processing_technology,base.group_user,1,1,1,1
|
||||||
access_sf_tray,sf_tray,model_sf_tray,base.group_user,1,1,1,1
|
access_sf_tray,sf_tray,model_sf_tray,base.group_user,1,1,1,1
|
||||||
|
access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,base.group_user,1,1,1,1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -6,23 +6,17 @@
|
|||||||
<field name="model">sf.processing.technology</field>
|
<field name="model">sf.processing.technology</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="加工工艺">
|
<form string="加工工艺">
|
||||||
|
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="process_encode" readonly="1"/>
|
<field name="process_encode" readonly="1"/>
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="remark"/>
|
<field name="remark"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -30,10 +24,8 @@
|
|||||||
<field name="model">sf.processing.technology</field>
|
<field name="model">sf.processing.technology</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="加工工艺">
|
<tree string="加工工艺">
|
||||||
|
|
||||||
<field name="process_encode"/>
|
<field name="process_encode"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -52,13 +44,13 @@
|
|||||||
<field name="model">sf.production.process</field>
|
<field name="model">sf.production.process</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="表面工艺">
|
<tree string="表面工艺">
|
||||||
|
|
||||||
<field name="process_encode" readonly="1"/>
|
<field name="process_encode" readonly="1"/>
|
||||||
<field name="name" readonly="1"/>
|
<field name="name" readonly="1"/>
|
||||||
<field name="remark"/>
|
<field name="remark"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="sf_production_process_form">
|
<record model="ir.ui.view" id="sf_production_process_form">
|
||||||
<field name="model">sf.production.process</field>
|
<field name="model">sf.production.process</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
@@ -77,9 +69,7 @@
|
|||||||
</field>
|
</field>
|
||||||
</tree>
|
</tree>
|
||||||
<form>
|
<form>
|
||||||
|
|
||||||
<field name="processing_technology_ids" widget="many2many">
|
<field name="processing_technology_ids" widget="many2many">
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
@@ -110,24 +100,28 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="materials_no" readonly="1"/>
|
<field name="materials_no" readonly="1"/>
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
|
<field name="gain_way" required="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="density" required="1"/>
|
||||||
<field name="need_h" default="false"/>
|
<field name="need_h" default="false"/>
|
||||||
<field name="mf_materia_post" attrs="{'invisible':[('need_h','=',False)]} "/>
|
<field name="mf_materia_post" attrs="{'invisible':[('need_h','=',False)]} "/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group>
|
<group>
|
||||||
<field name='materials_id' default="default" invisible="1"/>
|
<field name='materials_id' default="default" invisible="1"/>
|
||||||
<field name="density" required="1"/>
|
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name='supplier_ids'>
|
||||||
|
<tree editable='bottom'>
|
||||||
|
<field name="sequence" widget="handle" string="序号"/>
|
||||||
|
<field name="partner_id" string="名称"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="remark"/>
|
<field name="remark"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.cs.jikimo.com',
|
'website': 'https://www.sf.cs.jikimo.com',
|
||||||
'depends': ['sf_base'],
|
'depends': ['sf_base', 'sf_sale', 'sf_dlm'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'views/res_partner_view.xml'
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from odoo.http import request
|
|||||||
|
|
||||||
class Sf_Bf_Connect(http.Controller):
|
class Sf_Bf_Connect(http.Controller):
|
||||||
|
|
||||||
@http.route('/api/bfm_process_order/list', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/api/bfm_process_order/list', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def get_bfm_process_order_list(self, **kw):
|
def get_bfm_process_order_list(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -23,17 +23,43 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
ret = json.loads(ret['result'])
|
||||||
product_id = request.env.ref('sf_dlm.product_template_sf').sudo()
|
product_id = request.env.ref('sf_dlm.product_template_sf').sudo()
|
||||||
|
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()
|
company_id = request.env.ref('base.main_company').sudo()
|
||||||
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(ret['delivery_end_date'], company_id)
|
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
|
||||||
|
company_id, ret['delivery_name'], ret['delivery_telephone'], ret['delivery_address'],
|
||||||
|
ret['delivery_end_date'])
|
||||||
i = 1
|
i = 1
|
||||||
for item in ret['bfm_process_order_list']:
|
for item in ret['bfm_process_order_list']:
|
||||||
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
ret['order_number'], i)
|
ret['order_number'], i)
|
||||||
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(product)
|
bom_data = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).get_bom(product)
|
||||||
bom.with_user(request.env.ref("base.user_admin")).bom_create_Line(product)
|
if bom_data:
|
||||||
i += 1
|
bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(product,
|
||||||
res['factory_order_no'] = order_id.name
|
'normal')
|
||||||
|
bom.with_user(request.env.ref("base.user_admin")).bom_create_Line(product)
|
||||||
|
else:
|
||||||
|
if product.materials_id.gain_way == '自加工':
|
||||||
|
self_machining = request.env['product.template'].sudo().no_bom_product_create(self_machining_id,
|
||||||
|
item,
|
||||||
|
order_i)
|
||||||
|
bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(
|
||||||
|
self_machining, 'normal')
|
||||||
|
bom.with_user(request.env.ref("base.user_admin")).bom_create_Line(self_machining)
|
||||||
|
|
||||||
|
elif product.materials_id.gain_way == '外协':
|
||||||
|
outsource = request.env['product.template'].sudo().no_bom_product_create(outsource_id, item,
|
||||||
|
order_id)
|
||||||
|
bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(outsource)
|
||||||
|
bom.with_user(request.env.ref("base.user_admin")).bom_create_Line(outsource, 'subcontract')
|
||||||
|
elif product.materials_id.gain_way == '采购':
|
||||||
|
purchase = request.env['product.template'].sudo().no_bom_product_create(purchase_id, item,
|
||||||
|
order_id)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
res['factory_order_no'] = order_id.name
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('get_bfm_process_order_list error:%s' % e)
|
logging.info('get_bfm_process_order_list error:%s' % e)
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import datetime
|
|||||||
import time
|
import time
|
||||||
import hashlib
|
import hashlib
|
||||||
from odoo import fields, models, api
|
from odoo import fields, models, api
|
||||||
from odoo.http import request, AuthenticationError
|
from odoo.http import request
|
||||||
|
|
||||||
__author__ = 'jinling.yang'
|
__author__ = 'jinling.yang'
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class AuthenticationError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class Http(models.AbstractModel):
|
class Http(models.AbstractModel):
|
||||||
_inherit = 'ir.http'
|
_inherit = 'ir.http'
|
||||||
@@ -23,6 +25,7 @@ class Http(models.AbstractModel):
|
|||||||
# 查询密钥
|
# 查询密钥
|
||||||
factory_secret = request.env['res.partner'].sudo().search(
|
factory_secret = request.env['res.partner'].sudo().search(
|
||||||
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
|
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
|
||||||
|
logging.info('factory_secret:%s' % factory_secret)
|
||||||
if not factory_secret:
|
if not factory_secret:
|
||||||
raise AuthenticationError('无效的token')
|
raise AuthenticationError('无效的token')
|
||||||
timestamp_str = int(time.time())
|
timestamp_str = int(time.time())
|
||||||
|
|||||||
@@ -25,4 +25,5 @@ class ResPartner(models.Model):
|
|||||||
return ran_str
|
return ran_str
|
||||||
|
|
||||||
sf_token = fields.Char(u'Token', default=get_token)
|
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)
|
||||||
|
|
||||||
|
|||||||
20
sf_bf_connect/views/res_partner_view.xml
Normal file
20
sf_bf_connect/views/res_partner_view.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_partner_form_sf" model="ir.ui.view">
|
||||||
|
<field name="name">view_partner_form</field>
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//page[last()]" position="before">
|
||||||
|
<page string="token和密钥">
|
||||||
|
<group>
|
||||||
|
<field name="sf_token"/>
|
||||||
|
<field name="sf_secret_key"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['mrp', 'base', 'sf_manufacturing'],
|
'depends': ['mrp', 'base', 'sf_manufacturing'],
|
||||||
'data': [
|
'data': [
|
||||||
# 'data/product_data.xml',
|
'data/product_data.xml',
|
||||||
'views/product_template_view.xml'
|
'views/product_template_view.xml'
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data noupdate="1">
|
<data>
|
||||||
<record id="product_template_sf" model="product.product">
|
<record id="product_template_sf" model="product.product">
|
||||||
<field name="name">CNC加工产品模板</field>
|
<field name="name">CNC加工产品模板</field>
|
||||||
<field name="categ_id" ref="product.product_category_5"/>
|
<!-- <field name="categ_id" ref="product.product_category_5"/>-->
|
||||||
<field name="invoice_policy">delivery</field>
|
<field name="invoice_policy">delivery</field>
|
||||||
<field name="detailed_type">product</field>
|
<field name="detailed_type">product</field>
|
||||||
<field name="purchase_ok">false</field>
|
<field name="purchase_ok">false</field>
|
||||||
@@ -12,5 +12,48 @@
|
|||||||
<field name="company_id" ref="base.main_company"/>
|
<field name="company_id" ref="base.main_company"/>
|
||||||
<field name="active">false</field>
|
<field name="active">false</field>
|
||||||
</record>
|
</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>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class ResProductTemplate(models.Model):
|
class ResProductTemplate(models.Model):
|
||||||
@@ -9,7 +10,7 @@ class ResProductTemplate(models.Model):
|
|||||||
model_long = fields.Float('模型长[mm]', digits=(16, 3))
|
model_long = fields.Float('模型长[mm]', digits=(16, 3))
|
||||||
model_width = fields.Float('模型宽[mm]', digits=(16, 3))
|
model_width = fields.Float('模型宽[mm]', digits=(16, 3))
|
||||||
model_height = fields.Float('模型高[mm]', digits=(16, 3))
|
model_height = fields.Float('模型高[mm]', digits=(16, 3))
|
||||||
model_volume = fields.Float('模型体积[mm]', compute='_compute_model_volume', store=True)
|
model_volume = fields.Float('模型体积[m³]')
|
||||||
model_machining_precision = fields.Selection([
|
model_machining_precision = fields.Selection([
|
||||||
('±0.10mm', '±0.10mm'),
|
('±0.10mm', '±0.10mm'),
|
||||||
('±0.05mm', '±0.05mm'),
|
('±0.05mm', '±0.05mm'),
|
||||||
@@ -22,35 +23,50 @@ class ResProductTemplate(models.Model):
|
|||||||
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
|
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
|
||||||
model_price = fields.Float('模型单价', digits=(16, 3))
|
model_price = fields.Float('模型单价', digits=(16, 3))
|
||||||
model_remark = fields.Char('模型备注说明')
|
model_remark = fields.Char('模型备注说明')
|
||||||
long = fields.Float('长[mm]', digits=(16, 3))
|
length = fields.Float('长[mm]', digits=(16, 3))
|
||||||
width = fields.Float('宽[mm]', digits=(16, 3))
|
width = fields.Float('宽[mm]', digits=(16, 3))
|
||||||
height = fields.Float('高[mm]', digits=(16, 3))
|
height = fields.Float('高[mm]', digits=(16, 3))
|
||||||
materials_id = fields.Many2one('sf.production.materials', string='材料')
|
materials_id = fields.Many2one('sf.production.materials', string='材料')
|
||||||
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
|
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
|
||||||
volume = fields.Float(compute='_compute_volume', store=True)
|
# volume = fields.Float(compute='_compute_volume', store=True)
|
||||||
|
|
||||||
single_manufacturing = fields.Boolean(string="单个制造")
|
single_manufacturing = fields.Boolean(string="单个制造")
|
||||||
|
|
||||||
@api.depends('long', 'width', 'height')
|
@api.model
|
||||||
def _compute_volume(self):
|
def _get_route(self):
|
||||||
self.volume = self.long * self.width * self.height
|
route_manufacture = self.env.ref('stock.warehouse0', raise_if_not_found=False).manufacture_pull_id.route_id.id
|
||||||
|
route_mto = self.env.ref('stock.warehouse0', raise_if_not_found=False).mto_pull_id.route_id.id
|
||||||
|
if route_manufacture and route_mto:
|
||||||
|
return [route_manufacture, route_mto]
|
||||||
|
return []
|
||||||
|
|
||||||
@api.depends('model_long', 'model_width', 'model_height')
|
route_ids = fields.Many2many(default=lambda self: self._get_route())
|
||||||
def _compute_model_volume(self):
|
|
||||||
self.model_volume = self.model_long * self.model_width * self.model_height
|
# @api.depends('long', 'width', 'height')
|
||||||
|
# def _compute_volume(self):
|
||||||
|
# self.volume = self.long * self.width * self.height
|
||||||
|
|
||||||
|
# @api.depends('model_long', 'model_width', 'model_height')
|
||||||
|
# def _compute_model_volume(self):
|
||||||
|
# self.model_volume = self.model_long * self.model_width * self.model_height
|
||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||||
def product_create(self, product_id, item, order_id, order_number, i):
|
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_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||||
copy_product_id.product_tmpl_id.active = True
|
copy_product_id.product_tmpl_id.active = True
|
||||||
|
logging.info('product_create:%s' % item)
|
||||||
vals = {
|
vals = {
|
||||||
'name': '%s-%s' % (order_id.name, i),
|
'name': '%s-%s' % (order_id.name, i),
|
||||||
'model_long': item['model_long'],
|
'model_long': item['model_long'],
|
||||||
'model_width': item['model_width'],
|
'model_width': item['model_width'],
|
||||||
'model_height': item['model_height'],
|
'model_height': item['model_height'],
|
||||||
'model_volume': item['model_volume'],
|
'length': item['model_long'],
|
||||||
|
'width': item['model_width'],
|
||||||
|
'height': item['model_height'],
|
||||||
|
'volume': item['model_long'] * item['model_width'] * item['model_height'],
|
||||||
'model_price': item['price'],
|
'model_price': item['price'],
|
||||||
'model_total_amount': item['total_amount'],
|
'tracking': 'serial',
|
||||||
'model_number': item['number'],
|
'single_manufacturing': True,
|
||||||
'list_price': item['price'],
|
'list_price': item['price'],
|
||||||
'materials_id': self.env['sf.production.materials'].search(
|
'materials_id': self.env['sf.production.materials'].search(
|
||||||
[('materials_no', '=', item['texture_code'])]).id,
|
[('materials_no', '=', item['texture_code'])]).id,
|
||||||
@@ -61,10 +77,47 @@ class ResProductTemplate(models.Model):
|
|||||||
# 'model_process_parameters_id': self.env['sf.processing.technology'].search(
|
# 'model_process_parameters_id': self.env['sf.processing.technology'].search(
|
||||||
# [('process_encode', '=', item['process_parameters_code'])]).id,
|
# [('process_encode', '=', item['process_parameters_code'])]).id,
|
||||||
'model_remark': item['remark'],
|
'model_remark': item['remark'],
|
||||||
'default_code': '%s-%s' % (order_number, i),
|
# 'default_code': '%s-%s' % (order_number, i),
|
||||||
'barcode': item['barcode'],
|
# 'barcode': item['barcode'],
|
||||||
'active': True
|
'active': True
|
||||||
}
|
}
|
||||||
|
logging.info('product_create1:%s' % item)
|
||||||
|
copy_product_id.sudo().write(vals)
|
||||||
|
return copy_product_id
|
||||||
|
|
||||||
|
def no_bom_product_create(self, product_id, item, order_id):
|
||||||
|
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||||
|
copy_product_id.product_tmpl_id.active = True
|
||||||
|
logging.info('no_bom_product_create:%s' % item)
|
||||||
|
materials_id = self.env['sf.production.materials'].search(
|
||||||
|
[('materials_no', '=', item['texture_code'])]).id
|
||||||
|
materials_type_id = self.env['sf.materials.model'].search(
|
||||||
|
[('materials_no', '=', item['texture_type_code'])]).id
|
||||||
|
vals = {
|
||||||
|
'name': '%s %s %s %s * %s * %s' % (
|
||||||
|
order_id.name, materials_id.name, materials_type_id.name, item['model_long'], item['model_width'],
|
||||||
|
item['model_height']),
|
||||||
|
'model_long': item['model_long'],
|
||||||
|
'model_width': item['model_width'],
|
||||||
|
'model_height': item['model_height'],
|
||||||
|
'model_volume': item['model_long'] * item['model_width'] * item['model_height'],
|
||||||
|
'length': item['model_long'],
|
||||||
|
'width': item['model_width'],
|
||||||
|
'height': item['model_height'],
|
||||||
|
'volume': item['model_long'] * item['model_width'] * item['model_height'],
|
||||||
|
'model_price': item['price'],
|
||||||
|
'tracking': 'serial',
|
||||||
|
'single_manufacturing': True,
|
||||||
|
'list_price': item['price'],
|
||||||
|
'materials_id': materials_id.id,
|
||||||
|
'materials_type_id': materials_type_id.id,
|
||||||
|
# 'model_surface_process_id': self.env['sf.production.process'].search(
|
||||||
|
# [('process_encode', '=', item['surface_process_code'])]).id,
|
||||||
|
# 'model_process_parameters_id': self.env['sf.processing.technology'].search(
|
||||||
|
# [('process_encode', '=', item['process_parameters_code'])]).id,
|
||||||
|
'active': True
|
||||||
|
}
|
||||||
|
logging.info('product_create1:%s' % item)
|
||||||
copy_product_id.sudo().write(vals)
|
copy_product_id.sudo().write(vals)
|
||||||
return copy_product_id
|
return copy_product_id
|
||||||
|
|
||||||
@@ -94,10 +147,10 @@ class ResMrpBom(models.Model):
|
|||||||
_inherit = 'mrp.bom'
|
_inherit = 'mrp.bom'
|
||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
||||||
def bom_create(self, product):
|
def bom_create(self, product, bom_type):
|
||||||
bom_id = self.env['mrp.bom'].create({
|
bom_id = self.env['mrp.bom'].create({
|
||||||
'product_tmpl_id': product.product_tmpl_id.id,
|
'product_tmpl_id': product.product_tmpl_id.id,
|
||||||
'type': 'normal',
|
'type': bom_type,
|
||||||
'product_qty': 1,
|
'product_qty': 1,
|
||||||
'product_uom_id': 1
|
'product_uom_id': 1
|
||||||
})
|
})
|
||||||
@@ -108,26 +161,56 @@ class ResMrpBom(models.Model):
|
|||||||
# 二、胚料的材料型号与生成产品的材料型号一致;
|
# 二、胚料的材料型号与生成产品的材料型号一致;
|
||||||
# 三、胚料的长宽高均要大于模型的长宽高;
|
# 三、胚料的长宽高均要大于模型的长宽高;
|
||||||
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
||||||
def bom_create_Line(self, product):
|
# 创建新的胚料,根据胚料材料型号的获取方式(
|
||||||
|
# 自加工,外协,采购) 的配置, 选择不同的库存路线,一种材料型号配置一个路线相关的配置:
|
||||||
|
# 材料型号配置不同的获取方式: (自加工, 外协, 采购);
|
||||||
|
# 原材料重量KG(公斤)= 胚料的体积(立方米m³) * 材料密度 * 1000
|
||||||
|
def bom_create_Line(self, embryo, materials):
|
||||||
|
bom_line = self.get_raw_bom(embryo, materials)
|
||||||
|
vals = {
|
||||||
|
'bom_id': self.id,
|
||||||
|
'product_id': bom_line.id,
|
||||||
|
'product_tmpl_id': bom_line.product_tmpl_id.id,
|
||||||
|
'product_qty': bom_line.volume * bom_line.materials_type_id.density * 1000,
|
||||||
|
'product_uom_id': bom_line.uom_id.id
|
||||||
|
}
|
||||||
|
return self.env['mrp.bom.line'].create(vals)
|
||||||
|
|
||||||
|
def get_bom(self, product):
|
||||||
embryo = self.env['product.product'].search(
|
embryo = self.env['product.product'].search(
|
||||||
[('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
|
[('categ_id.type', '=', '胚料'), ('materials_type_id', '=', product.materials_type_id.id),
|
||||||
('long', '>', product.long), ('width', '>', product.width),
|
('length', '>', product.length), ('width', '>', product.width),
|
||||||
('height', '>', product.height)
|
('height', '>', product.height)
|
||||||
],
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
order='volume desc'
|
order='volume desc'
|
||||||
)
|
)
|
||||||
vals = {
|
if embryo:
|
||||||
'bom_id': self.id,
|
rate_of_waste = ((embryo.volume - product.model_volume) % embryo.volume) * 100
|
||||||
'product_id': embryo.id,
|
if rate_of_waste <= 20:
|
||||||
'product_tmpl_id': embryo.product_tmpl_id.id,
|
return embryo
|
||||||
'product_qty': 1,
|
else:
|
||||||
'product_uom_id': 1
|
return
|
||||||
}
|
|
||||||
return self.env['mrp.bom.line'].create(vals)
|
# 查bom的原材料
|
||||||
|
def get_raw_bom(self, product):
|
||||||
|
raw_bom = self.env['product.product'].search(
|
||||||
|
[('categ_id.type', '=', '原材料'), ('materials_type_id', '=', product.materials_type_id.id)])
|
||||||
|
return raw_bom
|
||||||
|
|
||||||
|
|
||||||
class ResProductCategory(models.Model):
|
class ResProductCategory(models.Model):
|
||||||
_inherit = "product.category"
|
_inherit = "product.category"
|
||||||
|
|
||||||
is_embryo = fields.Boolean('胚料')
|
type = fields.Selection(
|
||||||
|
[("成品", "成品"), ("胚料", "胚料"), ("原材料", "原材料")],
|
||||||
|
default="", string="类型")
|
||||||
|
|
||||||
|
# @api.constrains('type')
|
||||||
|
# def _check_type(self):
|
||||||
|
# category = self.env['product.category'].search(
|
||||||
|
# [('type', '=', self.type)])
|
||||||
|
# if category:
|
||||||
|
# raise ValidationError("该类别已存在,请选择其他类别")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
</field>
|
</field>
|
||||||
|
|
||||||
<xpath expr="//label[@for='volume']" position="before">
|
<xpath expr="//label[@for='volume']" position="before">
|
||||||
<label for="long" string="尺寸"
|
<label for="length" string="尺寸"
|
||||||
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
||||||
<div class="o_address_format"
|
<div class="o_address_format"
|
||||||
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
|
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
|
||||||
<label for="long" string="长"/>
|
<label for="length" string="长"/>
|
||||||
<field name="long" class="o_address_zip"/>
|
<field name="length" class="o_address_zip"/>
|
||||||
<span>&nbsp;</span>
|
<span>&nbsp;</span>
|
||||||
<label for="width" string="宽"/>
|
<label for="width" string="宽"/>
|
||||||
<field name="width" class="o_address_zip"/>
|
<field name="width" class="o_address_zip"/>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<field name="model_long" string="长[mm]"/>
|
<field name="model_long" string="长[mm]"/>
|
||||||
<field name="model_width" string="宽[mm]"/>
|
<field name="model_width" string="宽[mm]"/>
|
||||||
<field name="model_height" string="高[mm]"/>
|
<field name="model_height" string="高[mm]"/>
|
||||||
<field name="model_volume" string="体积[mm]"/>
|
<field name="model_volume" string="体积[m³]"/>
|
||||||
<field name="model_type_id" string="模型类型"/>
|
<field name="model_type_id" string="模型类型"/>
|
||||||
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
|
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
|
||||||
<field name="model_machining_precision" />
|
<field name="model_machining_precision" />
|
||||||
@@ -48,16 +48,16 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_product_category_form_inherit_sf" model="ir.ui.view">
|
<!-- <record id="view_product_category_form_inherit_sf" model="ir.ui.view">-->
|
||||||
<field name="name">product.category.form.inherit.sf</field>
|
<!-- <field name="name">product.category.form.inherit.sf</field>-->
|
||||||
<field name="model">product.category</field>
|
<!-- <field name="model">product.category</field>-->
|
||||||
<field name="inherit_id" ref="product.product_category_form_view"/>
|
<!-- <field name="inherit_id" ref="product.product_category_form_view"/>-->
|
||||||
<field name="arch" type="xml">
|
<!-- <field name="arch" type="xml">-->
|
||||||
<field name="parent_id" position="before">
|
<!-- <field name="parent_id" position="before">-->
|
||||||
<field name="is_embryo"/>
|
<!-- <field name="type"/>-->
|
||||||
</field>
|
<!-- </field>-->
|
||||||
</field>
|
<!-- </field>-->
|
||||||
</record>
|
<!-- </record>-->
|
||||||
|
|
||||||
<record id="view_template_property_form" model="ir.ui.view">
|
<record id="view_template_property_form" model="ir.ui.view">
|
||||||
<field name="name">product.template.stock.property.form.inherit</field>
|
<field name="name">product.template.stock.property.form.inherit</field>
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
def action_generate_serial(self):
|
def action_generate_serial(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
self.lot_producing_id = self.env['stock.production.lot'].create({
|
self.lot_producing_id = self.env['stock.lot'].create({
|
||||||
'product_id': self.product_id.id,
|
'product_id': self.product_id.id,
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.company_id.id,
|
||||||
'name': self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
|
'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
|
||||||
'ir.sequence'].next_by_code('stock.lot.serial'),
|
'ir.sequence'].next_by_code('stock.lot.serial'),
|
||||||
})
|
})
|
||||||
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
|
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
|
||||||
|
|||||||
@@ -40,24 +40,24 @@ class ResMrpRoutingWorkcenter(models.Model):
|
|||||||
return self.env.cr.dictfetchall()[0].get('workcenter_id')
|
return self.env.cr.dictfetchall()[0].get('workcenter_id')
|
||||||
|
|
||||||
|
|
||||||
class ModelTypeRoutingSort(models.Model):
|
# class ModelTypeRoutingSort(models.Model):
|
||||||
_name = 'sf.model.type.routing.sort'
|
# _name = 'sf.model.type.routing.sort'
|
||||||
_description = '工序排序'
|
# _description = '工序排序'
|
||||||
|
#
|
||||||
sequence = fields.Integer('Sequence')
|
# sequence = fields.Integer('Sequence')
|
||||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
# route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
||||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
# is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||||
routing_type = fields.Selection([
|
# routing_type = fields.Selection([
|
||||||
('获取CNC加工程序', '获取CNC加工程序'),
|
# ('获取CNC加工程序', '获取CNC加工程序'),
|
||||||
('装夹', '装夹'),
|
# ('装夹', '装夹'),
|
||||||
('前置三元定位检测', '前置三元定位检测'),
|
# ('前置三元定位检测', '前置三元定位检测'),
|
||||||
('CNC加工', 'CNC加工'),
|
# ('CNC加工', 'CNC加工'),
|
||||||
('后置三元质量检测', '后置三元质量检测'),
|
# ('后置三元质量检测', '后置三元质量检测'),
|
||||||
('解除装夹', '解除装夹'),
|
# ('解除装夹', '解除装夹'),
|
||||||
], string="工序类型", related='route_workcenter_id.routing_type')
|
# ], string="工序类型", related='route_workcenter_id.routing_type')
|
||||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
# workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||||
model_type_id = fields.Many2one('sf.model.type')
|
# model_type_id = fields.Many2one('sf.model.type')
|
||||||
|
#
|
||||||
_sql_constraints = [
|
# _sql_constraints = [
|
||||||
('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
|
# ('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
|
||||||
]
|
# ]
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'material_type_code': cnc.env['sf.materials.model'].search(
|
'material_type_code': cnc.env['sf.materials.model'].search(
|
||||||
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
||||||
'machining_precision': cnc.product_id.model_machining_precision,
|
'machining_precision': cnc.product_id.model_machining_precision,
|
||||||
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.long,
|
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
||||||
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
||||||
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width
|
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width
|
||||||
# 'factory_code': self.env.user.company_id.partner_id.
|
# 'factory_code': self.env.user.company_id.partner_id.
|
||||||
@@ -345,7 +345,7 @@ class CNCprocessing(models.Model):
|
|||||||
|
|
||||||
# mrs下发编程单创建CNC加工
|
# mrs下发编程单创建CNC加工
|
||||||
def cnc_processing_create(self, obj):
|
def cnc_processing_create(self, obj):
|
||||||
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', obj['manufacturing_order_no']),
|
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', obj['production_order_no']),
|
||||||
('processing_panel', '=', obj['processing_panel']),
|
('processing_panel', '=', obj['processing_panel']),
|
||||||
('routing_type', '=', 'CNC加工')])
|
('routing_type', '=', 'CNC加工')])
|
||||||
vals = {
|
vals = {
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class StockRule(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class ProductionLot(models.Model):
|
class ProductionLot(models.Model):
|
||||||
_inherit = 'stock.production.lot'
|
_inherit = 'stock.lot'
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def generate_lot_names1(self, display_name, first_lot, count):
|
def generate_lot_names1(self, display_name, first_lot, count):
|
||||||
@@ -217,10 +217,10 @@ class ProductionLot(models.Model):
|
|||||||
def _get_next_serial(self, company, product):
|
def _get_next_serial(self, company, product):
|
||||||
"""Return the next serial number to be attributed to the product."""
|
"""Return the next serial number to be attributed to the product."""
|
||||||
if product.tracking == "serial":
|
if product.tracking == "serial":
|
||||||
last_serial = self.env['stock.production.lot'].search(
|
last_serial = self.env['stock.lot'].search(
|
||||||
[('company_id', '=', company.id), ('product_id', '=', product.id)],
|
[('company_id', '=', company.id), ('product_id', '=', product.id)],
|
||||||
limit=1, order='id DESC')
|
limit=1, order='id DESC')
|
||||||
if last_serial:
|
if last_serial:
|
||||||
return self.env['stock.production.lot'].generate_lot_names1(product.display_name, last_serial.name, 2)[
|
return self.env['stock.lot'].generate_lot_names1(product.display_name, last_serial.name, 2)[
|
||||||
1]
|
1]
|
||||||
return "%s-%03d" % (product.display_name, 1)
|
return "%s-%03d" % (product.display_name, 1)
|
||||||
|
|||||||
@@ -29,9 +29,11 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
# # 从ftp拉取对应的文件
|
# # 从ftp拉取对应的文件
|
||||||
model_code = cnc.workorder_id.product_id.barcode
|
model_code = cnc.workorder_id.product_id.barcode
|
||||||
processing_panel = cnc.workorder_id.processing_panel
|
processing_panel = cnc.workorder_id.processing_panel
|
||||||
|
logging.info('model_code:%s' % model_code)
|
||||||
server_dir = cnc.with_user(request.env.ref("base.user_admin")).download_file_tmp(model_code,
|
server_dir = cnc.with_user(request.env.ref("base.user_admin")).download_file_tmp(model_code,
|
||||||
processing_panel)
|
processing_panel)
|
||||||
cnc_file_path = os.path.join(server_dir, cnc.program_name + '.NC')
|
cnc_file_path = os.path.join(server_dir, cnc.program_name + '.NC')
|
||||||
|
logging.info('cnc_file_path:%s' % cnc_file_path)
|
||||||
cnc.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path, cnc)
|
cnc.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path, cnc)
|
||||||
# logging.info('get_cnc_processing_create:%s' % '111111111111111')
|
# logging.info('get_cnc_processing_create:%s' % '111111111111111')
|
||||||
# for root, dirs, files in os.walk(server_dir):
|
# for root, dirs, files in os.walk(server_dir):
|
||||||
|
|||||||
@@ -19,25 +19,24 @@ class FtpController():
|
|||||||
try:
|
try:
|
||||||
self.ftp.connect(host, port)
|
self.ftp.connect(host, port)
|
||||||
self.ftp.login(username, password)
|
self.ftp.login(username, password)
|
||||||
|
logging.info("连接成功: ")
|
||||||
except:
|
except:
|
||||||
logging.info("连接失败: ")
|
logging.info("连接失败: ")
|
||||||
|
|
||||||
# 下载目录下的文件
|
# 下载目录下的文件
|
||||||
def download_file_tree(self, remotepath, serverdir):
|
def download_file_tree(self, target_dir, serverdir):
|
||||||
|
self.ftp.cwd(target_dir) # 切换工作路径
|
||||||
if not os.path.exists(serverdir):
|
if not os.path.exists(serverdir):
|
||||||
os.makedirs(serverdir)
|
os.makedirs(serverdir)
|
||||||
self.ftp.cwd(remotepath)
|
remotenames = self.ftp.nlst()
|
||||||
remotenames = self.ftp.nlst()
|
for file in remotenames:
|
||||||
for file in remotenames:
|
server = os.path.join(serverdir, file)
|
||||||
server = os.path.join(serverdir, file)
|
if file.find(".") != -1:
|
||||||
if file.find(".") != -1:
|
self.download_file(server, file)
|
||||||
self.download_file(server, file)
|
return
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# 下载指定目录下的指定文件
|
# 下载指定目录下的指定文件
|
||||||
def download_file(self, serverfile, remotefile):
|
def download_file(self, serverfile, remotefile):
|
||||||
file_handler = open(serverfile, 'wb')
|
file_handler = open(serverfile, 'wb')
|
||||||
self.ftp.retrbinary('RETR ' + remotefile, file_handler.write)
|
self.ftp.retrbinary('RETR ' + remotefile, file_handler.write)
|
||||||
file_handler.close()
|
file_handler.close()
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sale', 'sale_management', 'sf_bf_connect', 'sf_dlm'],
|
'depends': ['sale', 'sale_management'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/sale_order_view.xml'
|
'views/sale_order_view.xml'
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from odoo import models, fields
|
from odoo import models, fields
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
import datetime
|
import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class ReSaleOrder(models.Model):
|
class ReSaleOrder(models.Model):
|
||||||
@@ -20,9 +21,9 @@ class ReSaleOrder(models.Model):
|
|||||||
'company_id': company_id.id,
|
'company_id': company_id.id,
|
||||||
'date_order': now_time,
|
'date_order': now_time,
|
||||||
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
|
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
|
||||||
'partner_id': 8,
|
'partner_id': 1,
|
||||||
'state': 'sale',
|
'state': 'sale',
|
||||||
'user_id': 6,
|
'user_id': 1,
|
||||||
'person_of_delivery': delivery_name,
|
'person_of_delivery': delivery_name,
|
||||||
'telephone_of_delivery': delivery_telephone,
|
'telephone_of_delivery': delivery_telephone,
|
||||||
'address_of_delivery': delivery_address,
|
'address_of_delivery': delivery_address,
|
||||||
|
|||||||
Reference in New Issue
Block a user