odoo 字段权限管控原理

网友投稿 733 2022-10-11

odoo 字段权限管控原理

odoo 字段权限管控原理

从视图结构来管控:

以stock.picking 的tree 视图为例,如果将name字段设置群组管控

服务器返回的字段结构将发生变更,根据用户登录所拥有的群组:

{ "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': '', '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": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n ", "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" } } }}

从返回的结果中可以看到:当前登录用户没有​​stock.group_stock_manager​​​权限,故字段中的​​name​​将不会返回但是数据的返回结果是不会变更的,即接口​​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 }}

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

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:IT之家小程序版客户端(使用 Mpvue 开发)(小程序之家app)
下一篇:django 执行原生的sql
相关文章

 发表评论

暂时没有评论,来抢沙发吧~