sf工单优化及权限

This commit is contained in:
gqh
2023-01-04 10:13:29 +08:00
parent dd5c387585
commit 08efe7813d
7 changed files with 96 additions and 24 deletions

View File

@@ -17,8 +17,8 @@
'report/tray_report.xml', 'report/tray_report.xml',
'views/mrp_maintenance_views.xml', 'views/mrp_maintenance_views.xml',
'views/mrp_routing_workcenter_view.xml', 'views/mrp_routing_workcenter_view.xml',
'views/mrp_workorder_view.xml',
'views/mrp_workcenter_views.xml', 'views/mrp_workcenter_views.xml',
'views/mrp_workorder_view.xml',
'views/tray_view.xml', 'views/tray_view.xml',
'views/model_type_view.xml', 'views/model_type_view.xml',

View File

@@ -6,6 +6,7 @@ from . import mrp_routing_workcenter
from . import mrp_workorder from . import mrp_workorder
from . import model_type from . import model_type
from . import stock from . import stock
from . import res_user

View File

@@ -7,6 +7,8 @@ class ResWorkcenter(models.Model):
_inherit = "mrp.workcenter" _inherit = "mrp.workcenter"
machine_tool_id = fields.Many2one('sf.machine_tool', '机床') machine_tool_id = fields.Many2one('sf.machine_tool', '机床')
users_ids = fields.Many2many("res.users", 'users_workcenter')
equipment_ids = fields.One2many( equipment_ids = fields.One2many(
'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment", 'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment",
check_company=True) check_company=True)

View File

@@ -19,6 +19,7 @@ class ResMrpWorkOrder(models.Model):
_order = 'sequence' _order = 'sequence'
workcenter_id = fields.Many2one('mrp.workcenter', required=False) workcenter_id = fields.Many2one('mrp.workcenter', required=False)
users_ids = fields.Many2many("res.users", 'users_workorder', related="workcenter_id.users_ids")
processing_panel = fields.Char('加工面') processing_panel = fields.Char('加工面')
sequence = fields.Integer(string='工序') sequence = fields.Integer(string='工序')
routing_type = fields.Selection([ routing_type = fields.Selection([
@@ -29,6 +30,21 @@ class ResMrpWorkOrder(models.Model):
('后置三元质量检测', '后置三元质量检测'), ('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'), ('解除装夹', '解除装夹'),
], string="工序类型") ], string="工序类型")
@api.onchange('users_ids')
def get_user_permissions(self):
uid = self.env.uid
for workorder in self:
if workorder.users_ids:
for item in workorder.users_ids:
if item.id == uid:
workorder.user_permissions = True
else:
workorder.user_permissions = False
else:workorder.user_permissions=False
user_permissions = fields.Boolean('用户权限', compute='get_user_permissions')
cnc_worksheet = fields.Binary( cnc_worksheet = fields.Binary(
'工作指令', readonly=True) '工作指令', readonly=True)
material_center_point = fields.Char(string='配料中心点') material_center_point = fields.Char(string='配料中心点')

View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import SUPERUSER_ID, _, api, fields, models, registry
class Users(models.Model):
_inherit = 'res.users'
workcenter_ids = fields.Many2many("mrp.workcenter", 'users_workcenter')

View File

@@ -24,14 +24,16 @@
</field> </field>
</record> </record>
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view"> <record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field> <field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
<field name="model">mrp.workcenter</field> <field name="model">mrp.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/> <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- Desktop view --> <!-- Desktop view -->
<xpath expr="//div[@name='o_wo']" position="inside"> <xpath expr="//div[@name='o_wo']" position="inside">
<button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object" context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}" title="Work orders" aria-label="Work orders"/> <button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object"
context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}"
title="Work orders" aria-label="Work orders"/>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -39,25 +41,46 @@
<!-- override to change the no content image --> <!-- override to change the no content image -->
<record id="mrp.action_work_orders" model="ir.actions.act_window"> <record id="mrp.action_work_orders" model="ir.actions.act_window">
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_workorder"> <p class="o_view_nocontent_workorder">
No work orders to do! No work orders to do!
</p><p> </p>
Work orders are operations to do as part of a manufacturing order. <p>
Operations are defined in the bill of materials or added in the manufacturing order directly. Work orders are operations to do as part of a manufacturing order.
</p><p> Operations are defined in the bill of materials or added in the manufacturing order directly.
Use the table work center control panel to register operations in the shop floor directly. </p>
The tablet provides worksheets for your workers and allow them to scrap products, track time, <p>
launch a maintenance request, perform quality tests, etc. Use the table work center control panel to register operations in the shop floor directly.
</p> The tablet provides worksheets for your workers and allow them to scrap products, track time,
launch a maintenance request, perform quality tests, etc.
</p>
</field>
</record>
<record id="mrp_workcenter_kanban_action1" model="ir.actions.act_window">
<field name="name">Work Centers Overview</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.workcenter</field>
<field name="view_mode">kanban,form</field>
<field name="view_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="search_view_id" ref="mrp.view_mrp_workcenter_search"/>
<field name="domain">[('users_ids','in',uid)]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new work center
</p>
<p>
Manufacturing operations are processed at Work Centers. A Work Center can be composed of
workers and/or machines, they are used for costing, scheduling, capacity planning, etc.
They can be defined via the configuration menu.
</p>
</field> </field>
</record> </record>
<menuitem id="menu_mrp_dashboard" <menuitem id="menu_mrp_dashboard"
name="工作中心概述" name="工作中心概述"
action="mrp.mrp_workcenter_kanban_action" action="mrp_workcenter_kanban_action1"
groups="mrp.group_mrp_routings" groups="mrp.group_mrp_routings"
parent="mrp.menu_mrp_root" parent="mrp.menu_mrp_root"
sequence="5"/> sequence="5"/>
<!-- MRP.WORKCENTER --> <!-- MRP.WORKCENTER -->
<record model="ir.ui.view" id="view_mrp_workcenter_form_inherit_sf"> <record model="ir.ui.view" id="view_mrp_workcenter_form_inherit_sf">
@@ -79,6 +102,9 @@
</field> </field>
</page> </page>
</xpath> </xpath>
<xpath expr="//field[@name='company_id']" position="after">
<field name="users_ids" widget="many2many_tags" string="可操作用户"/>
</xpath>
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after"> <xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
<field name="machine_tool_id"/> <field name="machine_tool_id"/>

View File

@@ -7,10 +7,24 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="name" position="before"> <field name="name" position="before">
<field name="sequence"/> <field name="sequence"/>
<field name = 'user_permissions'/>
</field> </field>
<field name="name" position="after"> <field name="name" position="after">
<field name="processing_panel"/> <field name="processing_panel"/>
</field> </field>
<xpath expr="//button[@name='button_start']" position="attributes">
<attribute name="attrs">{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False),("user_permissions","=",False)]}</attribute>
</xpath>
<!-- <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)]}"/>-->
<!-- <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)]}"/>-->
<!-- <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)]}"/>-->
<tree position="attributes">
<attribute name="multi_edit"></attribute>
<attribute name="editable"></attribute>
</tree>
</field> </field>
</record> </record>
@@ -57,10 +71,16 @@
<field name="model">mrp.workorder</field> <field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/> <field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="field[@name='is_user_working']" position="before">
<field name = 'user_permissions' invisible="1"/>
</xpath>
<xpath expr="//page[last()]" position="after"> <xpath expr="//page[last()]" position="after">
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'> <page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}' >
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"/> <button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码" attrs='{"invisible": [("user_permissions","=",False)]}' />
</div> </div>
</page> </page>
@@ -185,7 +205,7 @@
</div> </div>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"/> <button type="object" class="oe_highlight" name="getcenter" string="计算定位" attrs='{"invisible": [("user_permissions","=",False)]}'/>
</div> </div>
<group> <group>
@@ -227,7 +247,7 @@
</group> </group>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder" <button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认"/> string="检测确认" attrs='{"invisible": [("user_permissions","=",False)]}'/>
</div> </div>
</page> </page>
</xpath> </xpath>
@@ -235,11 +255,11 @@
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'> <page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"/> <button type="object" class="oe_highlight" name="unbindtray" string="解除装夹" attrs='{"invisible": [("user_permissions","=",False)]}'/>
</div> </div>
<div class="col-12 col-lg-6 o_setting_box"> <div class="col-12 col-lg-6 o_setting_box">
<button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1" <button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"
string="打印标签"/> string="打印标签" attrs='{"invisible": [("user_permissions","=",False)]}'/>
</div> </div>
</page> </page>