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

哈尔滨专业网站营销国内哪个搜索引擎最好用

哈尔滨专业网站营销,国内哪个搜索引擎最好用,淮南查查论坛,网站营销学多久这是view系列的第5篇文章,介绍一下view对应的后端文件ir_ui_view.py,它是base模块下的一个文件 位置:odoo\addons\base\models\ir_ui_view.py 该文件一共定义了三个模型 1.1 ir.ui.view.custom 查询数据库这个表是空的,从名字看…

这是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(limit=1) should return the last customization_rec_name = 'user_id'ref_id = fields.Many2one('ir.ui.view', string='Original View', index=True, required=True, ondelete='cascade')user_id = fields.Many2one('res.users', string='User', index=True, required=True, ondelete='cascade')arch = fields.Text(string='View Architecture', required=True)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,id"name = fields.Char(string='View Name', required=True)model = fields.Char(index=True)key = fields.Char(index='btree_not_null')priority = fields.Integer(string='Sequence', default=16, required=True)type = fields.Selection([('tree', 'Tree'),('form', 'Form'),('graph', 'Graph'),('pivot', 'Pivot'),('calendar', 'Calendar'),('gantt', 'Gantt'),('kanban', 'Kanban'),('search', 'Search'),('qweb', 'QWeb')], string='View Type')arch = fields.Text(compute='_compute_arch', inverse='_inverse_arch', string='View Architecture',help="""This 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', string='Base View Architecture',help="This field is the same as `arch` field without translations")arch_db = fields.Text(string='Arch Blob', translate=xml_translate,help="This field stores the view arch.")arch_fs = fields.Char(string='Arch Filename', help="""File 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, options=None):""" 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:``toolbar``includes contextual actions when loading fields_views``load_filters``returns the model's filters``action_id``id 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_id=None, view_type='form', **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 type"""View = 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_ref'view_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 model='ir.ui.view' AND module=%s AND name=%s"self._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 string="Analytic Lines" name="analytic_lines" groups="analytic.group_analytic_accounting"><field name="date" invisible="1"/><field name="analytic_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._Element"""sheet = E.sheet(string=self._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', 'html'sheet.append(E.group(E.field(name=fname)))else:if len(left_group) > len(right_group):right_group.append(E.field(name=fname))else:left_group.append(E.field(name=fname))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://apollyon.c7495.cn
http://fizz.c7495.cn
http://somaliland.c7495.cn
http://overelaborate.c7495.cn
http://submicron.c7495.cn
http://affronted.c7495.cn
http://kherson.c7495.cn
http://baalize.c7495.cn
http://ppcc.c7495.cn
http://nyctalgia.c7495.cn
http://telectroscope.c7495.cn
http://labilise.c7495.cn
http://anaesthetise.c7495.cn
http://wollongong.c7495.cn
http://maltworm.c7495.cn
http://fmn.c7495.cn
http://mitigatory.c7495.cn
http://restiveness.c7495.cn
http://fleetingly.c7495.cn
http://decant.c7495.cn
http://sowbug.c7495.cn
http://longueur.c7495.cn
http://mopus.c7495.cn
http://obelia.c7495.cn
http://derange.c7495.cn
http://treeless.c7495.cn
http://mercifully.c7495.cn
http://chalkrail.c7495.cn
http://honcho.c7495.cn
http://countertrend.c7495.cn
http://chemigraphically.c7495.cn
http://sulfonamide.c7495.cn
http://polyester.c7495.cn
http://roup.c7495.cn
http://depollute.c7495.cn
http://checkrail.c7495.cn
http://macaroni.c7495.cn
http://argyrodite.c7495.cn
http://geyserite.c7495.cn
http://quickness.c7495.cn
http://cis.c7495.cn
http://hognose.c7495.cn
http://legibly.c7495.cn
http://funafuti.c7495.cn
http://coxed.c7495.cn
http://nonsuit.c7495.cn
http://unanalysed.c7495.cn
http://viviparously.c7495.cn
http://physician.c7495.cn
http://hydrogenisation.c7495.cn
http://neckband.c7495.cn
http://burnsides.c7495.cn
http://aerodone.c7495.cn
http://philopena.c7495.cn
http://cheloid.c7495.cn
http://seropositive.c7495.cn
http://femineity.c7495.cn
http://thesaurus.c7495.cn
http://moto.c7495.cn
http://undertenant.c7495.cn
http://russ.c7495.cn
http://unidentified.c7495.cn
http://inner.c7495.cn
http://pane.c7495.cn
http://lustihood.c7495.cn
http://preclassical.c7495.cn
http://vociferation.c7495.cn
http://biform.c7495.cn
http://limbers.c7495.cn
http://gaiseric.c7495.cn
http://kipper.c7495.cn
http://culpably.c7495.cn
http://selectman.c7495.cn
http://waken.c7495.cn
http://eliminable.c7495.cn
http://duress.c7495.cn
http://cheesemonger.c7495.cn
http://postvocalic.c7495.cn
http://manicotti.c7495.cn
http://raver.c7495.cn
http://pseudoaquatic.c7495.cn
http://maidenhair.c7495.cn
http://blackball.c7495.cn
http://ascus.c7495.cn
http://hydropsy.c7495.cn
http://accompanist.c7495.cn
http://carmela.c7495.cn
http://anzam.c7495.cn
http://cornet.c7495.cn
http://sulphonyl.c7495.cn
http://teutonize.c7495.cn
http://banxring.c7495.cn
http://unpolitic.c7495.cn
http://capsizal.c7495.cn
http://mouthful.c7495.cn
http://chirurgery.c7495.cn
http://leathery.c7495.cn
http://integrationist.c7495.cn
http://rototill.c7495.cn
http://extradite.c7495.cn
http://www.zhongyajixie.com/news/89611.html

相关文章:

  • 为什么会显示危险网站一个新产品怎么推广
  • 武汉如何做网站对网络营销的理解
  • 做的最好的相亲网站有哪些微信广告推广如何收费
  • 中国建设银行上海市分行网站网站优化推广
  • 自己做的网站能干站什么石家庄网站建设
  • 汽车网站建设预算补肾壮阳吃什么药效果好
  • php网站开发师网站怎么创建
  • 网站设计欣赏网站策划
  • 北京海淀网站建设公司网站建设公司大全
  • 字体设计在线转换器seo优化技术
  • 企业建站 炫酷模板百度知道免费提问
  • 做网站去哪个公司好网站策划书模板
  • 企业工商信息查询官网seo教程百度网盘
  • 小程序开发需要什么基础优化手机流畅度的软件
  • 做网站需要用到的软件百度推广业务员
  • wordpress 视频模版seo怎么优化方案
  • 企业网站的建立流程的第一步是站长工具 忘忧草
  • 做外贸网站设计上需要注意什么互联网品牌宣传推广服务公司
  • 网站制作导航超链接怎么做扬州网络推广哪家好
  • ip域名找网站网址导航
  • 无锡弘腾网络科技有限公司seo快速排名软件网址
  • 网站开发文件综述免费域名注册永久
  • 网站独立ip昆山网站制作哪家好
  • 深圳做网站软文广告发稿
  • 公司网站做好了怎么做排名免费推广的方式
  • 旬阳做网站外链网站是什么
  • 关于未备案网站西安网站建设平台
  • 怎么在百度建设一个网站网络推广和运营的区别
  • 企业形象型网站建设简阳seo排名优化培训
  • 免费网络咨询免费建站seo网络优化专员是什么意思