我在 openerp 中自定义了销售订单菜单,将其分为两个菜单,一个名为“Local”,另一个为“Export”。 我在 sale.order 类中添加了一些字段:
'is_local' : fields.boolean('Local'), #Default as true if user clicked the Local menu.
'is_export' : fields.boolean('Export'), #Default as true if user clicked the Export menu.
在 sale.order.line 类:
'is_local' : fields.related('order_id','is_local',type='boolean',string='Local',store=True)
'is_export' : fields.related('order_id','is_export',type='boolean',string='Export',store=True)
'length' : fields.float('Length', digits=(12,2)),
'width' : fields.float('Width', digits=(12,2)),
'height' : fields.float('Height', digits=(12,2)),
情况是这样的,如果我在 sale.order 中单击本地菜单字段:长度、宽度 和高度。行必须隐藏在 View 中。
我在 sale_order View 中这样做了:
<field name="order_line" context="{'default_is_local': local}"/>
<tree string="Order line">
<field name="is_local"/>
<field name="length" invisible="context.get('is_local',True)"/>
.
.
.
</field>
使用 invisible="context.get('is_local',True)",如果我选择导出菜单 w/c 不应该隐藏,它也会隐藏字段.当我使用 attrs="{'invisible':[('is_local','=',True)]}" 它不会隐藏本地和导出菜单上的字段。不知道要用什么技术。
我正在使用 openerp v7
非常感谢任何帮助!
==================================== 编辑
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">biz1.view.order.sale</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="priority">1</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="is_export" attrs="{'invisible':[('is_export','=',False)]}" />
<field name="is_local" attrs="{'invisible':[('is_local','=',False)]}" />
</xpath>
<xpath expr="//field[@name='order_line']" position="replace">
<field name="order_line" context="{'default_is_local':is_local}"
colspan="4" nolabel="1" widget="one2many_list">
<tree string="Order Line" editable="bottom" />
<field name="sequence" widget="handle" />
<field name="state" invisible="1" />
<field name="th_weight" invisible="1" />
<field name="is_local" />
<field name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}"
groups="base.group_user"
on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)" />
<field name="name" />
<field name="product_uom_qty"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}"
on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)" />
<field name="product_uom"
on_change="product_uom_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, context)"
groups="product.group_uom" options='{"no_open": True}' />
<field name="product_uos_qty" groups="product.group_uos"
invisible="1" />
<field name="product_uos" string="UoS" groups="product.group_uos"
invisible="1" />
<field name="tax_id" widget="many2many_tags"
domain="[('parent_id','=',False),('type_tax_use','<>','purchase')]" />
<field name="price_unit" />
<field name="length" invisible="context.get('is_local',True)" />
<field name="width" invisible="context.get('is_local',True)" />
<field name="height" invisible="context.get('is_local',True)" />
<field name="discount" groups="sale.group_discount_per_so_line" />
<field name="price_subtotal" />
</tree>
</field>
</xpath>
</field></record>
<!-- ##### LOCAL SO #### -->
<record id="action_local_sale_orders" model="ir.actions.act_window">
<field name="name">Local SO</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="view_id" ref="view_order_form_inherit" />
<field name="context">
{'default_is_local':'1'}
</field>
<field name="domain">[('is_local','=','1')]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a quotation that can be converted into a sales order.
</p>
<p>
OpenERP will help you efficiently handle the complete sales flow: quotation,
sales order, delivery, invoicing and payment.
</p>
</field>
</record>
<menuitem action="action_local_sale_orders" name="Local"
id="menu_local_sale_order" parent="base.menu_sales" sequence="6"
groups="base.group_sale_salesman,base.group_sale_manager" />
<!-- ##### EXPORT SO #### -->
<record id="action_export_sale_orders" model="ir.actions.act_window">
<field name="name">Export SO</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="view_id" ref="view_order_form_inherit" />
<field name="context">
{'default_is_export':'1'}
</field>
<field name="domain">[('is_export','=','1')]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a quotation that can be converted into a sales order.
</p>
<p>
OpenERP will help you efficiently handle the complete sales flow: quotation,
sales order, delivery, invoicing and payment.
</p>
</field>
</record>
<menuitem action="action_export_sale_orders" name="Export"
id="menu_export_sale_order" parent="base.menu_sales" sequence="6"
groups="base.group_sale_salesman,base.group_sale_manager" />
最佳答案
为要在其上显示/隐藏字段的菜单定义操作。
<record id="action_id" model="ir.actions.act_window">
<field name="name">Name</field>
<field name="res_model">Model</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="context">{'is_local' : True}</field>
</record>
并将该操作分配给菜单。然后您的代码工作正常。
你没有得到正确输出的原因是,一旦你的相关记录被存储,相关字段总是赋值。在您的情况下,如果未创建订单,那么它在 is_local 和 is_export 中给出什么?
因此,您需要通过操作通过上下文传递该值。
试试这个,让我知道你是否会得到解决方案。
在此处编辑您的代码。<field name="context">
{'default_is_export':'1','is_local':False}
</field>
<field name="context">
{'is_local':True}
</field>
<field name="length" invisible="context.get('is_local',False)" />
<field name="width" invisible="context.get('is_local',False)" />
<field name="height" invisible="context.get('is_local',False)" />
关于xml - 如何在 openerp 的 one2many 上隐藏一个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30746396/
出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits
如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何
我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss