Skip to Content
Menu
This question has been flagged
1 Reply
5552 Views

Hi All, I want to add new field in stock.move and this is my code

import time

from openerp.osv import fields, osv

class bac_stock_move(osv.osv):
    _inherit = 'stock.move'
    _name = 'bac.stock.move'
    _description = 'bac_stock_move'

    _columns = {
        'supplier_id' : fields.many2one('res.partner', 'Supplier', domain=[('supplier','=','1')]),
        'customer_id' : fields.many2one('res.partner', 'Customer', domain=[('customer','=','1')]),
    }
bac_stock_move()

<?xml version="1.0"?>
<openerp>
    <data>

    <record id="bac_stock_move_form" model="ir.ui.view">
    <field name="name">bac.stock.move.form</field>
    <field name="model">stock.move</field>
    <field name="inherit_id" ref="stock.view_move_form"/>
    <field name="arch" type="xml">

      <xpath expr="//group[@name='main_grp']/field[@name='name']" position="after">
        <field name="partner_id" attrs="{'visible':True}"/>
        <field name="supplier_id"/>
        <field name="supplier_id"/>
      </xpath>

    </field>
    </record>


    </data>
</openerp>

Does it possible to group field by menu, not by user group. I want to show Supplier Field in menu Incoming product and Customer field in menu Outgoing Product. and hide supplier field when the current menu is outgoing product and hide customer menu when the current menu is incoming product. this 2 menu use only 1 view.

Avatar
Discard
Best Answer
import time

from openerp.osv import fields, osv

class bac_stock_move(osv.osv):
    _inherit = 'stock.move'
    _name = 'bac.stock.move'
    _description = 'bac_stock_move'

    _columns = {
        'supplier': fields.boolean('Supplier'),
        'customer': fields.boolean('Customer'),
        'supplier_id' : fields.many2one('res.partner', 'Supplier', domain=[('supplier','=','1')]),
        'customer_id' : fields.many2one('res.partner', 'Customer', domain=[('customer','=','1')]),
    }
bac_stock_move()

And your xml file should be <openerp> <data>

    <record id="bac_stock_move_form" model="ir.ui.view">
    <field name="name">bac.stock.move.form</field>
    <field name="model">stock.move</field>
    <field name="inherit_id" ref="stock.view_move_form"/>
    <field name="arch" type="xml">

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

        <field name="supplier" invisible="1"/>
        <field name="customer" invisible="1"/>
        <field name="supplier_id" attrs="{ 'invisible':[('supplier', '!=', True)]}"/>
        <field name="customer_id" attrs="{ 'invisible':[('customer', '!=', True)]}"/>
      </xpath>

    </field>
    </record>
    <record id="action_bac_stock_supplier" model="ir.actions.act_window">
        <field name="name">Incoming Products</field>
        <field name="res_model">bac.stock.move</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('supplier', '=', True)]</field>
        <field name="context">{ 'default_supplier':True}</field>

    </record>
    <record id="action_bac_stock_customer" model="ir.actions.act_window">
        <field name="name">Outgoing Products</field>
        <field name="res_model">bac.stock.move</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('customer', '=', True)]</field>
        <field name="context">{ 'default_customer':True}</field>

    </record>


    </data>
</openerp>

and please add the respective Menu items for the above actions to make it display on your client.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 15
2461
0
Dec 24
59
1
Jun 22
3471
1
Feb 19
3722
2
May 15
3117