Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Need help/hint [Closed]

By
Dr Obx
on 4/28/15, 12:10 PM 393 views

The Question has been closed for reason: not relevant or out dated

by
Dr Obx
on 05/10/2015 17:29:26

Guys, i just created a class and added a "menuitem" but for some reason i can't find it anywhere.


class product_casesize(orm.Model):

_name = 'product.casesize'

_columns = {

'name': fields.char('Case size'),

}

class product_template(orm.Model):

_inherit = 'product.template'

_columns = {

'product_casesize_id': fields.many2one(

'product.casesize',

'Case size', help='Select size.', ondelete='restrict'),

}


and menuitem in xml:

<menuitem name="Case size" id="menu_product_casesize" action="action_product_casesize" parent="product.prod_config_main"/>

so once i add something into this class i cant remove it because it only allow me to do it one way.

What should i do to have this option available ?

0
Michael Thomas
On 4/28/15, 5:26 PM

In order to see a menuitem and have it load a view, you typically need the following (shown with some examples from some code I recently wrote). Notice that the 2 XML objects create a record in ir.ui.view and ir.actions. 

1. An existing class or, in this case, the new one you created.

 class mrp_partsorder(osv.Model):
    _name = 'mrp.partsorder'

    _columns = {
        'scheduleStart': fields.datetime('Date Scheduled'),
        'scheduleend': fields.datetime('Schedule End'),
        'processStart': fields.datetime('Start Date'),
        'processEnd': fields.datetime('End Date'),
        'completedby_id': fields.many2one('res.users', string="Completed By"),
        'sourceorder_id': fields.many2one('mrp.production', string="Manufacturing Order"),
        'product_id': fields.many2one('product.product', related="sourceorder_id.product_id"),
        'options': fields.char(string="Options", related='sourceorder_id.options'),
        'state': fields.selection(
            [('new', 'New'), 
             ('started', 'Started'),
             ('paused', 'Paused'),
             ('complete', 'Complete')],
            string='Status',
            track_visibility='onchange', copy=False,
            help="This the the state of the current suborder."),
     }



2. A view of that class defined in xml. 

 <record id="mrp_partsorder_tree" model="ir.ui.view">
            <field name="name">mrp.partsorder.tree</field>
            <field name="model">mrp.partsorder</field>
            <field name="arch" type="xml">
                <tree create="false" editable="bottom" default_order="scheduleStart desc" string="Part Orders">
                    <field name="sourceorder_id" string="Order" readonly="True"/>
                    <field name="product_id" string="Part Number" options="{'no_open': False}"/>
                    <field name="options" string="Options" readonly="True"/>
                    <field name="scheduleStart" string="Scheduled" readonly="True"/>
                    <field name="state" string="Status" readonly="True"/>
                    <field name="primarystate" string="Primary Status"/>
                    <button name="button_parts_start" string="Start" class="oe_highlight" states="new"/>
                    <button name="button_parts_pause" string="Pause" class="oe_highlight" states="started" />
                    <button name="button_parts_unpause" string="Unpause" class="oe_highlight" states="paused"/>
                    <button name="button_parts_complete" string="Complete" class="oe_highlight" states="started"/>
                </tree>
            </field>
        </record>


3. A window action to load the view.

 <record id="tc_partaction" model="ir.actions.act_window">
            <field name="name">Part Orders</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">mrp.partsorder</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,calendar,graph,gantt</field>
            <field name="view_id" eval="False"/>
</record>


4. A menuitem that points to the action (which you have).

<menuitem id="tc_part" parent="tc_workcenters" action="tc_partaction" sequence="10"/> 


Sorted :) just added one line into the xml: ir.actions.act_window

Dr Obx
on 4/29/15, 6:31 AM
0
Dr Obx
On 4/29/15, 6:14 AM

Thank you, i just missed one detail, now it works beautifully :)

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/28/15, 12:10 PM
Seen: 393 times
Last updated: 5/10/15, 5:29 PM