Compare commits

..

11 Commits

Author SHA1 Message Date
guanhuan
ba955ca658 快速订单上传模型文件检查文件后缀 2024-09-14 08:46:32 +08:00
guanhuan
ccbe311c58 快速订单填写的零件图号和零件图纸传给制造订单 2024-09-13 10:45:08 +08:00
guanhuan
4c58f4d7f3 快速订单填写的零件图号和零件图纸传给制造订单 2024-09-13 10:22:14 +08:00
guanhuan
b5a3815f1f 设备维保标准筛选添加已归档 2024-09-12 16:43:54 +08:00
guanhuan
988c4a460d 2D加工图纸改为pdf 2024-09-12 10:24:45 +08:00
guanhuan
c050e2f11a 供应商详情的采购员去掉必填 2024-09-12 10:14:38 +08:00
guanhuan
8bc68e1edd 表面工艺参数取消必填 2024-09-11 17:40:28 +08:00
guanhuan
ea6fd42b2e SF快速订单优化 2024-09-11 09:01:24 +08:00
guanhuan
625499f758 SF快速订单优化 2024-09-11 08:59:44 +08:00
guanhuan
0c2d6dd582 SF快速订单优化 2024-09-11 08:52:28 +08:00
guanhuan
005a7bb68e 建立设备维保标准,建立设备维保标准修复 2024-09-05 08:51:36 +08:00
21 changed files with 79 additions and 296 deletions

View File

@@ -12,6 +12,7 @@
</tree> </tree>
</field> </field>
</record> </record>
<record model="ir.ui.view" id="mrs_production_process_parameter_form"> <record model="ir.ui.view" id="mrs_production_process_parameter_form">
<field name="model">sf.production.process.parameter</field> <field name="model">sf.production.process.parameter</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@@ -25,19 +26,19 @@
<group> <group>
<group> <group>
<field name="code" readonly="1"/> <field name="code" readonly="1"/>
<field name="process_id" attrs="{'readonly': [('code', '!=', False)]}"/> <field name="process_id" readonly="1"/>
<field name="process_description" attrs="{'readonly': [('code', '!=', False)]}"/> <field name="process_description" readonly="1"/>
<field name="gain_way"/> <field name="gain_way"/>
</group> </group>
<group> <group>
<field name="processing_day" attrs="{'readonly': [('code', '!=', False)]}"/> <field name="processing_day" readonly="1"/>
<field name="travel_day" attrs="{'readonly': [('code', '!=', False)]}"/> <field name="travel_day" readonly="1"/>
<field name="processing_mm" attrs="{'readonly': [('code', '!=', False)]}"/> <field name="processing_mm" readonly="1"/>
</group> </group>
</group> </group>
<notebook> <notebook>
<page string="适用材料"> <page string="适用材料">
<field name="materials_model_ids" attrs="{'readonly': [('code', '!=', False)]}"></field> <field name="materials_model_ids" readonly="1"></field>
</page> </page>
</notebook> </notebook>
</sheet> </sheet>

View File

@@ -53,7 +53,7 @@ class StatusChange(models.Model):
if not ret.get('error'): if not ret.get('error'):
logging.info('接口已经执行=============') logging.info('接口已经执行=============')
else: else:
logging.error('工厂加工同步订单状态失败 {}'.format(ret)) logging.error('工厂加工同步订单状态失败 {}'.format(ret.text))
raise UserError('工厂加工同步订单状态失败') raise UserError('工厂加工同步订单状态失败')
except UserError as e: except UserError as e:
logging.error('工厂加工同步订单状态失败 {}'.format(e)) logging.error('工厂加工同步订单状态失败 {}'.format(e))

View File

@@ -24,6 +24,7 @@ class SfEquipmentSaintenanceStandards(models.Model):
remark = fields.Char('备注') remark = fields.Char('备注')
maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养') maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养')
name = fields.Char(string='名称') name = fields.Char(string='名称')
active = fields.Boolean(default=True)
@api.model_create_multi @api.model_create_multi
def create(self, vals_list): def create(self, vals_list):

View File

@@ -6,13 +6,14 @@
<field name="name">equipment.maintenance.standards.form</field> <field name="name">equipment.maintenance.standards.form</field>
<field name="model">equipment.maintenance.standards</field> <field name="model">equipment.maintenance.standards</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="设备维保标准"> <form string="设备维保标准" delete="false" duplicate="false">
<sheet> <sheet>
<group> <group>
<group> <group>
<field name="active" invisible="1"/>
<field name="code" readonly="1" force_save="1"/> <field name="code" readonly="1" force_save="1"/>
<field name="name" readonly="1" force_save="1"/> <field name="name" readonly="1" force_save="1"/>
<field name="maintenance_equipment_category_id" required="1" /> <field name="maintenance_equipment_category_id" required="1"/>
<field name="eq_maintenance_ids" invisible='1'/> <field name="eq_maintenance_ids" invisible='1'/>
<field name="overhaul_ids" invisible='1'/> <field name="overhaul_ids" invisible='1'/>
@@ -50,7 +51,8 @@
<field name="name">equipment.maintenance.standards.tree</field> <field name="name">equipment.maintenance.standards.tree</field>
<field name="model">equipment.maintenance.standards</field> <field name="model">equipment.maintenance.standards</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="设备维保标准"> <tree string="设备维保标准" delete="false">
<field name="active" invisible="1"/>
<field name="code" readonly="1" force_save="1"/> <field name="code" readonly="1" force_save="1"/>
<field name="maintenance_type" required="1"/> <field name="maintenance_type" required="1"/>
<field name="name" required="1"/> <field name="name" required="1"/>
@@ -77,6 +79,7 @@
<field name="name" string="日常机床保养"/> <field name="name" string="日常机床保养"/>
<field name="created_user_id" string="创建人"/> <field name="created_user_id" string="创建人"/>
<field name="maintenance_equipment_category_id" string="设备类别"/> <field name="maintenance_equipment_category_id" string="设备类别"/>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
</search> </search>
</field> </field>
</record> </record>

View File

@@ -477,7 +477,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('LocationChange error:%s' % e) logging.info('LocationChange error:%s' % e)
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False, @http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*") cors="*")
def AGVToProduct(self, **kw): def AGVToProduct(self, **kw):
""" """
@@ -549,7 +549,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('AGVToProduct error:%s' % e) logging.info('AGVToProduct error:%s' % e)
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False, @http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*") cors="*")
def AGVDownProduct(self, **kw): def AGVDownProduct(self, **kw):
""" """

View File

@@ -222,7 +222,7 @@ class ResMrpWorkOrder(models.Model):
material_width = fields.Float(string='') material_width = fields.Float(string='')
material_height = fields.Float(string='') material_height = fields.Float(string='')
# 零件图号 # 零件图号
part_number = fields.Char(string='零件图号') part_number = fields.Char(related='production_id.part_number', string='零件图号')
# 工序状态 # 工序状态
process_state = fields.Selection([ process_state = fields.Selection([
('待装夹', '待装夹'), ('待装夹', '待装夹'),

View File

@@ -267,6 +267,11 @@ class StockRule(models.Model):
workorder_duration += workorder.duration_expected workorder_duration += workorder.duration_expected
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
# 根据销售订单号查询快速订单
quick_easy_order = self.env['quick.easy.order'].sudo().search([('sale_order_id', '=', sale_order.id)])
if quick_easy_order:
production.write({'part_number': quick_easy_order.part_drawing_number,
'part_drawing': quick_easy_order.machining_drawings})
if sale_order: if sale_order:
# sale_order.write({'schedule_status': 'to schedule'}) # sale_order.write({'schedule_status': 'to schedule'})
self.env['sf.production.plan'].sudo().with_company(company_id).create({ self.env['sf.production.plan'].sudo().with_company(company_id).create({
@@ -288,6 +293,7 @@ class StockRule(models.Model):
# 为同一个product_id创建一个生产订单名称列表 # 为同一个product_id创建一个生产订单名称列表
product_id_to_production_names[product_id] = [production.name for production in all_production] product_id_to_production_names[product_id] = [production.name for production in all_production]
for production_item in productions: for production_item in productions:
production_programming = self.env['mrp.production'].search( production_programming = self.env['mrp.production'].search(
[('product_id.id', '=', production_item.product_id.id), [('product_id.id', '=', production_item.product_id.id),
('origin', '=', production_item.origin)], ('origin', '=', production_item.origin)],

View File

@@ -25,7 +25,6 @@ class ReworkWizard(models.TransientModel):
processing_panel_id = fields.Many2many('sf.processing.panel', string="加工面") processing_panel_id = fields.Many2many('sf.processing.panel', string="加工面")
is_reprogramming = fields.Boolean(string='申请重新编程', default=False) is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
is_reprogramming_readonly = fields.Boolean(string='申请重新编程(只读)', default=False) is_reprogramming_readonly = fields.Boolean(string='申请重新编程(只读)', default=False)
is_clamp_measure = fields.Boolean(string='保留装夹测量数据', default=True)
reprogramming_num = fields.Integer('重新编程次数', default=0) reprogramming_num = fields.Integer('重新编程次数', default=0)
programming_state = fields.Selection( programming_state = fields.Selection(
[('待编程', '待编程'), ('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发'), [('待编程', '待编程'), ('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发'),
@@ -36,7 +35,6 @@ class ReworkWizard(models.TransientModel):
def confirm(self): def confirm(self):
if self.routing_type in ['装夹预调', 'CNC加工']: if self.routing_type in ['装夹预调', 'CNC加工']:
self.is_clamp_measure = False
self.workorder_id.is_rework = True self.workorder_id.is_rework = True
self.production_id.write({'detection_result_ids': [(0, 0, { self.production_id.write({'detection_result_ids': [(0, 0, {
'rework_reason': self.rework_reason, 'rework_reason': self.rework_reason,
@@ -60,15 +58,19 @@ class ReworkWizard(models.TransientModel):
if processing_panels_missing: if processing_panels_missing:
processing_panels_str = ','.join(processing_panels_missing) processing_panels_str = ','.join(processing_panels_missing)
raise UserError('您还有待处理的检测结果中为%s的加工面未选择' % processing_panels_str) raise UserError('您还有待处理的检测结果中为%s的加工面未选择' % processing_panels_str)
# processing_panels = set()
# for handle_item in handle_result:
# for dr_panel in self.processing_panel_id:
# if dr_panel.name == handle_item.processing_panel:
# processing_panels.add(dr_panel.name)
# if len(processing_panels) != len(handle_result):
# processing_panels_str = ','.join(processing_panels)
# return UserError(f'您还有待处理的检测结果中为{processing_panels_str}的加工面未选择')
for panel in self.processing_panel_id: for panel in self.processing_panel_id:
panel_workorder = self.production_id.workorder_ids.filtered( panel_workorder = self.production_id.workorder_ids.filtered(
lambda ap: ap.processing_panel == panel.name and ap.state != 'rework') lambda ap: ap.processing_panel == panel.name and ap.state != 'rework')
if panel_workorder: if panel_workorder:
panel_workorder.write({'state': 'rework'}) panel_workorder.write({'state': 'rework'})
rework_clamp_workorder = max(panel_workorder.filtered(
lambda
rp: rp.processing_panel == panel.name and rp.routing_type == '装夹预调' and rp.state in [
'done', 'rework']))
# panel_workorder.filtered( # panel_workorder.filtered(
# lambda wo: wo.routing_type == '装夹预调').workpiece_delivery_ids.filtered( # lambda wo: wo.routing_type == '装夹预调').workpiece_delivery_ids.filtered(
# lambda wd: wd.status == '待下发').write({'status': '已取消'}) # lambda wd: wd.status == '待下发').write({'status': '已取消'})
@@ -91,43 +93,6 @@ class ReworkWizard(models.TransientModel):
self.production_id.detection_result_ids.filtered( self.production_id.detection_result_ids.filtered(
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write( lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
{'handle_result': '已处理'}) {'handle_result': '已处理'})
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
'rework', 'done'))
if new_pre_workorder and rework_clamp_workorder and self.is_clamp_measure is True:
new_pre_workorder.write(
{'X1_axis': rework_clamp_workorder.X1_axis, 'Y1_axis': rework_clamp_workorder.Y1_axis
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
'X2_axis': rework_clamp_workorder.X2_axis
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
'Z2_axis': rework_clamp_workorder.Z2_axis
, 'X3_axis': rework_clamp_workorder.X3_axis,
'Y3_axis': rework_clamp_workorder.Y3_axis
, 'Z3_axis': rework_clamp_workorder.Z3_axis,
'X4_axis': rework_clamp_workorder.X4_axis
, 'Y4_axis': rework_clamp_workorder.Y4_axis,
'Z4_axis': rework_clamp_workorder.Z4_axis
, 'X5_axis': rework_clamp_workorder.X5_axis,
'Y5_axis': rework_clamp_workorder.Y5_axis
, 'Z5_axis': rework_clamp_workorder.Z5_axis,
'X6_axis': rework_clamp_workorder.X6_axis
, 'Y6_axis': rework_clamp_workorder.Y6_axis,
'Z6_axis': rework_clamp_workorder.Z6_axis
, 'X7_axis': rework_clamp_workorder.X7_axis,
'Y7_axis': rework_clamp_workorder.Y7_axis
, 'Z7_axis': rework_clamp_workorder.Z7_axis,
'X8_axis': rework_clamp_workorder.X8_axis
, 'Y8_axis': rework_clamp_workorder.Y8_axis,
'Z8_axis': rework_clamp_workorder.Z8_axis
, 'X9_axis': rework_clamp_workorder.X9_axis,
'Y9_axis': rework_clamp_workorder.Y9_axis
, 'Z9_axis': rework_clamp_workorder.Z9_axis,
'X10_axis': rework_clamp_workorder.X10_axis
, 'Y10_axis': rework_clamp_workorder.Y10_axis,
'Z10_axis': rework_clamp_workorder.Z10_axis
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
'material_center_point': rework_clamp_workorder.material_center_point
})
if self.is_reprogramming is False: if self.is_reprogramming is False:
if self.programming_state in ['已编程', '已下发']: if self.programming_state in ['已编程', '已下发']:
if self.reprogramming_num >= 1 and self.programming_state == '已编程': if self.reprogramming_num >= 1 and self.programming_state == '已编程':
@@ -184,7 +149,9 @@ class ReworkWizard(models.TransientModel):
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name, 'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name,
ret), ret),
'cnc_worksheet': cnc_rework.cnc_worksheet}) 'cnc_worksheet': cnc_rework.cnc_worksheet})
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
'rework', 'done'))
if new_pre_workorder: if new_pre_workorder:
pre_rework = max(self.production_id.workorder_ids.filtered( pre_rework = max(self.production_id.workorder_ids.filtered(
lambda pr: pr.processing_panel == panel.name and pr.state in ( lambda pr: pr.processing_panel == panel.name and pr.state in (

View File

@@ -14,15 +14,8 @@
<group> <group>
<field name="processing_panel_id" options="{'no_create': True}" <field name="processing_panel_id" options="{'no_create': True}"
attrs='{"invisible": [("routing_type","=","装夹预调")]}' widget="many2many_tags"/> attrs='{"invisible": [("routing_type","=","装夹预调")]}' widget="many2many_tags"/>
</group> </group>
<div attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
<span style='font-weight:bold;'>保留装夹测量数据
<field name="is_clamp_measure" force_save="1"/>
</span>
</div>
<div attrs='{"invisible": [("reprogramming_num","=",0)]}'> <div attrs='{"invisible": [("reprogramming_num","=",0)]}'>
<span style='font-weight:bold;'>
注意: 该制造订单产品已申请重新编程次数为<field 注意: 该制造订单产品已申请重新编程次数为<field
name="reprogramming_num" string="" name="reprogramming_num" string=""
readonly="1" readonly="1"
@@ -32,7 +25,6 @@
decoration-success="programming_state == '已下发'" decoration-success="programming_state == '已下发'"
decoration-warning="programming_state =='编程中'" decoration-warning="programming_state =='编程中'"
decoration-danger="programming_state =='已编程'" readonly="1"/> decoration-danger="programming_state =='已编程'" readonly="1"/>
</span>
</div> </div>
<div attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","not in",["已下发"])],"readonly": [("tool_state", "=", "2")]}'> <div attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","not in",["已下发"])],"readonly": [("tool_state", "=", "2")]}'>
<span style='font-weight:bold;'>申请重新编程 <span style='font-weight:bold;'>申请重新编程

View File

@@ -56,6 +56,27 @@ class QuickEasyOrder(models.Model):
processing_time = fields.Integer('加工时长(min)') processing_time = fields.Integer('加工时长(min)')
sale_order_id = fields.Many2one('sale.order', '销售订单号') sale_order_id = fields.Many2one('sale.order', '销售订单号')
part_drawing_number = fields.Char('零件图号')
machining_drawings = fields.Binary('2D加工图纸')
machining_drawings_name = fields.Char('2D加工图纸名')
@api.onchange('machining_drawings_name')
def _onchange_machining_drawings_name(self):
for item in self:
if item.machining_drawings_name:
if not item.machining_drawings_name.lower().endswith(
'.pdf'):
raise ValidationError('文件格式上传有误,请检查文件后缀(不区分大小写)是否为pdf')
@api.onchange('parameter_ids')
def _compute_parameter_ids(self):
my_parameter_ids = {}
for item in self:
for item1 in item.parameter_ids:
my_parameter_ids[item1.process_id.id] = item1.ids[0]
my_parameter_ids = list(my_parameter_ids.values())
item.write({'parameter_ids': [(6, 0, my_parameter_ids)]})
@api.depends('unit_price', 'quantity') @api.depends('unit_price', 'quantity')
def _compute_total_amount(self): def _compute_total_amount(self):
for item in self: for item in self:
@@ -116,6 +137,10 @@ class QuickEasyOrder(models.Model):
if len(item.upload_model_file) > 1: if len(item.upload_model_file) > 1:
raise ValidationError('只允许上传一个文件') raise ValidationError('只允许上传一个文件')
if item.upload_model_file: if item.upload_model_file:
if not item.upload_model_file.name.lower().endswith(
'.step') and not item.upload_model_file.name.lower().endswith(
'.stp'):
raise ValidationError('文件格式上传有误,请检查文件后缀(不区分大小写)是否为step、stp')
file_attachment_id = item.upload_model_file[0] file_attachment_id = item.upload_model_file[0]
# 附件路径 # 附件路径
report_path = file_attachment_id._full_path(file_attachment_id.store_fname) report_path = file_attachment_id._full_path(file_attachment_id.store_fname)

View File

@@ -73,12 +73,15 @@
<field name="material_model_id" options="{'no_create': True}" required="1"/> <field name="material_model_id" options="{'no_create': True}" required="1"/>
<!-- <field name="process_id"/>--> <!-- <field name="process_id"/>-->
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数" <field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"
options="{'no_create': True}" required="1"/> options="{'no_create': True}"/>
<field name="machining_precision" required="1"/> <field name="machining_precision" required="1"/>
<field name="processing_time"/> <field name="processing_time"/>
<field name="quantity" options="{'format': false}"/> <field name="quantity" options="{'format': false}"/>
<field name="unit_price"/> <field name="unit_price"/>
<field name="price" options="{'format': false}"/> <field name="price" options="{'format': false}"/>
<field name="part_drawing_number"/>
<field name="machining_drawings" filename="machining_drawings_name" widget="pdf_viewer"/>
<field name="machining_drawings_name" invisible="1"/>
<field name="sale_order_id" <field name="sale_order_id"
attrs='{"invisible": [("sale_order_id","=",False)],"readonly": [("sale_order_id","!=",False)]}'/> attrs='{"invisible": [("sale_order_id","=",False)],"readonly": [("sale_order_id","!=",False)]}'/>
</group> </group>

View File

@@ -100,8 +100,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="property_supplier_payment_term_id" position="before"> <field name="property_supplier_payment_term_id" position="before">
<field name="purchase_user_id" context="{'supplier_rank': supplier_rank }" <field name="purchase_user_id" context="{'supplier_rank': supplier_rank }"
widget="many2one_avatar_user" widget="many2one_avatar_user"/>
attrs="{'required' : [('supplier_rank','>', 0)]}"/>
</field> </field>
<xpath expr="//field[@name='property_account_position_id']" position="attributes"> <xpath expr="//field[@name='property_account_position_id']" position="attributes">
<attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute> <attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute>

View File

@@ -1,4 +0,0 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import models

View File

@@ -1,36 +0,0 @@
# -*- coding: utf-8 -*-
{
'name': "sf_stock",
'summary': """
Short (1 phrase/line) summary of the module's purpose, used as
subtitle on modules listing or apps.openerp.com""",
'description': """
Long description of module's purpose
""",
'author': "My Company",
'website': "https://www.yourcompany.com",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Uncategorized',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['sf_sale', 'stock'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/stock_picking.xml',
],
# only loaded in demonstration mode
'demo': [
'demo/demo.xml',
],
'installable': True,
'application': True,
}

View File

@@ -1,3 +0,0 @@
# -*- coding: utf-8 -*-
from . import controllers

View File

@@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
# from odoo import http
# class SfStock(http.Controller):
# @http.route('/sf_stock/sf_stock', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/sf_stock/sf_stock/objects', auth='public')
# def list(self, **kw):
# return http.request.render('sf_stock.listing', {
# 'root': '/sf_stock/sf_stock',
# 'objects': http.request.env['sf_stock.sf_stock'].search([]),
# })
# @http.route('/sf_stock/sf_stock/objects/<model("sf_stock.sf_stock"):obj>', auth='public')
# def object(self, obj, **kw):
# return http.request.render('sf_stock.object', {
# 'object': obj
# })

View File

@@ -1,30 +0,0 @@
<odoo>
<data>
<!--
<record id="object0" model="sf_stock.sf_stock">
<field name="name">Object 0</field>
<field name="value">0</field>
</record>
<record id="object1" model="sf_stock.sf_stock">
<field name="name">Object 1</field>
<field name="value">10</field>
</record>
<record id="object2" model="sf_stock.sf_stock">
<field name="name">Object 2</field>
<field name="value">20</field>
</record>
<record id="object3" model="sf_stock.sf_stock">
<field name="name">Object 3</field>
<field name="value">30</field>
</record>
<record id="object4" model="sf_stock.sf_stock">
<field name="name">Object 4</field>
<field name="value">40</field>
</record>
-->
</data>
</odoo>

View File

@@ -1,3 +0,0 @@
# -*- coding: utf-8 -*-
from . import stock_picking

View File

@@ -1,110 +0,0 @@
# -*- coding: utf-8 -*-
import json
import requests
from odoo import models, fields, api
from odoo.exceptions import UserError
import logging
from odoo.tools import date_utils
_logger = logging.getLogger(__name__)
class StockPicking(models.Model):
_inherit = 'stock.picking'
cancel_backorder_ids = fields.Boolean(default=False, string='是否取消后置单据')
# 重写验证下发发货到bfm
def button_validate(self):
info = super(StockPicking, self).button_validate()
if self.picking_type_code == 'outgoing':
self.send_to_bfm()
return info
def deal_move_ids(self, send_move_ids, send_move_line_ids):
move_ids = [] # 本次发货单
move_line_ids = [] # 本次发货单行
if send_move_ids:
for item in send_move_ids:
val = {
'name': item.product_id.upload_model_file.display_name,
'quantity_done': item.quantity_done,
'date': date_utils.json_default(item.date) if item.date else None,
'description_picking': item.description_picking,
'date_deadline': date_utils.json_default(item.date_deadline) if item.date_deadline else None,
'product_uom_qty': item.product_uom_qty,
'sequence': item.sequence,
'price_unit': item.price_unit,
'priority': item.priority,
'state': item.state,
}
move_ids.append(val)
for item in send_move_line_ids:
val = {
'qty_done': item.qty_done,
'reserved_qty': item.reserved_qty,
'reserved_uom_qty': item.reserved_uom_qty,
'date': date_utils.json_default(item.date) if item.date else None,
'description_picking': item.description_picking,
'state': item.state,
}
move_line_ids.append(val)
return move_ids, move_line_ids
def deal_send_backorder_id(self, backorder_ids1):
backorder_ids = []
if backorder_ids1:
for item in backorder_ids1:
move_ids, move_line_ids = self.deal_move_ids(item.move_ids, item.move_line_ids)
val = {
'receiverName': item.receiverName,
'name': item.sale_id.default_code,
'send_no': item.name,
'scheduled_date': date_utils.json_default(item.scheduled_date) if item.scheduled_date else None,
'date': date_utils.json_default(item.date) if item.date else None,
'date_deadline': date_utils.json_default(item.date_deadline) if item.date_deadline else None,
'date_done': date_utils.json_default(item.date_done) if item.date_done else None,
'move_ids': move_ids,
'move_line_ids': move_line_ids,
'state': item.state,
'move_type': item.move_type,
}
backorder_ids.append(val)
return backorder_ids
def send_to_bfm(self):
skip_backorder = self.env.context.get('skip_backorder')
# 下发发货到bfm
config = self.env['res.config.settings'].get_values()
move_ids, move_line_ids = self.deal_move_ids(self.move_ids, self.move_line_ids)
data = {
'params': {
'receiverName': self.receiverName,
'priority': self.priority,
'name': self.sale_id.default_code,
'send_no': self.name,
'scheduled_date': date_utils.json_default(self.scheduled_date) if self.scheduled_date else None,
'date': date_utils.json_default(self.date) if self.date else None,
'date_deadline': date_utils.json_default(self.date_deadline) if self.date_deadline else None,
'date_done': date_utils.json_default(self.date_done) if self.date_done else None,
'move_ids': move_ids,
'move_line_ids': move_line_ids,
'state': self.state,
'backorder_id': self.deal_send_backorder_id(self.backorder_id),
'backorder_ids': self.deal_send_backorder_id(self.backorder_ids),
'cancel_backorder_ids': skip_backorder,
'move_type': self.move_type,
},
}
url1 = config['bfm_url_new'] + '/api/stock/deliver_goods'
json_str = json.dumps(data)
print('json_str', json_str)
r = requests.post(url1, json=data, data=None)
if r.status_code == 200:
result = json.loads(r.json()['result'])
if result['code'] != 200:
raise UserError(result['message'] or '工厂发货下发bfm失败')
else:
raise UserError('工厂发货下发bfm失败')

View File

@@ -1,2 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_stock_sf_stock,sf_stock.sf_stock,model_sf_stock_sf_stock,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_stock_sf_stock sf_stock.sf_stock model_sf_stock_sf_stock base.group_user 1 1 1 1

View File

@@ -1,5 +0,0 @@
<odoo>
<data>
</data>
</odoo>