Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/新增机台日计划,工件预调(前置三元检测),NC程序下载接口

This commit is contained in:
jinling.yang
2024-01-19 17:18:59 +08:00
22 changed files with 287 additions and 146 deletions

View File

@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="sequence_routing_workcenter" model="ir.sequence">
<field name="name">工序编码规则</field>
<field name="code">mrp.routing.workcenter</field>
<field name="padding">4</field>
<field name="company_id" eval="False"/>
</record>
<record id="sequence_stock_picking_out" model="ir.sequence">
<field name="name">YourCompany Sequence ocout</field>
<field name="prefix">WH/OCOUT/</field>

View File

@@ -8,8 +8,6 @@ from odoo.exceptions import UserError
from odoo.addons.sf_base.commons.common import Common
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
from odoo.tools import float_compare, float_is_zero
class MrpProduction(models.Model):
_inherit = 'mrp.production'
@@ -162,7 +160,6 @@ class MrpProduction(models.Model):
logging.info('fetchCNC error:%s' % e)
raise UserError("cnc程序获取编程单失败,请联系管理员")
# 维修模块按钮
def button_maintenance_req(self):
self.ensure_one()
@@ -489,7 +486,7 @@ class MrpProduction(models.Model):
self._reset_work_order_sequence()
return True
#修改标记已完成方法
# 修改标记已完成方法
def button_mark_done1(self):
self._button_mark_done_sanity_checks()
@@ -506,7 +503,6 @@ class MrpProduction(models.Model):
productions_not_to_backorder = self
productions_to_backorder = self.env['mrp.production']
backorders = productions_to_backorder and productions_to_backorder._split_productions()
backorders = backorders - productions_to_backorder
@@ -514,13 +510,16 @@ class MrpProduction(models.Model):
productions_to_backorder._post_inventory(cancel_backorder=True)
# if completed products make other confirmed/partially_available moves available, assign them
done_move_finished_ids = (productions_to_backorder.move_finished_ids | productions_not_to_backorder.move_finished_ids).filtered(lambda m: m.state == 'done')
done_move_finished_ids = (
productions_to_backorder.move_finished_ids | productions_not_to_backorder.move_finished_ids).filtered(
lambda m: m.state == 'done')
done_move_finished_ids._trigger_assign()
# Moves without quantity done are not posted => set them as done instead of canceling. In
# case the user edits the MO later on and sets some consumed quantity on those, we do not
# want the move lines to be canceled.
(productions_not_to_backorder.move_raw_ids | productions_not_to_backorder.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')).write({
(productions_not_to_backorder.move_raw_ids | productions_not_to_backorder.move_finished_ids).filtered(
lambda x: x.state not in ('done', 'cancel')).write({
'state': 'done',
'product_uom_qty': 0.0,
})
@@ -546,8 +545,10 @@ class MrpProduction(models.Model):
'res_id': self.id,
'target': 'main',
}
if self.user_has_groups('mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report:
lines = self.move_finished_ids.filtered(lambda m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
if self.user_has_groups(
'mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report:
lines = self.move_finished_ids.filtered(lambda
m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
if lines:
if any(mo.show_allocation for mo in self):
action = self.action_view_reception_report()
@@ -574,4 +575,4 @@ class MrpProduction(models.Model):
'domain': [('id', 'in', backorders.ids)],
'view_mode': 'tree,form',
})
return action
return action

View File

@@ -1,5 +1,6 @@
import logging
from odoo import fields, models
from odoo import fields, models, api
from odoo.exceptions import UserError
class ResMrpRoutingWorkcenter(models.Model):
@@ -21,13 +22,17 @@ class ResMrpRoutingWorkcenter(models.Model):
bom_id = fields.Many2one('mrp.bom', required=False)
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
def generate_code(self):
return self.env['ir.sequence'].next_by_code('mrp.routing.workcenter')
code = fields.Char('编码', default=generate_code)
# 获得当前登陆者公司
def get_company_id(self):
self.company_id = self.env.user.company_id.id
company_id = fields.Many2one('res.company', compute="get_company_id", related=False)
# 排产的时候, 根据坯料的长宽高比对一下机床的最大加工尺寸.不符合就不要分配给这个加工中心(机床).
# 工单对应的工作中心,根据工序中的工作中心去匹配,
# 如果只配置了一个工作中心,则默认采用该工作中心;

View File

@@ -232,7 +232,7 @@ class ResMrpWorkOrder(models.Model):
'processing_panel': k,
'quality_point_ids': route.route_workcenter_id.quality_point_ids,
'routing_type': route.routing_type,
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'work_state': '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
route.routing_type,
production.product_id),

View File

@@ -87,7 +87,7 @@ access_mrp_production_split,access.mrp.production.split,mrp.model_mrp_production
access_mrp_production_split_line,access.mrp.production.split.line,mrp.model_mrp_production_split_line,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_workcenter_capacity_manager,mrp.workcenter.capacity.manager,mrp.model_mrp_workcenter_capacity,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_production,mrp_production,model_mrp_production,sf_base.group_plan_dispatch,1,1,1,0
access_mrp_production_group_plan_dispatch,mrp_production,model_mrp_production,sf_base.group_plan_dispatch,1,0,0,0
access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,1,0
access_sf_production_line_group_plan_dispatch,sf.production.line,model_sf_production_line,sf_base.group_plan_dispatch,1,0,0,0
access_sf_production_line_group_plan_director,sf.production.line,model_sf_production_line,sf_base.group_plan_director,1,1,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
87 access_mrp_workcenter_capacity_manager mrp.workcenter.capacity.manager mrp.model_mrp_workcenter_capacity sf_base.group_sf_mrp_user 1 1 1 0
88 access_mrp_production access_mrp_production_group_plan_dispatch mrp_production model_mrp_production sf_base.group_plan_dispatch 1 1 0 1 0 0
89 access_mrp_workorder mrp_workorder model_mrp_workorder sf_base.group_plan_dispatch 1 1 1 0
90 access_sf_production_line_group_plan_dispatch sf.production.line model_sf_production_line sf_base.group_plan_dispatch 1 0 0 0
91 access_sf_production_line_group_plan_director sf.production.line model_sf_production_line sf_base.group_plan_director 1 1 1 0
92 access_sf_production_line sf.production.line model_sf_production_line sf_maintenance.sf_group_equipment_user 1 1 1 0
93 access_mrp_workcenter mrp_workcenter model_mrp_workcenter sf_base.group_plan_dispatch 1 1 1 0

View File

@@ -53,6 +53,7 @@
</record>
<!-- 增加权限相关的按钮 -->
<!-- 制造订单的操作按钮只让制造用户可见 -->
<record id="custom_mrp_production_form_view" model="ir.ui.view">
<field name="name">custom.mrp.production.form</field>
<field name="model">mrp.production</field>
@@ -61,23 +62,151 @@
<xpath expr="//field[@name='state']" position="attributes">
<attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done</attribute>
</xpath>
<xpath expr="//form//header//button[@name='action_confirm']" position="after">
<field name="active" invisible="1"/>
<field name="check_status" invisible="1"/>
<!-- <button name="archive" type="object" string="归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', False)]}"/> -->
<!-- <button name="unarchive" type="object" string="取消归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', True)]}"/> -->
<button name="action_check" string="审核" type="object" class="oe_highlight" attrs="{'invisible': [('check_status', '=', True)]}" groups="sf_base.group_plan_director"/>
<!-- <button name="action_uncheck" string="禁用" type="object" class="oe_highlight" attrs="{'invisible': [('check_status', '=', False)]}" groups="sf_base.group_plan_director"/> -->
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="programming_no"/>
<field name="work_state" invisible="1"/>
<field name="programming_state"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', True)]}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[1]" position="replace">
<button name="button_mark_done" attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '!=', [])]}" string="验证" type="object" class="oe_highlight"
confirm="There are no components to consume. Are you still sure you want to continue?" data-hotkey="g" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[2]" position="replace">
<button name="button_mark_done" attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '=', [])]}" string="Validate" type="object" class="oe_highlight" data-hotkey="g" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[3]" position="replace">
<button name="button_mark_done" attrs="{'invisible': [
'|',
('move_raw_ids', '=', []),
'&amp;',
'|',
('state', 'not in', ('confirmed', 'progress')),
('qty_producing', '!=', 0),
('state', '!=', 'to_close')]}" string="Mark as Done" type="object" class="oe_highlight" data-hotkey="g" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[4]" position="replace">
<button name="button_mark_done" attrs="{'invisible': [
'|',
('move_raw_ids', '!=', []),
'&amp;',
'|',
('state', 'not in', ('confirmed', 'progress')),
('qty_producing', '!=', 0),
('state', '!=', 'to_close')]}" string="Mark as Done" type="object" class="oe_highlight" data-hotkey="g"
confirm="There are no components to consume. Are you still sure you want to continue?" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_unplan']" position="replace">
<button name="button_unplan" type="object" string="取消安排" attrs="{'invisible': ['|', ('is_planned', '=', False), ('state', '=', 'cancel')]}" data-hotkey="x" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_scrap']" position="replace">
<button name="button_scrap" type="object" string="报废" attrs="{'invisible': [('state', 'in', ('cancel', 'draft'))]}" data-hotkey="y" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_confirm']" position="replace">
<button name="action_confirm" attrs="{'invisible': [('state', '!=', 'draft')]}" string="Confirm" type="object" class="oe_highlight" data-hotkey="v" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_plan']" position="replace">
<button name="button_plan" attrs="{'invisible': ['|', '|', ('state', 'not in', ('confirmed', 'progress', 'to_close')), ('workorder_ids', '=', []), ('is_planned', '=', True)]}" type="object" string="Plan" class="oe_highlight" data-hotkey="x" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_assign']" position="replace">
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}" string="Check availability" type="object" data-hotkey="q" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='do_unreserve']" position="replace">
<button name="do_unreserve" type="object" string="Unreserve" attrs="{'invisible': [('unreserve_visible', '=', False)]}" data-hotkey="w" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', ('show_lock', '=', False), ('is_locked', '=', False)]}" string="Unlock" groups="sf_base.group_sf_mrp_user" type="object" help="Unlock the manufacturing order to adjust what has been consumed or produced." data-hotkey="l"/>
</xpath>
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', ('show_lock', '=', False), ('is_locked', '=', True)]}" string="Lock" groups="sf_base.group_sf_mrp_user" type="object" help="Lock the manufacturing order to prevent changes to what has been consumed or produced." data-hotkey="l"/>
</xpath>
<xpath expr="//header//button[@name='action_serial_mass_produce_wizard']" position="replace">
<button name="action_serial_mass_produce_wizard" attrs="{'invisible': [('show_serial_mass_produce', '=', False)]}" string="Mass Produce" type="object" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="Cancel" data-hotkey="z"
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', False)]}"
confirm="Some product moves have already been confirmed, this manufacturing order can't be completely cancelled. Are you still sure you want to process ?" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_unbuild']" position="replace">
<button name="button_unbuild" type="object" string="Unbuild" attrs="{'invisible': [('state', '!=', 'done')]}" data-hotkey="shift+v" groups="sf_base.group_sf_mrp_user"/>
</xpath>
</field>
</record>
<!-- 工单的操作按钮只让制造用户可见 -->
<record id="sf_mrp_production_workorder_tree_editable_view" model="ir.ui.view">
<field name="name">sf.mrp.production.workorder.tree.editable</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view"/>
<field name="arch" type="xml">
<xpath expr="//tree//button[@name='button_start']" position="replace">
<button name="button_start" type="object" string="Start" class="btn-success"
attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_pending']" position="replace">
<button name="button_pending" type="object" string="Pause" class="btn-warning"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="Done" class="btn-success"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked')]}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_unblock']" position="replace">
<button name="button_unblock" type="object" string="Unblock" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='action_open_wizard']" position="replace">
<button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"
title="Open Work Order"
context="{'default_workcenter_id': workcenter_id}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
</field>
</record>
<!-- 制造订单列表视图header内的按钮只让制造用户可见 -->
<record id="sf_mrp_production_tree_view" model="ir.ui.view">
<field name="name">sf.mrp.production.tree</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//header//button[@name='button_plan']" position="replace">
<!-- <button name="button_plan" type="object" string="安排" groups="sf_base.group_sf_mrp_user"/> -->
</xpath>
<xpath expr="//header//button[@name='do_unreserve']" position="replace">
<button name="do_unreserve" type="object" string="取消保留" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" groups="sf_base.group_sf_mrp_user"/>
</xpath>
</field>
</record>
<!-- <record id="custom_mrp_production_form_view" model="ir.ui.view"> -->
<!-- <field name="name">custom.mrp.production.form</field> -->
<!-- <field name="model">mrp.production</field> -->

View File

@@ -6,6 +6,9 @@
<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="name" position="before">
<field name="code" readonly="1"/>
</field>
<field name="workcenter_id" position="replace">
<field name="workcenter_ids" widget="many2many_tags" string="工作中心" required="0"/>
<field name="surface_technics_id"

View File

@@ -6,9 +6,9 @@
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="action_cancel" position="before">
<button name="button_maintenance_req" type="object" string="维修请求"/>
</button>
<!-- <button name="action_cancel" position="before"> -->
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
<!-- </button> -->
<div name="button_box" position="inside">
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
attrs="{'invisible': [('maintenance_count', '=', 0)]}"
@@ -376,9 +376,9 @@
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="action_cancel" position="before">
<button name="button_maintenance_req" type="object" string="维修请求"/>
</button>
<!-- <button name="action_cancel" position="before"> -->
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
<!-- </button> -->
<div name="button_box" position="inside">
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
attrs="{'invisible': [('maintenance_count', '=', 0)]}"