تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
7 الردود
19168 أدوات العرض

hello I found a problem with the stock module I want to add some fields the data are stored in the database but not displayed in the view!!!


__init__.py

import test

openerp.py

{
    "name" : "Test",
    "version" : "1.0",
    "category" : "",
    'complexity' : "normal",
    "author" : "xxxxxx",
    "website" : "www.you.com",
    "depends" : ["stock"],
    "summary" : "Test",
     "description" : """ Test """,
    "data" : ['test_view.xml'],
    "application": False,
    "installable": True
}

test.py

from openerp.osv import fields, osv

class stock_picking_out(osv.osv):
    _inherit = 'stock.picking.out'
    _columns = {
             'test': fields.char('Test Field', size=8, select=True, states={'done': [('readonly', True)]}, domain=[('type', '=', 'out')]),
}

test_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_picking_out_form_test" model="ir.ui.view">
            <field name="name">stock.picking.out.form.test</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_form" />
            <field name="arch" type="xml">
            <field name="partner_id" position="after">
              <field name="test" placeholder="e.g. [0-9][a-zA-Z]" />
            </field>
            </field>
        </record>
    </data>
</openerp>
الصورة الرمزية
إهمال

Finally I now to fix this. This is OpenERP bug (ref: lp996816). You must add the new field in two model by inheriting stock.picking & stock.picking.out. See in sale_stock module > stock.py (on last line) there is FIXME comment. Add that new field in new inherit stock.view_picking_out_form with model stock.picking.out. Thx all...

أفضل إجابة

I have same problem. My friend try deleting all .pyc file from folder addons and it success to display field value (before did not show). But I tried again in my module, it didn't work. I think there is a problem in .py file or osv file.

الصورة الرمزية
إهمال
أفضل إجابة

 

need to create the field in both "stock_picking_out" and "stock_picking"

 

Hi rachid,

You Can try this.....

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_picking_out_form_test" model="ir.ui.view">
            <field name="name">stock.picking.out.form.test</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">

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

                      <field name="test" placeholder="e.g. [0-9][a-zA-Z]"/>

              </xpath>

           </field>

</record>

</data>

</openerp>

الصورة الرمزية
إهمال

I' ve tried your code. But still do not display the value. If I save, the value insert into database but do not show in view (I can see label but not the value). In my tree view, it also do not show up.

Problem is you Have created field only in "stock.picking.out" u cannot save data in that, so need to create field in "stock.picking" also.... try this and it defnetly works

أفضل إجابة

Hi;

I think you should add field name="priority" eval="12" to your form according to this.

Maybe, you will have to change the eval value from 12 to another value.

Go under Settings ---> Technical ----> User Interface , open Views and filter by Stock, to see all views related to stock. There you can see the priority of the views.

Another question: did you checked if the field ' test' is created in the table stock_picking

Last, i think your class should inherit from stock.picking and not stock.picking.out

stock.view_picking_form

Try as follow to see if it works:

Don't use the xpath:

      field name="partner_id" position="after"

      field name="test" placeholder="e.g. [0-9][a-zA-Z]"

In your view you are using the object (Model) stock.picking.out, so i think you must inherit from stock.view_picking_out_form:

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

Try with and without xpath.

Also, if you are using V7.0, Remove

       <field name="type">form</field>

from your form view.

I've tested on my side and it's working (without xpath).

put this in your __init__.py file: import test (in my case i've named the py file as test.py), and in your __openerp__.py file put

"data" : ['test_view.xml'], Of course! don't forget "depends" : ["stock"], as stated by le_dilem

test-rachid

Give it a try, and keep us informed.

Good luck.

Here after the files i used:

__init__.py

import test

__openerp__.py

{
"name" : "Test", "version" : "1.0", "category" : "", 'complexity' : "normal", "author" : "xxxxxx", "website" : "www.you.com", "depends" : ["stock"], "summary" : "Test", "description" : """ Test """,

"data" : ['test_view.xml'],
"application": False,
"installable": True

}

test.py

from openerp.osv import fields, osv

 class stock_picking_out(osv.osv):

          _inherit = 'stock.picking.out'

          _columns = {
                   'test': fields.char('Test Field', size=8, select=True, states={'done': [('readonly', True)]}, domain=[('type', '=', 'out')]),
}

test_view.xml

     <?xml version="1.0" encoding="utf-8"?>
              <openerp>
                    <data>
                       <record id="view_picking_out_form_test" model="ir.ui.view">
                            <field name="name">stock.picking.out.form.test</field>
                            <field name="model">stock.picking.out</field>
                            <field name="inherit_id" ref="stock.view_picking_out_form" />
                            <field name="arch" type="xml">
                               <field name="partner_id" position="after">
                                 <field name="test" placeholder="e.g. [0-9][a-zA-Z]" />
                               </field>
                            </field>
                        </record>
                    </data>
              </openerp>
الصورة الرمزية
إهمال
الكاتب

no change, same problem , I tryed eval="10" and eval="15" too with no changes :(

What's the content of your openerp-server.log. Do you get any error message during the install process of the module? Did you restarted the server ?

الكاتب

yes I restarted the server with test modul as update there's no errors in log

الكاتب

the priority of pickin_out is 16 I tryed 15 & 17 with no result the values is stored in the database but not displayd

Is it stored in the stock_picking table?

الكاتب

yes, when I save the view the data is stored in the table stock_picking

الكاتب

I test that before & it doesnt work :'(

الكاتب

I copied all your code, & the problem doesn't resolved :s

الكاتب

med said did the value apear in the field ?

Yes, the value appears in the field. Rachid, if you still encounter a problem there is probably some details in your openerp-server.log or in your postgres.log !

أفضل إجابة

I tested the code. like this

do not forget in your file __ openerp__.py add the 'depends' : ['stock'],

 from openerp.osv import fields, osv

    class stock_picking_out(osv.Model):
        _inherit = 'stock.picking.out'

        _columns = {
            'test': fields.char('Test Field', size=8, select=True, states={'done': [('readonly', True)]}, domain=[('type', '=', 'out')]),
        }

    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
      <data>
            <record id="view_picking_out_form_test" model="ir.ui.view">
            <field name="name">stock.picking.out.form.test</field>
            <field name="type">form</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">
                <field name="partner_id" position="after">
                    <field name="test" placeholder="e.g. [0-9][a-zA-Z]"/>
                </field>
            </field>
            </record>
      </data>
    </openerp>
الصورة الرمزية
إهمال
الكاتب

same result, the field doesn't display the value :s

I think that ( view name: stock.picking.out.form) stock.view_picking_out_form (external ID) inherit from (view name name: stock.picking.form) stock.view_picking_form (external ID).

الكاتب

they're no deference. I want just the values to be displayed

أفضل إجابة

Hi,

Refer sale_stock module - stock.py line 147 - 152 - stock_view.xml line no 52 -61

Thanks

الصورة الرمزية
إهمال
الكاتب

I didn't understand what do you mean ?

check module name sale_stock(see file stock.py line no 147 to 152 and in stock_view.xml line no 52 to 61) from addons. there is field added in stock.picking object

الكاتب

same as the code I used no deference, the view doesn't display the data

أفضل إجابة

put also your 'test': fields.char('Test Field', size=8, select=True, states={'done': [('readonly', True)]}, domain=[('type', '=', 'out')]), in stcok.picking inherited class.

الصورة الرمزية
إهمال
أفضل إجابة

I have same problem. My friend try deleting all .pyc file from folder addons and it success to display field value (before did not show). But I tried again in my module, it didn't work. I think there is a problem in .py file or osv file.

الصورة الرمزية
إهمال