How to add relate option on a model

Hello I am trying to make a shortcut from a module to another and I can’t find information, I want to add a module on the list that is displayed on the Related entries
Screenshot from 2020-03-20 22-46-35
Is there any tutorial to do that?

Thnaks in advance

This action is a related button which is used to show records related to the current one. For example, the invoices related to a party.

In order to create a new relate option you should define a new action which has a domain that evaluates active_ids. This will be replaced by the clients with the ids of the selected records. Then you should define a form_relate keyword on the action with the model where you want to add this relate option.

For example, Here is the xml definition of the Party invoices relate.


Im following the manual and adding a module to tryton and there’s a problem to try to open it, give me this error:

ERROR trytond.protocols.dispatcher <class 'trytond.modules.waiterman.tablepos.Area'>.fields_view_get(*(798, 'tree', {'client': '06ac72cc-23aa-4b74-9d47-392ca70c2ab6', 'warehouse': None, 'employee': None, 'company': None, 'language': 'es', 'language_direction': 'ltr', 'groups': [1, 11, 9, 4, 26, 22, 6, 12, 2, 15, 16, 7, 18, 3, 10, 25, 21, 27, 23, 5, 31, 30, 14, 29, 13, 20, 19, 17, 8, 28, 24]}), **{}) from admin@
Traceback (most recent call last):
  File "/home/hidura/Documents/RESTPOS/server/TrytonREST/env/lib/python3.7/site-packages/trytond/protocols/", line 186, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/home/hidura/Documents/RESTPOS/server/TrytonREST/env/lib/python3.7/site-packages/trytond/model/", line 303, in fields_view_get
    tree = etree.fromstring(result['arch'], parser=parser)
  File "src/lxml/etree.pyx", line 3235, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1875, in lxml.etree._parseMemoryDocument
ValueError: can only parse strings

This is my xml where I declared the menu options.

<?xml version=“1.0”?>
    <menuitem name=“Restaurant Management” id=“menu_restman” sequence=“1”/>
    <record model=“ir.ui.view” id=“area_view_form”>
      <field name=“model”></field>
      <field name=“type”>form</field>
      <field name=“name”>arearest_form</field>
    <record model=“ir.ui.view” id=“area_view_list”>
      <field name=“model”></field>
      <field name=“type”>tree</field>
      <field name=“name”>arearest_list</field>
    <record model=“ir.action.act_window” id=“act_area”>
      <field name=“name”>Areas</field>
      <field name=“res_model”></field>
    <record model=“ir.action.act_window.view” id=“act_area_view_list”>
      <field name=“sequence” eval=“10”/>
      <field name=“view” ref=“area_view_list”/>
      <field name=“act_window” ref=“act_area”/>
    <record model=“ir.action.act_window.view” id=“act_area_view_form”>
      <field name=“sequence” eval=“20”/>
      <field name=“view” ref=“area_view_form”/>
      <field name=“act_window” ref=“act_area”/>
    <menuitem parent=“menu_restman” sequence=“1” action=“act_area” id=“menu_area”/>

You are missing the view architechture for the following records:

You shouuld define them a file name arearest_form.xml and arearest_list.xml inside the view folder of your module

1 Like

And how I can add a action to be executed? Like the one displays on this button -> Screenshot from 2020-03-21 22-10-32

Never mind, I found it! Is creating a wizard and adding it to a group and connecting it to the class like this:

    <record model=“ir.action.wizard” id=“wizard_erase”>
        <field name=“name”>Erase</field>
        <field name=“wiz_name”>party.erase</field>
        <field name=“model”></field> --> Model
    <record model=“” id=“wizard_erase-group_party_admin”>
        <field name=“action” ref=“wizard_erase”/>
        <field name=“group” ref=“group_rest_admin”/>
    <record model=“ir.action.keyword” id=“wizard_erase_keyword1”>
        <field name=“keyword”>form_action</field>
       <field name=“model”>,-1</field>
       <field name=“action” ref=“wizard_erase”/>

    <record model=“ir.ui.view” id=“erase_ask_view_form”>
        <field name=“model”>party.erase.ask</field>
        <field name=“type”>form</field>
       <field name=“name”>erase_ask_form</field>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.