This question has been flagged
2 Replies
3704 Views

I want to add a new selection option above the supplier in the stock_picking_in form. It shows up and can be selected but it is not writing to the database, what am i doing wrong?

My Python:

class stock_picking_in(osv.osv):
    _inherit = "stock.picking.in"
    _table = "stock_picking"

    _columns = {
        'prod_type': fields.selection([('itemized','Itemized Product'),('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help="Itemized: Every unit of this product is assigned a unique item number and can have unique attributes. \nConsumable: Will not imply stock management for this product. \nStockable product: Will imply stock management for this product."),        
    }

    _defaults = {
        'prod_type': 'itemized',
    }
stock_picking_in()

My XML:

<record id="view_picking_in_form_items" model="ir.ui.view">
        <field name="name">stock.picking.in.form</field>
        <field name="model">stock.picking.in</field>
        <field name="inherit_id" ref="stock.view_picking_in_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='partner_id']" position="replace">
                    <field name="prod_type" string="Inventory Type"/>
                <field name="partner_id" on_change="onchange_partner_in(partner_id)" string="Supplier" domain="[('supplier','=',True)]" />
            </xpath>
                <xpath expr="//field[@name='move_lines']" position="replace">
                <field name="move_lines" attrs="{'invisible': [('prod_type','=','itemized')]}" context="{'address_in_id': partner_id, 'picking_type': 'in', 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}" options='{"reload_on_button": true}'/>
                    <field name="move_lines" string="Itemized" attrs="{'invisible': [('prod_type','&lt;&gt;','itemized')]}" context="{'address_in_id': partner_id, 'picking_type': 'in', 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}" options='{"reload_on_button": true}'/>
            </xpath>
        </field>
    </record>
Avatar
Discard

Does the new field exist in table stock_picking? Are there any error messages?

Author Best Answer

The answer was I needed to create the field in both stock.picking and stock.picking.in.

class stock_picking(osv.osv):
    _inherit = "stock.picking"

    _columns = {
        'prod_type': fields.selection([('itemized','Itemized Product'),('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help=""),        
    }

stock_picking()

class stock_picking_in(osv.osv):
    _inherit = "stock.picking.in"

    _columns = {
        'prod_type': fields.selection([('itemized','Itemized Product'),('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help=""),        
    }

    _defaults = {
        'prod_type': 'itemized',
    }
stock_picking_in()
Avatar
Discard
Best Answer

Hello ,

make you sure that you didn't change the write function of the stock.picking.in class . Try to use store="True" in your field definition.

Avatar
Discard