新增权限审核按钮

This commit is contained in:
qihao.gong@jikimo.com
2023-12-07 17:31:28 +08:00
parent 35c051e730
commit 31260e8921
5 changed files with 337 additions and 152 deletions

View File

@@ -6,8 +6,8 @@ import os
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
#from OCC.Extend.DataExchange import read_step_file
#from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model):

View File

@@ -2,7 +2,7 @@
import logging
from odoo.modules import get_resource_path
from odoo import fields, models, api
from quatotion import readSql, feature_recognize, auto_quatotion
#from quatotion import readSql, feature_recognize, auto_quatotion
__author__ = 'jinling.yang'
_logger = logging.getLogger(__name__)

View File

@@ -5,8 +5,8 @@ import os
import json
from datetime import datetime
import requests
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
#from OCC.Extend.DataExchange import read_step_file
#from OCC.Extend.DataExchange import write_stl_file
from odoo import models, fields, api
from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError

View File

@@ -11,6 +11,14 @@ class SfLocation(models.Model):
name = fields.Char('Location Name', required=True, size=20)
barcode = fields.Char('Barcode', copy=False, size=15)
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
# 仓库类别selection库区、库位、货位
# location_type = fields.Selection([
# ('库区', '库区'),
@@ -500,3 +508,63 @@ class SfProcurementGroup(models.Model):
res = Rule.search(expression.AND([[('route_id', 'in', warehouse_routes.ids)], domain]),
order='route_sequence, sequence', limit=1)
return res
class SfWarehouse(models.Model):
_inherit = 'stock.warehouse'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfRule(models.Model):
_inherit = 'stock.rule'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfRoute(models.Model):
_inherit = 'stock.route'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfPickingType(models.Model):
_inherit = 'stock.picking.type'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfProductCategory(models.Model):
_inherit = 'product.category'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- <record id="view_location_tree2_sf_inherit" model="ir.ui.view"> -->
<!-- <field name="name">stock.location.tree.sf.inherit</field> -->
<!-- <field name="model">stock.location</field> -->
<!-- <field name="inherit_id" ref="stock.view_location_tree2"/> -->
<!-- <field name="arch" type="xml"> -->
<!-- <xpath expr="//tree/field[@name='complete_name']" position="before"> -->
<!-- <field name="barcode"/> -->
<!-- </xpath> -->
<!-- </field> -->
<!-- </record> -->
<data>
<!-- <record id="view_location_tree2_sf_inherit" model="ir.ui.view"> -->
<!-- <field name="name">stock.location.tree.sf.inherit</field> -->
<!-- <field name="model">stock.location</field> -->
<!-- <field name="inherit_id" ref="stock.view_location_tree2"/> -->
<!-- <field name="arch" type="xml"> -->
<!-- <xpath expr="//tree/field[@name='complete_name']" position="before"> -->
<!-- <field name="barcode"/> -->
<!-- </xpath> -->
<!-- </field> -->
<!-- </record> -->
<record id="view_location_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.location.form.sf.inherit</field>
@@ -27,34 +27,45 @@
<field name="hide_location" invisible="1"/>
<field name="barcode" string="编码"/>
<field name="location_type"/>
<field name="channel" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="direction" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="product_sn_id" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '空闲')]}"/>
<!-- <field name="time_test" widget="timepicker"/>-->
<field name="area_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
<field name="channel"
attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="direction"
attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="product_sn_id"
attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '空闲')]}"/>
<!-- <field name="time_test" widget="timepicker"/>-->
<field name="area_type"
attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
<field name="current_location_id" attrs="{'invisible': [('hide_area', '=', False)]}"/>
<field name="destination_location_id" attrs="{'invisible': [('hide_area', '=', False)]}"/>
</group>
<group>
<!-- <field name="storage_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/> -->
<field name="product_type" widget="many2many_tags" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
<field name="shelf_height" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="shelf_layer" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="layer_capacity" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="product_id" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '占用')]}"/>
<field name="location_status" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False)]}"/>
<!-- <field name="storage_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/> -->
<field name="product_type" widget="many2many_tags"
attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
<field name="shelf_height"
attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="shelf_layer"
attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="layer_capacity"
attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
<field name="product_id"
attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '占用')]}"/>
<field name="location_status"
attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False)]}"/>
</group>
</group>
</xpath>
<!-- <xpath expr="//form/sheet/div/button" position="before"> -->
<!-- <button string="生成货位" name="create_location" type="object" class="oe_highlight" attrs="{'invisible': [('hide_shelf', '=', False)]}"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//form/sheet/div/button" position="before"> -->
<!-- <button string="生成货位" name="create_location" type="object" class="oe_highlight" attrs="{'invisible': [('hide_shelf', '=', False)]}"/> -->
<!-- </xpath> -->
<xpath expr="//form/sheet" position="before">
<header>
<button string="生成货位" name="create_location" type="object" class="oe_highlight" attrs="{'invisible': [('hide_shelf', '=', False)]}"/>
<button string="生成货位" name="create_location" type="object" class="oe_highlight"
attrs="{'invisible': [('hide_shelf', '=', False)]}"/>
</header>
</xpath>
<xpath expr="//form/sheet/group[last()]">
@@ -64,6 +75,17 @@
</page>
</notebook>
</xpath>
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
</xpath>
</field>
</record>
@@ -74,7 +96,7 @@
<field name="arch" type="xml">
<xpath expr="//search[1]" position="inside">
<searchpanel class="account_root">
<!-- <field name="location_type" icon="fa-filter"/> -->
<!-- <field name="location_type" icon="fa-filter"/> -->
<field name="location_id" select="multi" domain="[('location_type', '=', '货架')]"/>
</searchpanel>
</xpath>
@@ -103,36 +125,36 @@
</div>
<div class="o_kanban_record_bottom">
<field name="product_sn_id"/>
<span> | </span>
<span>|</span>
<field name="product_id"/>
</div>
</div>
</t>
<!-- <t t-name="kanban-box"> -->
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
<!-- --><!-- 看板内容 -->
<!-- </div> -->
<!-- <div t-attf-class="oe_kanban_card"> -->
<!-- --><!-- 标题 -->
<!-- <div class="o_kanban_card_header"> -->
<!-- <div class="o_kanban_card_header_title"> -->
<!-- <field name="name"/> -->
<!-- </div> -->
<!-- </div> -->
<!-- --><!-- 内容 -->
<!-- <div class="o_kanban_record_bottom"> -->
<!-- <field name="location_status"/> -->
<!-- </div> -->
<!-- <div class="o_kanban_record_bottom"> -->
<!-- <field name="product_sn_id"/> -->
<!-- <span> | </span> -->
<!-- <field name="product_id"/> -->
<!-- </div> -->
<!-- </div> -->
<!-- </t> -->
<!-- <t t-name="kanban-box"> -->
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
<!-- --><!-- 看板内容 -->
<!-- </div> -->
<!-- <div t-attf-class="oe_kanban_card"> -->
<!-- --><!-- 标题 -->
<!-- <div class="o_kanban_card_header"> -->
<!-- <div class="o_kanban_card_header_title"> -->
<!-- <field name="name"/> -->
<!-- </div> -->
<!-- </div> -->
<!-- --><!-- 内容 -->
<!-- <div class="o_kanban_record_bottom"> -->
<!-- <field name="location_status"/> -->
<!-- </div> -->
<!-- <div class="o_kanban_record_bottom"> -->
<!-- <field name="product_sn_id"/> -->
<!-- <span> | </span> -->
<!-- <field name="product_id"/> -->
<!-- </div> -->
<!-- </div> -->
<!-- </t> -->
</templates>
</kanban>
</field>
@@ -145,23 +167,118 @@
<field name="view_mode">kanban,form</field>
</record>
<!-- <record id="example_action" model="ir.actions.act_window"> -->
<!-- <field name="name">Example</field> -->
<!-- <field name="type">ir.actions.act_window</field> -->
<!-- <field name="res_model">stock.location</field> -->
<!-- <field name="view_mode">kanban</field> -->
<!-- <field name="searchpanel">true</field> -->
<!-- <field name="searchpanel_field_label">货架</field> -->
<!-- <field name="searchpanel_field_name">parent_id</field> -->
<!-- <field name="searchpanel_field_group_by">['parent_id']</field> -->
<!-- <field name="domain">[('location_type', '=', '货位')]</field> -->
<!-- </record> -->
<!-- <record id="example_action" model="ir.actions.act_window"> -->
<!-- <field name="name">Example</field> -->
<!-- <field name="type">ir.actions.act_window</field> -->
<!-- <field name="res_model">stock.location</field> -->
<!-- <field name="view_mode">kanban</field> -->
<!-- <field name="searchpanel">true</field> -->
<!-- <field name="searchpanel_field_label">货架</field> -->
<!-- <field name="searchpanel_field_name">parent_id</field> -->
<!-- <field name="searchpanel_field_group_by">['parent_id']</field> -->
<!-- <field name="domain">[('location_type', '=', '货位')]</field> -->
<!-- </record> -->
<!-- <menuitem id="menu_stock_location" name="货位状态" parent="stock.menu_stock_root" -->
<!-- sequence="50" -->
<!-- action="kanban_action_id"/> -->
<!-- <menuitem id="menu_stock_location" name="货位状态" parent="stock.menu_stock_root" -->
<!-- sequence="50" -->
<!-- action="kanban_action_id"/> -->
<!--仓库根据权限增加审核按钮-->
<record id="view_warehouse_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.warehouse.form.sf.inherit</field>
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
</xpath>
</field>
</record>
</data>
<!--路线根据权限增加审核按钮-->
<record id="view_route_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.route.form.sf.inherit</field>
<field name="model">stock.route</field>
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
</xpath>
</field>
</record>
<!--规则根据权限增加审核按钮-->
<record id="view_rule_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.rule.form.sf.inherit</field>
<field name="model">stock.rule</field>
<field name="inherit_id" ref="stock.view_stock_rule_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
</xpath>
</field>
</record>
<!--作业类型根据权限增加审核按钮-->
<record id="view_picking_type_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.picking.type.form.sf.inherit</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.view_picking_type_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
</xpath>
</field>
</record>
<!--产品类别根据权限增加审核按钮-->
<record id="view_product_category_form_sf_inherit" model="ir.ui.view">
<field name="name">product.category.form.sf.inherit</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
</xpath>
</field>
</record>
</data>
</odoo>