从视图结构来管控:

  1. 以stock.picking 的tree 视图为例,如果将name字段设置群组管控
<?xml version="1.0"?>
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" decoration-danger="state not in ('cancel', 'done') and scheduled_date < current_date" string="Picking list">
<field name="name" groups="stock.group_stock_manager" />
<field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
<field name="partner_id"/>
<field name="date" invisible="1"/>
<field name="scheduled_date"/>
<field name="origin"/>
<field name="group_id" invisible="1"/>
<field name="backorder_id"/>
<field name="state"/>
<field name="priority" invisible="1"/>
<field name="picking_type_id" invisible="1"/>
</tree>
  1. 服务器返回的字段结构将发生变更,根据用户登录所拥有的群组:
{
"list": {
"model": "stock.picking",
"name": "stock.picking.tree",
"toolbar": {
"relate": [],
"print": [
{
"model": "stock.picking",
"groups_id": [],
"attachment": false,
"report_type": "qweb-pdf",
"type": "ir.actions.report",
"binding_model_id": [
220,
"Transfer"
],
"create_uid": [
1,
"OdooBot"
],
"paperformat_id": false,
"jasper_report": false,
"create_date": "2020-03-05 14:07:45",
"binding_type": "report",
"attachment_use": false,
"__last_update": "2020-06-21 13:06:37",
"help": false,
"name": "Picking Operations",
"display_name": "Picking Operations",
"report_name": "stock.report_picking",
"jasper_output": "pdf",
"string": "Picking Operations",
"id": 169,
"xml_id": "stock.action_report_picking",
"report_file": "stock.report_picking_operations",
"write_uid": [
1,
"OdooBot"
],
"write_date": "2020-06-21 13:06:37",
"model_id": [
220,
"Transfer"
],
"print_report_name": "'Picking Operations - %s - %s' % (object.partner_id.name or '', object.name)",
"multi": false,
"jasper_file_ids": []
},
{
"model": "stock.picking",
"groups_id": [],
"attachment": false,
"report_type": "qweb-pdf",
"type": "ir.actions.report",
"binding_model_id": [
220,
"Transfer"
],
"create_uid": [
1,
"OdooBot"
],
"paperformat_id": false,
"jasper_report": false,
"create_date": "2020-03-05 14:07:45",
"binding_type": "report",
"attachment_use": false,
"__last_update": "2020-06-21 13:06:37",
"help": false,
"name": "Delivery Slip",
"display_name": "Delivery Slip",
"report_name": "stock.report_deliveryslip",
"jasper_output": "pdf",
"string": "Delivery Slip",
"id": 170,
"xml_id": "stock.action_report_delivery",
"report_file": "stock.report_deliveryslip",
"write_uid": [
1,
"OdooBot"
],
"write_date": "2020-06-21 13:06:37",
"model_id": [
220,
"Transfer"
],
"print_report_name": "'Delivery Slip - %s - %s' % (object.partner_id.name or '', object.name)",
"multi": false,
"jasper_file_ids": []
},
{
"model": "stock.picking",
"groups_id": [],
"attachment": false,
"report_type": "qweb-pdf",
"type": "ir.actions.report",
"binding_model_id": [
220,
"Transfer"
],
"create_uid": [
1,
"OdooBot"
],
"paperformat_id": false,
"jasper_report": false,
"create_date": "2020-05-30 08:01:33",
"binding_type": "report",
"attachment_use": false,
"__last_update": "2020-06-21 13:09:01",
"help": false,
"name": "Delivery Slip",
"display_name": "Delivery Slip",
"report_name": "bi_professional_reports_templates.report_deliveryslip",
"jasper_output": "pdf",
"string": "Delivery Slip",
"id": 662,
"xml_id": "bi_professional_reports_templates.action_report_delivery_custom",
"report_file": "bi_professional_reports_templates.report_deliveryslip",
"write_uid": [
1,
"OdooBot"
],
"write_date": "2020-06-21 13:09:01",
"model_id": [
220,
"Transfer"
],
"print_report_name": false,
"multi": false,
"jasper_file_ids": []
}
],
"action": [
{
"groups_id": [],
"limit": 0,
"xml_id": "stock_picking_batch.stock_picking_to_batch_action_stock_picking",
"views": [
[
false,
"form"
]
],
"auto_search": true,
"type": "ir.actions.act_window",
"filter": false,
"context": "{}",
"binding_model_id": [
220,
"Transfer"
],
"create_uid": [
1,
"OdooBot"
],
"view_mode": "form",
"view_type": "form",
"domain": "[]",
"create_date": "2020-04-29 10:53:30",
"binding_type": "action",
"display_name": "Add to Batch",
"view_id": false,
"help": false,
"name": "Add to Batch",
"res_id": 0,
"usage": false,
"string": "Add to Batch",
"view_ids": [],
"id": 565,
"res_model": "stock.picking.to.batch",
"src_model": "stock.picking",
"write_uid": [
1,
"OdooBot"
],
"write_date": "2020-06-21 13:07:37",
"search_view_id": false,
"__last_update": "2020-06-21 13:07:37",
"search_view": "{'model': 'stock.picking.to.batch', 'name': 'default', 'arch': '<search string=\"Batch Picking Lines\"><field name=\"id\" modifiers=\"{"readonly": true}\"/></search>', 'type': 'search', 'fields': {'id': {'change_default': False, 'depends': (), 'store': True, 'company_dependent': False, 'sortable': True, 'type': 'integer', 'views': {}, 'required': False, 'readonly': True, 'string': 'ID', 'manual': False, 'searchable': True}}, 'field_parent': False}",
"multi": true,
"target": "new"
}
]
},
"arch": "<tree decoration-info=\"state == 'draft'\" decoration-muted=\"state == 'cancel'\" decoration-danger=\"state not in ('cancel', 'done') and scheduled_date < current_date\" string=\"Picking list\">\n <field name=\"name\" invisible=\"1\" modifiers=\"{"column_invisible": true, "invisible": true, "readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n <field name=\"location_dest_id\" can_create=\"false\" can_write=\"false\" modifiers=\"{"required": true, "readonly": [["state", "not in", ["draft"]]]}\"/>\n <field name=\"partner_id\" on_change=\"1\" can_create=\"true\" can_write=\"true\" modifiers=\"{"readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n <field name=\"date\" invisible=\"1\" modifiers=\"{"column_invisible": true, "readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n <field name=\"scheduled_date\" modifiers=\"{}\"/>\n <field name=\"origin\" modifiers=\"{"readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n <field name=\"group_id\" invisible=\"1\" can_create=\"true\" can_write=\"true\" modifiers=\"{"column_invisible": true, "readonly": true}\"/>\n <field name=\"backorder_id\" can_create=\"true\" can_write=\"true\" modifiers=\"{"readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n <field name=\"state\" modifiers=\"{"readonly": true}\"/>\n <field name=\"priority\" invisible=\"1\" modifiers=\"{"column_invisible": true, "readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n <field name=\"picking_type_id\" invisible=\"1\" on_change=\"1\" can_create=\"false\" can_write=\"false\" modifiers=\"{"column_invisible": true, "required": true, "readonly": [["state", "not in", ["draft"]]]}\"/>\n <field name=\"batch_id\" can_create=\"true\" can_write=\"true\" modifiers=\"{"readonly": [["state", "in", ["cancel", "done"]]]}\"/>\n \n </tree>",
"base_model": "stock.picking",
"type": "tree",
"view_id": 688,
"field_parent": false,
"fields": {
"batch_id": {
"change_default": false,
"depends": [],
"type": "many2one",
"help": "Batch associated to this picking",
"sortable": true,
"company_dependent": false,
"searchable": true,
"context": {},
"store": true,
"views": {},
"required": false,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"domain": [],
"string": "Batch Picking",
"manual": false,
"readonly": false,
"relation": "stock.picking.batch"
},
"picking_type_id": {
"change_default": false,
"depends": [],
"store": true,
"states": {
"draft": [
[
"readonly",
false
]
]
},
"company_dependent": false,
"sortable": true,
"type": "many2one",
"context": {},
"views": {},
"required": true,
"readonly": true,
"domain": [],
"string": "Operation Type",
"manual": false,
"searchable": true,
"relation": "stock.picking.type"
},
"priority": {
"change_default": false,
"depends": [
"move_lines.priority"
],
"store": true,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"company_dependent": false,
"sortable": true,
"type": "selection",
"help": "Priority for this picking. Setting manually a value here would set it as priority for all the moves",
"views": {},
"selection": [
[
"0",
"Not urgent"
],
[
"1",
"Normal"
],
[
"2",
"Urgent"
],
[
"3",
"Very Urgent"
]
],
"readonly": false,
"string": "Priority",
"manual": false,
"searchable": true,
"required": false
},
"backorder_id": {
"change_default": false,
"depends": [],
"type": "many2one",
"help": "If this shipment was split, then this field links to the shipment which contains the already processed part.",
"sortable": true,
"company_dependent": false,
"searchable": true,
"context": {},
"store": true,
"views": {},
"required": false,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"domain": [],
"string": "Back Order of",
"manual": false,
"readonly": false,
"relation": "stock.picking"
},
"origin": {
"change_default": false,
"depends": [],
"store": true,
"company_dependent": false,
"translate": false,
"sortable": true,
"type": "char",
"trim": true,
"help": "Reference of the document",
"views": {},
"readonly": false,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"string": "Source Document",
"manual": false,
"searchable": true,
"required": false
},
"name": {
"change_default": false,
"depends": [],
"store": true,
"company_dependent": false,
"translate": false,
"sortable": true,
"type": "char",
"trim": true,
"views": {},
"required": false,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"readonly": false,
"string": "Reference",
"manual": false,
"searchable": true
},
"scheduled_date": {
"change_default": false,
"depends": [
"move_lines.date_expected"
],
"store": true,
"company_dependent": false,
"sortable": true,
"type": "datetime",
"help": "Scheduled time for the first part of the shipment to be processed. Setting manually a value here would set it as expected date for all the stock moves.",
"views": {},
"readonly": false,
"string": "Scheduled Date",
"manual": false,
"searchable": true,
"required": false
},
"partner_id": {
"change_default": false,
"depends": [],
"store": true,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"company_dependent": false,
"sortable": true,
"type": "many2one",
"context": {},
"views": {},
"required": false,
"readonly": false,
"domain": [],
"string": "Partner",
"manual": false,
"searchable": true,
"relation": "res.partner"
},
"date": {
"change_default": false,
"depends": [],
"store": true,
"company_dependent": false,
"sortable": true,
"type": "datetime",
"help": "Creation Date, usually the time of the order",
"views": {},
"readonly": false,
"states": {
"cancel": [
[
"readonly",
true
]
],
"done": [
[
"readonly",
true
]
]
},
"string": "Creation Date",
"manual": false,
"searchable": true,
"required": false
},
"group_id": {
"change_default": false,
"depends": [
"move_lines.group_id"
],
"store": true,
"related": [
"move_lines",
"group_id"
],
"company_dependent": false,
"sortable": true,
"type": "many2one",
"searchable": true,
"context": {},
"views": {},
"required": false,
"domain": [],
"string": "Procurement Group",
"manual": false,
"readonly": true,
"relation": "procurement.group"
},
"state": {
"change_default": false,
"depends": [
"move_type",
"move_lines.state",
"move_lines.picking_id"
],
"store": true,
"company_dependent": false,
"sortable": true,
"type": "selection",
"help": " * Draft: not confirmed yet and will not be scheduled until confirmed.\n * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows).\n * Waiting: if it is not ready to be sent because the required products could not be reserved.\n * Ready: products are reserved and ready to be sent. If the shipping policy is 'As soon as possible' this happens as soon as anything is reserved.\n * Done: has been processed, can't be modified or cancelled anymore.\n * Cancelled: has been cancelled, can't be confirmed anymore.",
"views": {},
"selection": [
[
"draft",
"Draft"
],
[
"waiting",
"Waiting Another Operation"
],
[
"confirmed",
"Waiting"
],
[
"assigned",
"Ready"
],
[
"done",
"Done"
],
[
"cancel",
"Cancelled"
]
],
"readonly": true,
"string": "Status",
"manual": false,
"searchable": true,
"required": false
},
"location_dest_id": {
"change_default": false,
"depends": [],
"store": true,
"states": {
"draft": [
[
"readonly",
false
]
]
},
"company_dependent": false,
"sortable": true,
"type": "many2one",
"context": {},
"views": {},
"required": true,
"readonly": true,
"domain": [],
"string": "Destination Location",
"manual": false,
"searchable": true,
"relation": "stock.location"
}
}
}
}
  1. 从返回的结果中可以看到:当前登录用户没有​​stock.group_stock_manager​​​权限,故字段中的​​name​​将不会返回
  2. 但是数据的返回结果是不会变更的,即接口​​search_read​​​的结果不会发生改变,仍然有​​name​​字段,只是没有被js处理罢了.
{
"0": {
"priority": false,
"name": "My Co/IN/00001",
"origin": false,
"partner_id": false,
"scheduled_date": "2020-05-13 03:14:38",
"id": 36,
"batch_id": false,
"picking_type_id": [
7,
"My Company, Chicago: Receipts"
],
"date": "2020-05-13 03:14:43",
"backorder_id": false,
"location_dest_id": [
27,
"My Co/Stock"
],
"state": "done",
"group_id": false
}
}

懂得,原来世界如此简单!