コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
11934 ビュー

I'm having a problem with many2many fields. Creating a dhl label with relation to stock_picking_out is no problem. Everything works. But when I go to delivery orders the "dhl_label" field shows me an empty list. Here the code:

class dhl_label(osv.osv):
    _name = 'dhl.label'

    _columns = {
        'stock_picking_out': fields.many2many('stock.picking.out', 'dhl_label_stock_picking_out_rel', 'dhl_label_id', 'stock_picking_out_id'),

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

    _columns = {
        'dhl_label': fields.many2many('dhl.label', 'dhl_label_stock_picking_out_rel', 'stock_picking_out_id', 'dhl_label_id'),

<record id="view_dhl_label_form" model="ir.ui.view">
            <field name="name">dhl.label.form</field>
            <field name="model">dhl.label</field>
            <field name="arch" type="xml">
                <form string="DHL Label" version="7.0">
                    <sheet>
                        <group>
                            <group>
                                <field name="stock_picking_out" widget="many2many_tags"/>
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

<record id="nfx_dhl_view_picking_out_form" model="ir.ui.view">
            <field name="name">nfx.dhl.stock.picking.out.form</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <data>

                    <notebook position="inside">
                        <page string="DHL Label">
                            <field name="dhl_label" select="1"/>
                        </page>
                    </notebook>

                </data>
            </field>
        </record>
アバター
破棄
著作者 最善の回答

I got the answer from the openerp support. Because stock_picking_out is not physical we must do it this way:

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

Then everythin works...

アバター
破棄
最善の回答

Hi Stefan The working copy is below,, just copy and see if it works for let me know if you need any help it will create a menu like dev under that you add same dhl label and in warehouse delivery orders it is accessible while creating and editing .

Thanks

Py File

import logging
from osv import fields,osv
_logger = logging.getLogger(__name__)

class dhl_label(osv.osv):
    _name = 'dhl.label'

    _columns = {
        'name': fields.char('dhl Label', size=32),
        'stock_picking_out': fields.many2many('stock.picking.out', 'dhl_label_stock_picking_out_rel', 'dhl_label_id',
                                              'stock_picking_out_id','Stocking Picking Out'),

    }

#dev_person()

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

    _columns = {
        'dhl_label': fields.many2many('dhl.label', 'dhl_label_stock_picking_out_rel', 'stock_picking_out_id',
                                      'dhl_label_id','SPO Dhl Label'),

    }

View File

<?xml version="1.0"?>
<openerp>
<data>
    <record id="view_dhl_label_form" model="ir.ui.view">
            <field name="name">dhl.label.form</field>
            <field name="model">dhl.label</field>
            <field name="arch" type="xml">
                <field name="name"/>
                <form string="DHL Label" version="7.0">
                    <sheet>
                        <group>
                            <group>
                                <field name="stock_picking_out" widget="many2many_tags"/>
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

    <record model="ir.ui.view" id="view_person_tree">
        <field name="name">dhl.label.tree</field>
        <field name="model">dhl.label</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="dev.person">
                <field name="name"/>
                <field name="stock_picking_out"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_dhl_label">
        <field name="name">dhl.label</field>
        <field name="res_model">dhl.label</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>


<!--<menuitem id="menu_item_abi_notes" parent="menu_section_ramport" name="Abi Results" action="action_abi_results" />-->
<menuitem id="dev_menu" name="dev" />
 <menuitem id="menu_section_test" parent="dev_menu" name="Test" />
<menuitem id="menu_person" parent="menu_section_test" name="DHL Label" action="action_dhl_label" />
<!--<menuitem id="menu_prop" parent="dev_menu" name="prop" action="action_property" />-->

    <record id="nfx_dhl_view_picking_out_form" model="ir.ui.view">
            <field name="name">nfx.dhl.stock.picking.out.form</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <data>

                    <notebook position="inside">
                        <page string="DHL Label">
                            <field name="dhl_label" select="1"/>
                            <field name="origin" select="1"/>
                        </page>
                    </notebook>

                </data>
            </field>
        </record>

    <record model="ir.ui.view" id="view_property_tree">
        <field name="name">stock.picking.out</field>
        <field name="model">stock.picking.out</field>
        <field name="inherit_id" ref="stock.view_picking_out_tree"/>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <field name="name" position="after">
                <field name="dhl_label"/>
            </field>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_stock_picking_out_1">
        <field name="name">stock.picking.out</field>
        <field name="res_model">stock.picking.out</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
<menuitem id="menu_prop" parent="menu_section_test" name="Stock picking out" action="action_stock_picking_out_1" />

</data>

</openerp>
アバター
破棄
著作者

i'm sorry but nothing have changed. when i go to the delivery order i cannot see the dhl label. the many2many list is empty.

have to created any dhl label

著作者

yes, of course i have created one, but it doesn't appears in delivery orders.

著作者

I got it. Thank you for your help!

Hi stefan ! can you give me a example of load/save my own config

http://help.openerp.com/question/30123/how-can-i-saveload-my-own-configurationsettings/

This one is not working

please please give one live example

著作者

hi Soohoo, i decided to use the system parameters from openerp to save all my configurations. you need to activate the technical view for your user and then you can go to settings -> parameters -> system parameters. there i added new values like my_module.my_setting_key. you will get this value with self.pool.get('ir.config_parameter').get_param(cr, uid, 'my_module.my_setting_key'). don't forget to eval the values, they are always saved as string...

can't we do it from code ??

著作者

I'm not doing this by code, but i think you can write to the ir.config_parameter model: self.pool.get('ir.config_parameter').create(cr, uid, {'key': 'your_key', 'value': 'your_value'})...

but i wanted to know how the other module like account and stock using it

著作者

i'm sorry but i don't understand. as i wrote you can read the values with self.pool.get('ir.config_parameter').get_param(cr, uid, 'my_setting_key'). that's the way i'm saving/loading my configuration at the moment...

so from the front end how can we create a form so that it can be changed , for multiple values

著作者

i don't know...

関連投稿 返信 ビュー 活動
1
1月 23
1941
2
12月 23
24114
2
6月 17
6463
3
6月 18
15091
0
10月 16
2856