【已解决】button所执行的方法(弹出一个窗口)
- 
在openerp里面我对于button所触发的方法不是十分了解。 
 从devloper文档里面得出
 [quote]Button
 : addabuttonusingthestringattributeaslabel. Whenclicked,itcantriggermethodsontheobject,workflow
 transitionsor actions(reports,wizards,...).- string: definethebutton’slabel
- confirm: the messagefortheconfirmationwindow, ifneeded. Eg: confirm=”Are you sure?”
- name: thename of thefunctiontocallwhen thebuttonis pressed. In the case it’s an object function, it must take 4 arguments: cr, uid,ids, –
 cr isadatabasecursor
 – uidistheuserIDoftheuser who clicked thebutton
 – idsis the recordIDlist
 – **argsis atuple of additional arguments
- states: a comma-separated list of states (from the state field or from the workflow) in which the button must
 appear. Ifthestatesattributeis not given, the buttonisalwaysvisible.
- type: thisattributecanhave3values – “workflow” (value by default): the function to call is a function of
 workflow
 – “object”: thefunction to callis amethod of theobject
 – “action”: callanactioninstead ofafunction
 Example
 [/quote] 
 [attach]211[/attach]我现在就是想添加一个button通过读取使用者在BOM code里面填入的东西,来执行相应的操作。 
 但是不知为什么当我点击create的时候,会出现错误如下:[attach]212[/attach] -----> [attach]213[/attach] 下面是我view的代码[code] 
 <button name="create_product_with_bomcode" string="CREATE"/>
 </openerp>
 [/code]我在create_product_with_bomcode应该怎么写才可以读取到BOM Code里面填入的数据呢?
 我说的是直接在client上面填入,之后点击create,按照填入的bomcode进行操作。这个bomcode不用保存的。谢谢大家了。。。。:) [[i] 本帖最后由 popkar77 于 2009-9-21 16:26 编辑 [/i]] 
- 
解决了。 
 关于弹出窗口可以看module 的project里面的例子比较简单
 具体就是这句[code]
 <button name="%(action_config_compute_remaining)d" string="Review" type="action" colspan="1" target="new" states="open,pending"/>
 [/code]而="%(action_config_compute_remaining)d"这个写法官方论坛上也得出答案
 [quote]
 It will search for id of that action in ir_model_data and replace it with integer value.
 you can check the view from Administration/Customization/User Interface/Views
 You will get id of that action in views[/quote] 
 结果如下:
 [attach]220[/attach][[i] 本帖最后由 popkar77 于 2009-9-21 16:37 编辑 [/i]] 
- 
view ID 
 我举个例子,例如:project这个moudule
 project_view.xml
 里面的[code]
 <record id="view_config_compute_remaining" model="ir.ui.view">
 <field name="name">Compute Remaining Hours </field>
 <field name="model">config.compute.remaining</field>
 <field name="type">form</field>
 <field name="arch" type="xml">
 <form string="Remaining Hours">
 <separator colspan="4" string="Change Remaining Hours"/>
 <newline/>
 <field name="remaining_hours" widget="float_time"/>
 <group col="4" colspan="4">
 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
 <button icon="gtk-ok" name="compute_hours" string="Update" type="object"/>
 </group>
 </form>
 </field>
 </record><record id="action_config_compute_remaining" model="ir.actions.act_window"> 
 <field name="name">Compute Remaining Hours</field>
 <field name="type">ir.actions.act_window</field>
 <field name="res_model">config.compute.remaining</field>
 <field name="view_type">form</field>
 <field name="view_mode">form</field>
 <field name="target">new</field>
 </record>
 [/code][code]
 <button name="%(action_config_compute_remaining)d" string="Review" type="action" colspan="1" target="new" states="open,pending"/>
 [/code]action_config_compute_remaining就是一个view的id,
 最上面的view_config_compute_remaining就是要弹出窗口的详细内容。
 view_config_compute_remaining和action_config_compute_remaining的连接方法就是field name
 [code]
 <field name="name">Compute Remaining Hours </field>
 [/code]

