OpenERP:如何覆盖继承视图的动作?

时间:2012-11-06 19:53:32

标签: openerp

我想在制造页面的默认视图中隐藏股票价值变化图表的显示。我正在使用继承来修改表单。现在我可以继承表单并获取其他操作来显示。但是,我无法对action,form或“arch”字段使用position =“replace”。那么如何停止显示股票价值变动或其他图表呢?

背景: 我是OpenERP的新手,我正在尝试使用Manufacturing模块创建一个自定义应用程序来跟踪原型硬件开发。我想要的大部分功能已经存在,所以OpenERP非常适合。但是,第一步是禁用任何不必要的东西。继承和替换字段以阻止它们显示并不是问题,但我没有运气摆脱创建报告和图形的操作

相关问题:

  • 将制造页面单独留下并创建会更好吗? 一个全新的“原型”模块?换句话说,现在我正在努力 改变制造页面的行为 - 是不是 最好创建一个新模块并添加一个“Prototypes”按钮 与销售/采购/仓库/制造/会计/设置在 默认页面的顶部?

  • 我不确定在顶部的额外“更改布局”按钮的位置 默认制造页面来自或如何摆脱 那。有什么想法吗?

  • 我是从动态名称和引用中得到的问题 他们在另一个模块? (例如 mrp_boot_view.xml中的name =“%(procurement.procurement_exceptions)d”。

Windows上的OpenERP 6.1,在本地安装所有内容。

以下是代码:

__openerp__.py:

{
    "name" : "prototyping tool",
    "version" : "0.1",
    "author" : "",
    "website" : "",
    "category" : "Manufacturing",
    "sequence": 19,
    "images" : [],
    "depends" : ["mrp", "base"],
    "description": """initial version doesn't do much, simplifies MRP views.""",
    'init_xml': [],
    'update_xml': ["mrp_boot_view.xml"],
    'demo_xml': [],
    'test': [],
    'installable': True,
    'application': True,
    'auto_install': False,
    'certificate': '',
}

__init__.py:
    import mrp_boot
    import mrp

mrp_boot.py:

# None of this functionality is currently used

import mrp_boot
import mrp

from osv import fields, osv

class mrp_boot(osv.osv):
   _name = "mrp_boot"
   _inherit = "purchase.order"

   def _get_boot_expense_category(self, cursor, user_id, context=None):
       return (
           ('NRE', 'NRE'),
           ('MatProto', 'Materials / Prototype'),
           ('Capital', 'Capital'),
           ('Loaner', 'Loaner'))

   _columns = {
       'boot_expense_category':
           fields.selection( _get_boot_expense_category
                           , 'Expense Category'
                           , help="How the equipment for the entire PO is to be expensed. If multiple methods will be used, multiple POs must be created"),
       }

mrp_boot()

mrp_boot_view.xml:

# I'd like to supress the display of the charts generated by the actions 
<?xml version="1.0" ?>

<openerp>
<data>
     <record id="board_mrp_manager_form" model="ir.ui.view">
          <field name="name">board.mrp.manager.form</field>
          <field name="model">board.board</field>
          <field name="inherit_id" ref="mrp.board_mrp_manager_form" />
          <field name="type">form</field>
          <field name="priority" eval="15"/>
          <field name="arch" type="xml">

               <form string="Manufacturing board">
                    <board style="2-1">
                        <column>
                            <action name="%(procurement.procurement_exceptions)d" string="New Prototype Outlook" domain="[('state','=','exception')]"/>
                        </column>
                        <column>
                        </column>
                    </board>
                </form>

          </field>
     </record>
</data>
</openerp>

2 个答案:

答案 0 :(得分:5)

您无法使用replace属性修改操作中的任何内容。

要继承操作或在操作中进行更改,您可以覆盖操作的ID。
例如我想覆盖采购模块的操作,然后我可以根据我的要求更改view_type或view_mode或context或search_view_id:

<record id="procurement.procurement_exceptions" model="ir.actions.act_window">
        <field name="name">Procurement Exceptions</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">procurement.order</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="context">{'search_default_perm_exceptions':1}</field>
        <field name="search_view_id" ref="procurement.view_procurement_filter"/>
</record>

从继承视图中删除额外的东西(取自评论):

<record id="my_customized_board_mrp_manager_form" model="ir.ui.view">
    <field name="name">board.mrp.manager.form</field>
    <field name="model">board.board</field>
    <field name="inherit_id" ref="mrp.board_mrp_manager_form" />
    <field name="type">form</field>
    <field name="arch" type="xml">
        <action name="%(mrp.action_report_in_out_picking_tree)d" position="replace"/>
    </field>
<record>

答案 1 :(得分:0)

当您从purchase.order继承所有字段时,您无需使用_name =&#39; mrp_boot&#39; ..因为您正在使用现有对象,而不是创建新对象