优化权限相关
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
'security/ir.model.access.csv',
|
||||
# 'security/rules.xml',
|
||||
'views/view.xml',
|
||||
'views/change_manufactuing.xml'
|
||||
],
|
||||
|
||||
'assets': {
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import custom_plan
|
||||
from . import change_manufactuing
|
||||
|
||||
293
sf_plan/models/change_manufactuing.py
Normal file
293
sf_plan/models/change_manufactuing.py
Normal file
@@ -0,0 +1,293 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class CustomMrpUnBuild(models.Model):
|
||||
_inherit = 'mrp.unbuild'
|
||||
_description = "拆解单"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomStockScrap(models.Model):
|
||||
_inherit = 'stock.scrap'
|
||||
_description = "报废单"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomWorkCenter(models.Model):
|
||||
_inherit = 'mrp.workcenter'
|
||||
_description = "工作中心"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomSfProductionLine(models.Model):
|
||||
_inherit = 'sf.production.line'
|
||||
_description = "生产线"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomSfModelType(models.Model):
|
||||
_inherit = 'sf.model.type'
|
||||
_description = "模型类型"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomMrpRoutingWorkcenter(models.Model):
|
||||
_inherit = 'mrp.routing.workcenter'
|
||||
_description = "工序"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
_description = "产品模板"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomMrpBom(models.Model):
|
||||
_inherit = 'mrp.bom'
|
||||
_description = "BOM清单"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
|
||||
|
||||
class CustomStockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = "批次序列号"
|
||||
|
||||
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
审核启用
|
||||
"""
|
||||
self.check_status = True
|
||||
self.active = True
|
||||
|
||||
def action_uncheck(self):
|
||||
"""
|
||||
审核禁用
|
||||
"""
|
||||
self.check_status = False
|
||||
self.active = False
|
||||
|
||||
def archive(self):
|
||||
"""
|
||||
归档
|
||||
"""
|
||||
self.write({'active': False})
|
||||
|
||||
def unarchive(self):
|
||||
"""
|
||||
取消归档
|
||||
"""
|
||||
self.write({'active': True})
|
||||
170
sf_plan/views/change_manufactuing.xml
Normal file
170
sf_plan/views/change_manufactuing.xml
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_mrp_unbuild_form_view" model="ir.ui.view">
|
||||
<field name="name">custom.mrp.unbuild.form</field>
|
||||
<field name="model">mrp.unbuild</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_unbuild_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//header//button[@name='action_validate']" 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>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_stock_scrap_form_view" model="ir.ui.view">
|
||||
<field name="name">custom.stock.scrap.form</field>
|
||||
<field name="model">stock.scrap</field>
|
||||
<field name="inherit_id" ref="stock.stock_scrap_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//header//button[@name='action_validate']" 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>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">custom.product.template.form</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//header" position="inside">
|
||||
<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>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_mrp_bom_form_view" model="ir.ui.view">
|
||||
<field name="name">custom.mrp.bom.form</field>
|
||||
<field name="model">mrp.bom</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet" position="before">
|
||||
<header>
|
||||
<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"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_view_production_lot_form" model="ir.ui.view">
|
||||
<field name="name">custom.view.production.lot.form</field>
|
||||
<field name="model">stock.lot</field>
|
||||
<field name="inherit_id" ref="stock.view_production_lot_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet" position="before">
|
||||
<header>
|
||||
<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"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_sf_production_line_form" model="ir.ui.view">
|
||||
<field name="name">custom.sf.production.line.form</field>
|
||||
<field name="model">sf.production.line</field>
|
||||
<field name="inherit_id" ref="sf_manufacturing.sf_production_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet" position="before">
|
||||
<header>
|
||||
<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"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_form_sf_model_type" model="ir.ui.view">
|
||||
<field name="name">custom.form.sf.model.type</field>
|
||||
<field name="model">sf.model.type</field>
|
||||
<field name="inherit_id" ref="sf_manufacturing.form_sf_model_type"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//group" position="before">
|
||||
<header>
|
||||
<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"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_mrp_workcenter_view_form" model="ir.ui.view">
|
||||
<field name="name">custom.mrp.workcenter.view.form</field>
|
||||
<field name="model">mrp.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_workcenter_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet" position="before">
|
||||
<header>
|
||||
<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"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 增加权限相关的按钮 -->
|
||||
<record id="custom_mrp_routing_workcenter_form_view" model="ir.ui.view">
|
||||
<field name="name">custom.mrp.routing.workcenter.form.view</field>
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet" position="before">
|
||||
<header>
|
||||
<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"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
0
sf_plan/views/menuitem_override.xml
Normal file
0
sf_plan/views/menuitem_override.xml
Normal file
Reference in New Issue
Block a user