0

I am trying to create a form structure for save information a two tables, but i am get a error. Can anyone help me I search in the odoo15 documentation but its don't help me too much. I think the error is not inside the menu item but in other lines code.

This is my model

from odoo import models, fields


class dga_doc(models.Model):
    _name = "dnre.dga_doc"
    _auto = False
    _description = "DNRE - Recursos Humanos"

    nc = fields.Integer(string="Nº contribuente", required=True)
    dc = fields.Char(string="Designação contribuente", required=True)
    ca = fields.Integer(string="CA")
    da = fields.Char(string="DA")
    mr = fields.Date(string="MR")
    tc = fields.Integer(string="TC")
    r = fields.Char(string="Regime")
    dga = fields.One2many('dnre.dga', 'dga_id', string="DGA Lines", readonly="True")

class dga(models.Model):
    _name = "dnre.dga"
    _description = "DGA Funcionarios"

    dga_id = fields.Many2one('dnre.dga_doc', string="dga", readonly="True")
    nums = fields.Integer(string="Nº segurado", required=True)
    ns = fields.Char(string="Nome segurado", required=True)
    cp = fields.Char(string="CP")
    pc = fields.Char(string="P/C")
    ndt = fields.Integer(string="Nº DT")
    sl = fields.Integer(string="SL")
    cs = fields.Char(string="CS")
    cf = fields.Integer(string="CF")
    cep = fields.Integer(string="CEP")

This is my view

<odoo>
  <data>
    <!-- Top menu item -->
    <menuitem name="DNRE" id="dnre.menu_root"/>

    <!-- menu categories -->
    <menuitem name="FOS" id="dnre.menu_1" parent="dnre.menu_root"/>

    <!-- actions -->
    <menuitem name="DGA" id="dnre.menu_1_list" parent="dnre.menu_1" action="dnre.action_dga"/>
    <menuitem name="DGCI" id="dnre.menu_2_list" parent="dnre.menu_1" action="dnre.action_dgci"/>

    <!-- actions opening views on models -->
    <record model="ir.actions.act_window" id="dnre.action_dga">
      <field name="name">Folha de Orçamento Salarial</field>
      <field name="res_model">dnre.dgci_doc</field>
      <field name="view_mode">tree, form</field>
    </record>

    <record model="ir.actions.act_window" id="dnre.action_dgci">
      <field name="name">Folha de Orçamento Salarial</field>
      <field name="res_model">dnre.dga_doc</field>
      <field name="view_mode">tree, form</field>
    </record>

    <!-- server action to the one above -->
    <record model="ir.actions.server" id="dnre.action_server">
      <field name="name">dnre server</field>
      <field name="model_id" ref="model_dnre_dga_doc"/>
      <field name="state">code</field>
      <field name="code">
        action = {
          "type": "ir.actions.act_window",
          "view_mode": "tree, form",
          "res_model": model._name,
        }
      </field>
    </record>

    <record model="ir.ui.view" id="dnre.list_dga">
      <field name="name">dnre dga list</field>
      <field name="model">dnre.dga_doc</field>
      <field name="arch" type="xml">
        <form>
          <group string="Informação do documento">
            <group colspan="4" col="6">
              <field name="nc"/>
              <field name="dc"/>
              <field name="ca"/>
              <field name="da"/>
              <field name="mr"/>
              <field name="tc"/>
              <field name="r"/>
            </group>
          </group>
          <notebook>
            <page string="Funcionários DGA">
              <field name="dga">
                <tree>
                  <field name="nums"/>
                  <field name="ns"/>
                  <field name="cp"/>
                  <field name="pc"/>
                  <field name="ndt"/>
                  <field name="sl"/>
                  <field name="cs"/>
                  <field name="cf"/>
                  <field name="cep"/>
                </tree>
              </field>
            </page>
          </notebook>
        </form>
      </field>
    </record>
  </data>
</odoo>

This is the error that i am having

Traceback (most recent call last):
  File "/home/ruben/Documents/MyLab/DNRE/odoo/odoo/http.py", line 694, in _handle_exception
    return super()._handle_exception(exception)
  File "/home/ruben/Documents/MyLab/DNRE/odoo/odoo/http.py", line 324, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /home/ruben/Documents/MyLab/DNRE/dnre-addons/dnre/views/dga.xml:10, somewhere inside
<menuitem name="DGA" id="dnre.menu_1_list" parent="dnre.menu_1" action="dnre.action_dga"/>
Ruben de Pina
  • 41
  • 1
  • 5

1 Answers1

0

1st: stop using dnre.xxxx prefix for define a record, you could use dnre_xxxx definition. When you define a record with dnre.xxxx Odoo with try to find the view xxxx for the dnre module and override it, this is how external ids works in Odoo. Don't mess with that or you will get more problems than now.

2nd: be aware where you define a view, Odoo respects your definitions from the top to the bottom. Op1: if you are working in one file you don't need externals ids, you sould define your view on top and use then on the bottom. Op2: working with more files, if you need to call some views defined in the file A from the file B you need to use externals ids, using this pattern module_name.view_id, in this case in __manfiest__ file you should define file A first an then file B.

If it is Op1. you could use this pattern of definitions:

  1. tree, form, kamban, search, pivots, graph view(the order don't matters).
  2. actions.
  3. Menus

I hope this answer can help you.

Juan Salcedo
  • 1,598
  • 1
  • 16
  • 28