Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
11945 Lượt xem

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>
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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...

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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>
Ảnh đại diện
Huỷ bỏ
Tác giả

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

Tác giả

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

Tác giả

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

Tác giả

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 ??

Tác giả

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

Tác giả

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

Tác giả

i don't know...

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 23
1958
2
thg 12 23
24134
2
thg 6 17
6494
3
thg 6 18
15106
0
thg 10 16
2869