更新制造订单生成工单时的工序字段

This commit is contained in:
gqh
2022-11-17 17:27:05 +08:00
parent 4f0df9f2bd
commit 057ec915d9
23 changed files with 792 additions and 148 deletions

View File

@@ -14,9 +14,9 @@
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',
'data/product_data.xml',
'views/mrs_base_view.xml',
'views/mrs_common_view.xml',
'views/mrp_routing_workcenter_view.xml',
"views/menu_view.xml",
'views/sale_order_view.xml',
'views/product_template_view.xml',

View File

@@ -11,27 +11,30 @@ class ResProductTemplate(models.Model):
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='模型材料型号')
model_type_id = fields.Many2one('sf.model.type', string='模型类型')
model_processing_panel = fields.Char('模型加工面板')
model_surface_process_id = fields.Many2one('mrs.production.process', string='表面工艺')
model_process_parameters_id = fields.Many2one('mrs.processing.technology', string='工艺参数')
model_price = fields.Float('模型单价', digits=(16, 3))
model_total_amount = fields.Float('模型金额', digits=(16, 3))
model_number = fields.Integer('模型数量', default=1)
model_remark = fields.Char('模型备注说明')
# price = fields.Float('单价', digits=(16, 3))
# number = fields.Integer('数量', default=1)
# total_amount = fields.Float('金额', digits=(16, 3), compute='_compute_total_amount')
# model_number =
long = fields.Float('长[mm]', digits=(16, 3), onchange='count_embryo_size')
width = fields.Float('[mm]', digits=(16, 3), onchange='count_embryo_size')
height = fields.Float('[mm]', digits=(16, 3), onchange='count_embryo_size')
materials_id = fields.Many2one('mrs.production.materials', string='材料')
materials_type_id = fields.Many2one('mrs.materials.model', string='材料型号')
# 胚料的长,宽,高
embryo_long = fields.Float('胚料长[mm]', digits=(16, 3), onchange='count_embryo_size')
embryo_width = fields.Float('胚料宽[mm]', digits=(16, 3), onchange='count_embryo_size')
embryo_height = fields.Float('胚料高[mm]', digits=(16, 3), onchange='count_embryo_size')
embryo_materials_id = fields.Many2one('mrs.production.materials', string='胚料材料')
embryo_materials_type_id = fields.Many2one('mrs.materials.model', string='胚料材料型号')
volume = fields.Float(compute='_compute_volume', store=True)
@api.depends('long', 'width', 'height')
@api.depends('embryo_long', 'embryo_width', 'embryo_height')
def _compute_volume(self):
self.volume = self.long * self.width * self.height
self.volume = self.embryo_long * self.embryo_width * self.embryo_height
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
def product_create(self, product_id, item, order_id, order_number, i):
@@ -43,21 +46,18 @@ class ResProductTemplate(models.Model):
'model_width': item['model_width'],
'model_height': item['model_height'],
'model_volume': item['model_volume'],
'model_price': item['price'],
'model_total_amount': item['total_amount'],
'model_number': item['number'],
'list_price': item['price'],
'materials_id': self.env['mrs.production.materials'].search(
'model_materials_id': self.env['mrs.production.materials'].search(
[('materials_no', '=', item['texture_code'])]).id,
'materials_type_id': self.env['mrs.materials.model'].search(
'model_materials_type_id': self.env['mrs.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id,
# 'model_surface_process_id': self.env['mrs.production.process'].search(
# [('process_encode', '=', item['surface_process_code'])]).id,
# 'model_process_parameters_id': self.env['mrs.processing.technology'].search(
# [('process_encode', '=', item['process_parameters_code'])]).id,
'model_surface_process_id': self.env['mrs.production.process'].search(
[('process_encode', '=', item['surface_process_code'])]).id,
'model_process_parameters_id': self.env['mrs.processing.technology'].search(
[('process_encode', '=', item['process_parameters_code'])]).id,
''
'default_code': '%s-%s' % (order_number, i),
'model_remark': item['remark'],
# 'barcode': item['barcode'],
'barcode': item['barcode'],
'active': True
}
copy_product_id.sudo().write(vals)
@@ -65,19 +65,19 @@ class ResProductTemplate(models.Model):
# 在产品上增加模型类型和加工的面例如A、B)
# 并根据模型类型计算出产品的胚料尺寸;
# @api.onchange('model_type_id')
# def count_embryo_size(self):
# if not self.model_type_id:
# return
# bom = self.env['product.product'].search(
# [('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
# limit=1,
# order='volume desc'
# )
# for item in self:
# item.embryo_long = bom.embryo_long + 1
# item.embryo_width = bom.embryo_width + 1
# item.embryo_height = bom.embryo_height + 1
@api.onchange('model_type_id')
def count_embryo_size(self):
if not self.model_type_id:
return
bom = self.env['product.product'].search(
[('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
limit=1,
order='volume desc'
)
for item in self:
item.embryo_long = bom.embryo_long + 1
item.embryo_width = bom.embryo_width + 1
item.embryo_height = bom.embryo_height + 1
@@ -104,32 +104,22 @@ class ResMrpBom(models.Model):
# 生成产品BOM匹配胚料胚料的匹配规则
# 一、匹配的胚料类别需要带有胚料的标签;
# 二、胚料的材料型号与生成产品的材料型号一致;如没有新增一条
# 二、胚料的材料型号与生成产品的材料型号一致;
# 三、胚料的长宽高均要大于模型的长宽高;
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
def bom_create_Line(self, product):
embryo = self.env['product.product'].search(
[('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
('long', '>', product.long), ('width', '>', product.width),
('height', '>', product.height)
[('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'
)
# if not embryo:
# embryo = self.env['product.product'].search(
# [('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
# ('long', '>', product.long), ('width', '>', product.width),
# ('height', '>', product.height)
# ],
# limit=1,
# order='volume desc'
# )
vals = {
'bom_id': self.id,
'product_id': embryo.id or 1,
'product_tmpl_id': embryo.product_tmpl_id.id or 1,
'product_id': embryo.id,
'product_tmpl_id': embryo.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': 1
}

View File

@@ -7,12 +7,9 @@ class ReSaleOrder(models.Model):
_inherit = 'sale.order'
deadline_of_delivery = fields.Date('交货截止日期')
person_of_delivery = fields.Char('交货人')
telephone_of_delivery = fields.Char('交货人电话号码')
address_of_delivery = fields.Char('交货人地址')
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address, deadline_of_delivery):
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,
@@ -21,9 +18,6 @@ class ReSaleOrder(models.Model):
'partner_id': 8,
'state': 'sale',
'user_id': 6,
'person_of_delivery': delivery_name,
'telephone_of_delivery': delivery_telephone,
'address_of_delivery': delivery_address,
'deadline_of_delivery': deadline_of_delivery
})
return order_id
@@ -33,7 +27,7 @@ class ReSaleOrder(models.Model):
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.materials_id.name),
'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']
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
#-----------------作业-------------------
<record model="ir.ui.view" id="view_mrp_routing_workcenter_form_inherit_sf">
<field name="name">mrp.routing.workcenter.form.inherit.sf</field>
<field name="model">mrp.routing.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_form_view"/>
<field name="arch" type="xml">
<field name="workcenter_id" position="replace">
<field name="workcenter_ids" widget="many2many_tags" string="工作中心" required="0"/>
</field>
<field name="bom_product_template_attribute_value_ids" position="after">
<field name="routing_type" required="1"/>
<field name="is_repeat"/>
</field>
</field>
</record>
#-----------------工单-------------------
<record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">
<field name="name">mrp.production.workorder.form.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml">
<field name="production_id" position="after">
<field name="processing_panel" readonly="1"/>
</field>
</field>
</record>
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_tree_inherit_sf">-->
<!-- <field name="name">mrp.production.workorder.tree.inherit.sf</field>-->
<!-- <field name="model">mrp.workorder</field>-->
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <field name="workcenter_id" position="replace">-->
<!-- <filter name="workcenter_ids" string="工作中心" />-->
<!-- </field>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_filter_inherit_sf">-->
<!-- <field name="name">mrp.production.workorder.filter.inherit.sf</field>-->
<!-- <field name="model">mrp.workorder</field>-->
<!-- <field name="inherit_id" ref="mrp.view_mrp_production_workorder_form_view_filter"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//filter[@name='work_center']" position="replace">-->
<!-- <filter name="work_center" string="工作中心" context="{'group_by': 'workcenter_ids'}"/>-->
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
#-----------------制造订单里的工单-------------------
<record model="ir.ui.view" id="view_mrp_production_workorder_tree_editable_inherit_sf">
<field name="name">mrp.production.workorder.tree.editable.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="processing_panel"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -6,43 +6,30 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="invoice_policy" position="after">
<field name="materials_id" string="材料"/>
<field name="materials_type_id" string="型号"
domain="[('materials_id', '=', materials_id)]"/>
</field>
<xpath expr="//label[@for='volume']" position="before">
<label for="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="long" string="长"/>
<field name="long" class="o_address_zip"/>
<span>&amp;nbsp;</span>
<label for="width" string="宽"/>
<field name="width" class="o_address_zip"/>
<span>&amp;nbsp;</span>
<label for="height" string="高"/>
<field name="height" class="o_address_zip"/>
</div>
</xpath>
<xpath expr="//page[last()]" position="after">
<page string="加工参数">
<group string="模型">
<field name="model_long" string="长[mm]"/>
<field name="model_width" string="[mm]"/>
<field name="model_height" string="[mm]"/>
<field name="model_volume" string="体积[mm]"/>
<field name="model_type_id" string="模板类型"/>
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
<field name="model_precision" string="精度要求"/>
<field name="model_surface_process_id" string="表面工艺"/>
<field name="model_process_parameters_id" string="工艺参数"
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
<field name="model_price" string="单价"/>
<field name="model_total_amount" string="金额"/>
<field name="model_number" string="数量"/>
<field name="model_remark" string="备注说明"/>
<group>
<group string="模型">
<field name="model_long" string="[mm]"/>
<field name="model_width" string="[mm]"/>
<field name="model_height" string="[mm]"/>
<field name="model_volume" string="体积[mm]"/>
<field name="model_type_id" string="模板类型"/>
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
<field name="model_precision" string="精度要求"/>
<field name="model_materials_id" string="材料"/>
<field name="model_materials_type_id" string="型号"
domain="[('materials_id', '=', model_materials_id)]"/>
</group>
<group string="胚料">
<field name="embryo_long" string="长[mm]"/>
<field name="embryo_width" string="宽[mm]"/>
<field name="embryo_height" string="高[mm]"/>
<field name="volume" string="体积[mm³]"/>
<field name="embryo_materials_id" string="材料"/>
<field name="embryo_materials_type_id" string="型号"
domain="[('materials_id', '=',embryo_materials_id)]"/>
</group>
</group>
</page>
</xpath>

View File

@@ -9,18 +9,6 @@
<field name="payment_term_id" position="after">
<field name="deadline_of_delivery"/>
</field>
<field name="sale_order_template_id" position="after">
<label for="person_of_delivery" string="交货信息"/>
<div>
<field name="person_of_delivery"/>
<span>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
</span>
<field name="telephone_of_delivery"/>
<span>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
</span>
<field name="address_of_delivery"/>
</div>
</field>
</field>
</record>
</data>

View File

@@ -22,11 +22,9 @@ class Sf_Bf_Connect(http.Controller):
datas = request.httprequest.data
ret = json.loads(datas)
ret = json.loads(ret['result'])
product_id = request.env.ref('sf_base.product_template_sf').sudo()
product_id = request.env.ref('sf_bpm_api.product_template_sf').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(
company_id, ret['delivery_name'], ret['delivery_telephone'], ret['delivery_address'],
ret['delivery_end_date'])
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(ret['delivery_end_date'], company_id)
i = 1
for item in ret['bfm_process_order_list']:
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,

View File

@@ -23,18 +23,18 @@ class Http(models.AbstractModel):
# 查询密钥
factory_secret = request.env['res.partner'].sudo().search(
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
# if not factory_secret:
# raise AuthenticationError('无效的token')
# timestamp_str = int(time.time())
# # 设置API接口请求时间,不能超过5秒
# deltime = datetime.timedelta(seconds=60)
# if abs(int(datas['HTTP_TIMESTAMP'])-timestamp_str) > deltime.seconds:
# raise AuthenticationError('请求已过期')
# # 获得sha1_str加密字符串
# post_time = int(datas['HTTP_TIMESTAMP'])
# check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
# check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
# if check_sf_str != datas['HTTP_CHECKSTR']:
# raise AuthenticationError('数据校验不通过')
if not factory_secret:
raise AuthenticationError('无效的token')
timestamp_str = int(time.time())
# 设置API接口请求时间,不能超过5秒
deltime = datetime.timedelta(seconds=60)
if abs(int(datas['HTTP_TIMESTAMP'])-timestamp_str) > deltime.seconds:
raise AuthenticationError('请求已过期')
# 获得sha1_str加密字符串
post_time = int(datas['HTTP_TIMESTAMP'])
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
if check_sf_str != datas['HTTP_CHECKSTR']:
raise AuthenticationError('数据校验不通过')
else:
raise AuthenticationError('请求参数中无token')

View File

@@ -1,6 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
access_sf_model_type_routing_sort,sf_model_type_routing_sort,model_sf_model_type_routing_sort,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
access_sf_model_type sf_model_type model_sf_model_type base.group_user 1 1 1 1
access_sf_model_type_routing_sort sf_model_type_routing_sort model_sf_model_type_routing_sort base.group_user 1 1 1 1
2
3
4

View File

@@ -15,6 +15,7 @@
'views/sf_production.xml',
],
'demo': [
],

View File

@@ -1,21 +1,15 @@
from odoo import api, fields, models, SUPERUSER_ID, _
class ResWorkcenter(models.Model):
_inherit = 'mrp.workcenter'
machine_tool_id = fields.Many2one('mrs.machine_tool', '机床')
class ResWorkcenterProductivity(models.Model):
_inherit = 'mrp.workcenter.productivity'
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
class ResMrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
processing_panel = fields.Char('加工面')
routing_type = fields.Selection([

View File

@@ -0,0 +1,89 @@
=======================
MRP Work Order Sequence
=======================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/15.0/mrp_workorder_sequence
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_workorder_sequence
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
Provide a new field sequence on production orders's work orders, that provides
clear information on the process order of those.
**Table of contents**
.. contents::
:local:
Usage
=====
Go to any production order with a routing set and check its work orders.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_workorder_sequence%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* ForgeFlow
Contributors
~~~~~~~~~~~~
* Lois Rilo <lois.rilo@forgeflow.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
* Christopher Ormaza <chris.ormaza@forgeflow.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
.. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px
:target: https://github.com/LoisRForgeFlow
:alt: LoisRForgeFlow
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-LoisRForgeFlow|
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/15.0/mrp_workorder_sequence>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': '机企猫智能工厂 工作订单排序',
'version': '1.0',
'summary': '智能工厂工作订单',
'sequence': 1,
'description': """
""",
'category': '',
'website': 'https://www.sf.jikimo.com',
'depends': ['mrp'],
'data': [
'views/mrp_workorder_view.xml',
],
'demo': [
],
'qweb': [
],
'installable': True,
'application': False,
'auto_install': False,
}

View File

@@ -0,0 +1,2 @@
from . import mrp_production
from . import mrp_workorder

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from odoo import models
class MrpProduction(models.Model):
_inherit = "mrp.production"
def _reset_work_order_sequence(self):
for rec in self:
current_sequence = 1
for work in rec.workorder_ids:
work.sequence = current_sequence
current_sequence += 1
def _create_workorder(self):
res = super()._create_workorder()
self._reset_work_order_sequence()
return res

View File

@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from odoo import fields, models
class MrpWorkOrder(models.Model):
_inherit = "mrp.workorder"
_order = 'sequence'
sequence = fields.Integer(string='工序')

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,429 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>MRP Work Order Sequence</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="mrp-work-order-sequence">
<h1 class="title">MRP Work Order Sequence</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/15.0/mrp_workorder_sequence"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-15-0/manufacture-15-0-mrp_workorder_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Provide a new field sequence on production orderss work orders, that provides
clear information on the process order of those.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>Go to any production order with a routing set and check its work orders.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_workorder_sequence%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
<li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/LoisRForgeFlow"><img alt="LoisRForgeFlow" src="https://github.com/LoisRForgeFlow.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/15.0/mrp_workorder_sequence">OCA/manufacture</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="mrp_production_workorder_tree_view_inherit" model="ir.ui.view">
<field name="name">mrp.workorder.tree</field>
<field name="model">mrp.workorder</field>
<field
name="inherit_id"
ref="mrp.mrp_production_workorder_tree_editable_view"
/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="sequence" />
</field>
</field>
</record>
</odoo>

View File

@@ -82,7 +82,7 @@ class MrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
_description = '工单'
tray_ids = fields.One2many('sf.tray', 'workorder_id', string='托盘')
# def get_tray_info(self):
# @api.onchange('X_axis', 'Y_axis', 'Z_axis')
# def get_center_point(self):
@@ -241,7 +241,7 @@ class MrpWorkOrder(models.Model):
productions = self.production_id
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
productions.create_workorder1(self.processing_panel)
productions._create_workorder2(self.processing_panel)
return ""
def fetchCNC(self):
@@ -279,7 +279,26 @@ class MrpProduction(models.Model):
'user_id': production.user_id.id}
return production_values_str
def create_workorder1(self, k):
def _reset_work_order_sequence1(self,k):
for rec in self:
current_sequence = 1
for work in rec.workorder_ids:
if work.processing_panel == '':
work.sequence = current_sequence
current_sequence += 1
for work in rec.workorder_ids:
if work.processing_panel == k:
work.sequence = current_sequence
current_sequence += 1
for work in rec.workorder_ids:
if work.processing_panel != k and work.processing_panel != "":
work.sequence = current_sequence
current_sequence += 1
def _create_workorder1(self, k):
for production in self:
if not production.bom_id or not production.product_id:
continue
@@ -320,10 +339,12 @@ class MrpProduction(models.Model):
i += 1
for route in routingworkcenter:
if route.routing_type == 'CNC加工':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
if route.routing_type == '后置三元质量检测':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route)
)
if route.routing_type == 'CNC加工':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
@@ -331,6 +352,11 @@ class MrpProduction(models.Model):
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
def _create_workorder2(self, k):
res = self._create_workorder1(k)
self._reset_work_order_sequence1(k)
return res
class Attachment(models.Model):
_inherit = 'ir.attachment'

View File

@@ -1,6 +1,6 @@
<odoo>
<data>
<!-- 托盘码打印尺寸-->
<!-- 托盘码打印尺寸-->
<record id="sf_tray1" model="report.paperformat">
<field name="name">Dymo Label Sheet</field>
<field name="default" eval="True"/>
@@ -16,7 +16,7 @@
<field name="dpi">96</field>
</record>
<!-- 托盘码打印动作-->
<!-- 托盘码打印动作-->
<record id="label_sf_tray_code" model="ir.actions.report">
<field name="name">打印条形码</field>
<field name="model">sf.tray</field>
@@ -28,7 +28,7 @@
<field name="paperformat_id" ref="sf_route_workcenter.sf_tray1"/>
</record>
<!-- 托盘码打印模板-->
<!-- 托盘码打印模板-->
<template id="sf_tray_template">
<t t-call="web.html_container">
<t t-call="web.external_layout">
@@ -65,10 +65,11 @@
<t t-call="web.external_layout">
<t t-foreach="docs" t-as="o">
<div class="page">
<div t-field="o.production_id.name"
t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}"/>
<div t-field="o.production_id" style="text-align: center"/>
<div t-field="o.name" style="text-align: center"/>
</div>
</t>
@@ -78,8 +79,5 @@
</template>
</data>
</odoo>

View File

@@ -247,12 +247,21 @@
</xpath>
<xpath expr="//page[last()]" position="after">
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}' >
<div class="col-12 col-lg-6 o_setting_box">
<group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
/>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<button type="action" class="oe_highlight" name="sf_route_workcenter.label_sf_tray_code1" string="打印标签"
/>
</div>
</group>
</page>
</xpath>