当前位置: 首页 > news >正文

获取网站状态wordpress 文章分页 链接

获取网站状态,wordpress 文章分页 链接,企业管理系统包括哪些,百度 营销推广费用这是view系列的第5篇文章#xff0c;介绍一下view对应的后端文件ir_ui_view.py#xff0c;它是base模块下的一个文件 位置#xff1a;odoo\addons\base\models\ir_ui_view.py 该文件一共定义了三个模型 1.1 ir.ui.view.custom 查询数据库这个表是空的#xff0c;从名字看…这是view系列的第5篇文章介绍一下view对应的后端文件ir_ui_view.py它是base模块下的一个文件 位置odoo\addons\base\models\ir_ui_view.py 该文件一共定义了三个模型 1.1 ir.ui.view.custom 查询数据库这个表是空的从名字看和数据库表结构看 这个表应该是view和user的三方表可以根据用户自定义view 但是案例呢 class ViewCustom(models.Model):_name ir.ui.view.custom_description Custom View_order create_date desc # search(limit1) should return the last customization_rec_name user_idref_id fields.Many2one(ir.ui.view, stringOriginal View, indexTrue, requiredTrue, ondeletecascade)user_id fields.Many2one(res.users, stringUser, indexTrue, requiredTrue, ondeletecascade)arch fields.Text(stringView Architecture, requiredTrue)def _auto_init(self):res super(ViewCustom, self)._auto_init()tools.create_index(self._cr, ir_ui_view_custom_user_id_ref_id,self._table, [user_id, ref_id])return res 1.2 ir.ui.view 截取一部分字段 view的字典表保存从xml中解析的view信息。 class View(models.Model):_name ir.ui.view_description View_order priority,name,idname fields.Char(stringView Name, requiredTrue)model fields.Char(indexTrue)key fields.Char(indexbtree_not_null)priority fields.Integer(stringSequence, default16, requiredTrue)type fields.Selection([(tree, Tree),(form, Form),(graph, Graph),(pivot, Pivot),(calendar, Calendar),(gantt, Gantt),(kanban, Kanban),(search, Search),(qweb, QWeb)], stringView Type)arch fields.Text(compute_compute_arch, inverse_inverse_arch, stringView Architecture,helpThis field should be used when accessing view arch. It will use translation.Note that it will read arch_db or arch_fs if in dev-xml mode.)arch_base fields.Text(compute_compute_arch_base, inverse_inverse_arch_base, stringBase View Architecture,helpThis field is the same as arch field without translations)arch_db fields.Text(stringArch Blob, translatexml_translate,helpThis field stores the view arch.)arch_fs fields.Char(stringArch Filename, helpFile from where the view originates.Useful to (hard) reset broken views or to read arch from file in dev-xml mode.)1.3 Model 这是一个抽象模型 class Model(models.AbstractModel):_inherit base_date_name date #: field to use for default calendar view它继承自base模型让我们看看base模型是何方神圣从注释看这是一个基本模型所有的模型都要继承它。 odoo\addons\base\models\ir_model.py 这是一个抽象模型抽象的只有一名字而已。估计又很多地方对这个模型进行了扩展。我们搜索一下 # # IMPORTANT: this must be the first model declared in the module # class Base(models.AbstractModel): The base model, which is implicitly inherited by all models. _name base_description Base 前端的viewService中通过orm调用的getViews就是最终就是调用了这个模型的get_views方法 api.modeldef get_views(self, views, optionsNone): Returns the fields_views of given views, along with the fields ofthe current model, and optionally its filters for the given action.The return of the method can only depend on the requested view types,access rights (views or other records), view access rules, options,context lang and TYPE_view_ref (other context values cannot be used).Python expressions contained in views or representing domains (onpython fields) will be evaluated by the client with all the contextvalues as well as the record values it has.:param views: list of [view_id, view_type]:param dict options: a dict optional boolean flags, set to enable:toolbarincludes contextual actions when loading fields_viewsload_filtersreturns the models filtersaction_idid of the action to get the filters, otherwise loads the globalfilters or the model:return: dictionary with fields_views, fields and optionally filters调用链条 get_views get_view _get_view_cache _get_view 重点看一下 _get_view这个私有函数 api.modeldef _get_view(self, view_idNone, view_typeform, **options):Get the model view combined architecture (the view along all its inheriting views).:param int view_id: id of the view or None:param str view_type: type of the view to return if view_id is None (form, tree, ...):param dict options: bool options to return additional features:- bool mobile: true if the web client is currently using the responsive mobile view(to use kanban views instead of list views for x2many fields):return: architecture of the view as an etree node, and the browse record of the view used:rtype: tuple:raise AttributeError:if no view exists for that model, and no method _get_default_[view_type]_view exists for the view typeView self.env[ir.ui.view].sudo()# try to find a view_id if none providedif not view_id:# view_type_view_ref in context can be used to override the default viewview_ref_key view_type _view_refview_ref self._context.get(view_ref_key)if view_ref:if . in view_ref:module, view_ref view_ref.split(., 1)query SELECT res_id FROM ir_model_data WHERE modelir.ui.view AND module%s AND name%sself._cr.execute(query, (module, view_ref))view_ref_res self._cr.fetchone()if view_ref_res:view_id view_ref_res[0]else:_logger.warning(%r requires a fully-qualified external id (got: %r for model %s). Please use the complete module.view_id form instead., view_ref_key, view_ref,self._name)if not view_id:# otherwise try to find the lowest priority matching ir.ui.viewview_id View.default_view(self._name, view_type)if view_id:# read the view with inherited views appliedview View.browse(view_id)arch view._get_combined_arch()else:# fallback on default views methods if no ir.ui.view could be foundview View.browse()try:arch getattr(self, _get_default_%s_view % view_type)()except AttributeError:raise UserError(_(No default view of type %s could be found!, view_type))return arch, view 如果没有传入view_id, 那么就去上下文中查找_view_ref, 这给了我们一种思路那就是可以在上下文中指定视图。 如果还是获取不到view_id,那么调用View.default_view函数获取默认的视图。 如果获取到了view_id, view返回该条记录而arch返回处理好继承关系之后的结构 view View.browse(view_id)arch view._get_combined_arch()如果view_id 还是没有获取到那么还是做了最后的尝试 arch getattr(self, _get_default_%s_view % view_type)()调用了视图类型对应的函数以form为例调用_get_default_form_view返回arch如果没有这个函数那就抛出异常。 odoo 我已经尽了我最大的努力了。。。 1.4 view_ref 应用的案例 page stringAnalytic Lines nameanalytic_lines groupsanalytic.group_analytic_accountingfield namedate invisible1/field nameanalytic_line_ids context{tree_view_ref:analytic.view_account_analytic_line_tree, default_general_account_id:account_id, default_name: name, default_date:date, amount: (debit or 0.0)-(credit or 0.0)}/ /page随便找了 一个例子这是一个x2many字段在context中指定了 tree_view_ref那么系统在打开的时候就会调用这里指定的tree视图而不是默认的tree视图。 ir_ui_view.py的代码有3000行这里只介绍了很少的一部分后面如果有其他的知识点再来补充。 1.5 _get_default_form_view 通过代码动态生成视图这给了我们一共思路就是在审批流中等需要动态生成视图的场景下可以参考这种方式。 本质是动态生成或者改变arch在后端或者前端都可以做。 api.modeldef _get_default_form_view(self): Generates a default single-line form view using all fieldsof the current model.:returns: a form view as an lxml document:rtype: etree._Elementsheet E.sheet(stringself._description)main_group E.group()left_group E.group()right_group E.group()for fname, field in self._fields.items():if field.automatic:continueelif field.type in (one2many, many2many, text, html):# append to sheet left and right group if neededif len(left_group) 0:main_group.append(left_group)left_group E.group()if len(right_group) 0:main_group.append(right_group)right_group E.group()if len(main_group) 0:sheet.append(main_group)main_group E.group()# add an oneline group for field type one2many, many2many, text, htmlsheet.append(E.group(E.field(namefname)))else:if len(left_group) len(right_group):right_group.append(E.field(namefname))else:left_group.append(E.field(namefname))if len(left_group) 0:main_group.append(left_group)if len(right_group) 0:main_group.append(right_group)sheet.append(main_group)sheet.append(E.group(E.separator()))return E.form(sheet)
http://www.w-s-a.com/news/101125/

相关文章:

  • 直播网站模板新营销平台电商网站
  • 建设部指定招标网站免费的企业查询软件
  • 做前端常用的网站及软件下载平台优化是什么意思
  • 企石镇仿做网站wordpress 网站白屏
  • 班级网站建设规划书专业定制网红变色杯
  • 上海网站设计公司电话甘肃路桥建设集团有限公司官方网站
  • 哈尔滨网站建设网站开发陕西省建设监理工程协会网站
  • 微信公众号电商网站开发wordpress增加论坛
  • 网站建设视频百度网盘下载免费wordpress搭建
  • 哈尔滨市网站建设公司汕头市公司网站建设平台
  • 东莞网站建设方案外包甘肃两学一做网站
  • 网站建设优化排名推广平面设计职业学校
  • 网后台的网站怎么做网站代理商
  • 网站如何转移到新的空间服务器上手机无人区离线地图app
  • 网站建设模板的买域名做网站的坏处
  • 长春做网站qianceyun做景观素材有哪几个网站
  • 自己建的网站也要注册域名吗邯郸市做网站
  • 天津网站建设制作软件潍坊个人做网站
  • 重庆城市建设集团官方网站php用什么做网站服务器
  • 深圳坪山站重庆市园林建设有限公司网站
  • 网站建设图片教程如何用自己的电脑建网站
  • 《网页设计与网站建设》A卷答案广东新闻联播
  • 海南专业网站运营托管wordpress 去掉主题
  • 企业品牌网站制作甜品制作网站
  • 手机网站怎么制作影响力网站建设
  • 猪八戒网站做私活赚钱吗一尊网 又一个wordpress站点
  • 上海市做网站的公司滨州哪里做网站
  • 简单的网站建设步骤wordpress 贴吧主题
  • 金泉网做网站找谁表格做网站
  • 北京做兼职从哪个网站好江西省建设监督网站电子网