Skip to Content
Menu
This question has been flagged
4 Replies
5413 Views

Hello,

I add a new field into my form, the field is not visible.

<!-- My form view -->

<field name="res_model">stock.production.lot</field>

<field name="inherit_id" ref="stock.view_production_lot_form" />

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

      <xpath expr="//field[@name='product_id']" position="before"> <!-- or After -->

      <field name="newField"/>

  </xpath>

</field>


<!-- My manifest file -->

'depends': ['stock','product'],

<!-- My module class -->

class ProductionLot(models.Model):

    _inherit = '''stock.production.lot'''

    newField = fields.Char(string='New field ', required=False, store=False)   

<!-- Parent view "stock.view_production_lot_form" -->
<form>

 <sheet>

  <group>

   </group>

        <field name="product_id"/>

  </group>

</group>

</sheet>

</form>

Help please.


Avatar
Discard
Author Best Answer

Hello,

i always added it:

'data': [

        # 'security/ir.model.access.csv',

        'views/stock_production_lot_views.xml',


    ],


If i used model="ir.ui.view" NOt working, so i have to use model="ir.actions.act_window".
And "res_model" for ir.actions.act_window.

Update my answer

<?xml version="1.0" encoding="utf-8"?>

<odoo>

  <record model="ir.actions.act_window" id="production_lot_form_view"> <!-- ir.ui.view and name="model" with error definition view odoo12 -->

    <field name="name">production.lot.form.view</field>

    <field name="res_model">stock.production.lot</field>

    <field name="mode">primary</field>

    <field name="inherit_id" ref="stock.view_production_lot_form" />

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

<xpath expr="//field[@name='ref'] position="after">

<field name="children_ids">

          <tree>

            <field name="name" />

            <field name="qty" />

          </tree>

        </field>

</xpath>

----------------------- or --------------------------------

      <field name="ref" position="after">

        <field name="children_ids">

          <tree>

            <field name="name" />

            <field name="qty" />

          </tree>

        </field>

       </field>

    </field>

  </record>

</odoo>


Still not working !


The good is  :  <xpath expr="/form/sheet/group" position="after">

Avatar
Discard
Author

raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs))

odoo.tools.convert.ParseError: "Invalid view view_production_lot_form_ath definition in stock_serial/views/stock_production_lot_views.xml

None" while parsing /odoo/odoo12/addons/stock_serial/views/stock_production_lot_views.xml:3, near

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

add the tag <odoo> into your file. i have update my answer, see that.

Best Answer

hello,

in your __manifest__.py file,  add your xml file.

like 'data': ['your_file.xml'], 

<odoo>
<record id="your_unique_xml_id" model="ir.ui.view">
<field name="name">stock.prodution.lot.form</field>
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_form" />
<field name="arch" type="xml">
      <xpath expr="//field[@name='product_id']" position="before"> <!-- or After -->
      <field name="newField"/>
  </xpath>
</field>
</record>
</odoo>
Avatar
Discard
Related Posts Replies Views Activity
2
Jun 21
3833
0
Dec 23
45
2
Dec 23
11994
0
Oct 23
33
3
Oct 23
787