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

I have two custom field defined in two classes. one class is inherit from 'sale.order' another class can inherit from 'sale.order.line'. so while selecting value from dropdown list filed of first class, then it can be set to filed of second class. How it's possible

this is code

.py file

from openerp.osv import osv
from openerp.osv import fields


class ship_so(osv.osv):

    _inherit = 'sale.order'

    _columns = {

        'ship_id': fields.many2one('ship.info', 'Ship Field '),
        'hull_no': fields.char('Hull Number',size=25),
        'engn_no': fields.char('Engine Number',size=25),
    }

    def onchange_ship_id(self, cr, uid, ids, ship_id, context=None):

        if ship_id:
            ship = self.pool.get('ship.info').browse(cr, uid, ship_id, context=context)
            return {'value': {'hull_no': ship.hullno, 'engn_no': ship.enginno}}
        return {}

 

class ship_line(osv.osv):

    _inherit = 'sale.order.line'

    _columns = {

        'ship_no': fields.text('Ship Field'),

    }

 

.xml file

 

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>

       <record model="ir.ui.view" id="view_order_tree_inherit">
            <field name="name">sale.order.tree</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_tree"/>
            <field name="arch" type="xml">
                <field name="partner_id" position="after">
                    <field name="ship_id"/>
                </field>
            </field>
       </record>

       <record model="ir.ui.view" id="view_order_form_inherit">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <xpath expr="//form/sheet/group/group/field[@name='partner_id']" position="after">
                    <field name="ship_id" on_change="onchange_ship_id(ship_id)"/>
                    <field name="hull_no"/>
                    <field name="engn_no"/>
                </xpath>
                <xpath expr="//sheet/group" position="inside">
                </xpath>
                <xpath expr="//tree/field[@name='product_uom_qty']" position="after">
                        <field name="ship_no"/>
                </xpath>
            </field>
       </record>

    </data>
</openerp>

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
3
feb. 25
3591
0
maj 24
46
1
apr. 24
3372
4
sep. 23
4868
2
sep. 23
7099