Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenERP: How to override an inherited view's action?

Tags:

openerp

I'd like to supress the display of the Stock Value Variation chart on the default view of the Manufacturing page. I'm using inheritance to modify the form. Right now I can inherit the form and get additional actions to show up. However, I'm not able to use position="replace" for an action, form, or on the "arch" field. So how do I stop display of the Stock Value Variation, or the other graphs?

Background: I'm new to OpenERP, and I'm trying to use the Manufacturing module to create a custom app for tracking prototype hardware development. Much of the functionality I want is already there, so OpenERP is a natural fit. However, the first step is to disable anything unnecessary. Inheriting and replacing fields to stop them from showing up hasn't been a problem, but I'm not having any luck getting rid of the actions that create reports and graphs.

Related questions:

  • Would it be better to leave the Manufacturing pages alone, and create a whole new "Prototypes" module? In other words, right now I'm trying to change the behavior of the Manufacturing pages -- would it be better to create a new module and add a "Prototypes" button along with Sales/Purchase/Warehouse/Manufacturing/Accounting/Settings at the top of the default page?

  • I'm not sure where the extra "Change Layout" button at the top of the default Manufacturing page is comming from, or how to get rid of that. Any ideas?

  • Is the problem I'm having derived from the dynamic names and refering to them in another module? (E.g. the name="%(procurement.procurement_exceptions)d" in mrp_boot_view.xml).

OpenERP 6.1 on Windows, install everything locally.

Here's the code:

__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>
like image 448
Jeff P. Avatar asked Nov 06 '12 19:11

Jeff P.


1 Answers

You can not use replace attribute to modify anything in action.

To inherit action or make changes in action you can override action's id.
For Example I want to override action of procurement module, then I can change view_type or view_mode or context or search_view_id as per my requirement:

<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>

To remove extra stuff from inherited view (taken from comment):

<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>
like image 140
Sudhir Arya Avatar answered Nov 01 '22 05:11

Sudhir Arya