Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
6286 Prikazi

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
Opusti
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
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
mar. 15
3646
0
feb. 25
1337
0
jan. 25
1151
1
dec. 24
1498
1
jun. 22
5640