Skip to Content
Menu
This question has been flagged
1 Reply
2148 Views

Hello,


I created a tree view to see all data of model "mrp.workcenter.productivity" and a menu item to open this tree view.

I need when i click on a line, to open the form of the concerned "mrp.workorder" (field workorder_id in mrp.workcenter.productivity)


Is anybody knows how to do that ?


Here is my xml code for menu item and tree view :


<odoo>

    <record model="ir.ui.view" id="s_mrp_workcenter_productivity_tree_complet">

        <field name="name">Safar.s_mrp_workcenter_productivity_tree_complet</field>

        <field name="model">mrp.workcenter.productivity</field>

        <field name="arch" type="xml">

            <tree create="false">

                <field name="workorder_id"/>

                <field name="duration" widget="float_time" sum="Total duration"/>

                <field name="date_start"/>

            </tree>

        </field>

    </record>


    <record model="ir.actions.act_window" id="safar_tache_operateur_action">

        <field name="name">Tâches opérateurs</field>

        <field name="res_model">mrp.workcenter.productivity</field>

        <field name="view_mode">tree</field>

    </record>


    <menuitem id="safar_tache_operateur_action_menu" name="Tâches opérateurs" parent="mrp.menu_mrp_manufacturing" action="safar_tache_operateur_action" sequence="11"/>

</odoo>

Avatar
Discard
Best Answer

Hi,

Here is the updated XML code for the form view from parent tree view.

<record model="ir.actions.act_window" id="safar_tache_operateur_action">
<field name="name">Tâches opérateurs</field>
<field name="res_model">mrp.workcenter.productivity</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="s_mrp_workcenter_productivity_form_complet">
<field name="name">Safar.s_mrp_workcenter_productivity_form_complet</field>
<field name="model">mrp.workcenter.productivity</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Productivity">
<sheet>
<field name="workorder_id"/>
<field name="duration" widget="float_time" sum="Total duration"/>
<field name="date_start"/>
</sheet>
</form>
</field>
</record>

Regards

Avatar
Discard
Author

Hi Cybrosys,

Sorry i didn't saw your answer before!

Thank you for your help but i've got an error :

File "/home/odoo/src/odoo/odoo/addons/base/models/ir_ui_view.py", line 396, in _check_xml

raise ValidationError("%s\n\n%s" % (_("Error while validating view"), tools.ustr(e)))

odoo.tools.convert.ParseError: "Erreur lors de la validation de la vue

Le champ 'company_id' utilisé dans les attributs doit être présent dans la vue, mais il manque:

- 'company_id' dans domain="[('company_id', 'in', [company_id, False])]"

Contexte de l'erreur :

Vue `Safar.s_mrp_workcenter_productivity_form_complet`

[view_id: 3576, xml_id: n/a, model: mrp.workcenter.productivity, parent_id: n/a]

None" while parsing /home/odoo/src/user/safar_module/views/mrp_workcenter_productivity.xml:2, near

<odoo>

And about your solution, i don't understand it.

Why create a new form view? It is not possible to call the form view of mr.workorder which already exists ?