Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to call product form to using of button in purchase module in OpenERP(Odoo-8)?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 869
    Comment on it

    In OpenERP first, create your custom module and inherits the purchase module object like purchase.order object in your own module. Than add button in the purchase form.

    Follow these step given below

    Step1- First create module and than file like test.py file in your own module and pass this file in the __init__.py file.

    Use this code given below

    class set_product(osv.TransientModel):
        _name = "set.product"
        _description = "Set Selection"
        _columns = {
             'line_set': fields.one2many('prod.set', 'set_one', 'Sets Lines'),
             'sequences': fields.char('Sequence')
            }
    
        def add_items(self, cr, uid, ids, context=None):
            active_id = context.get('active_id', [])
            purchase_obj = self.pool.get('purchase.order')
            purchase_line = self.pool.get('purchase.order.line')
            set = self.browse(cr, uid,ids,context=context)
            order_id = purchase_obj.browse(cr, uid, active_id, context=context)
            set_line = set.line_set
            order_liness = []
            for line in set_line:
                line_vals = purchase_line.onchange_product_id(cr, uid, ids, order_id.pricelist_id.id, line.product_id.id,1,1, partner_id = order_id.partner_id.id)['value']
                line_vals.update({'product_id' : line.product_id.id,'name' : line.product_id.name, 'order_id':order_id.id})          
                ress = purchase_line.create(cr, uid, line_vals, context=context)
                order_liness.append(ress)
                line.write({'purchase_line': [(4, ress)]})
            return True      
    class prod_set(osv.TransientModel):
        _name = "prod.set"
        _description = "Set"
        _columns = {
            'product_id' : fields.many2one('product.product', string='Product'),
            'set_one' : fields.many2one('set.product', string='Journal Entry')
    
            }

     

    Step2- After this, create another file like test.xml file and pass this file in other file like __openerp__.py file. And create view using xml file.

    Using this code given below

    </openerp>
       </data>
          <record id="view_set_product" model="ir.ui.view">
                <field name="name">product_set</field>
                <field name="model">set.product</field>
                <field name="arch" type="xml">
                    <form>
                        <group>
                            <field name="sequences"/>
                        </group>
                        <field name="line_set">
                            <tree string="Set lines" editable="bottom"> 
                                <field name="product_id"/> 
                            </tree>
                        </field>
                        <footer>
                            <button string="Add purchase Item" name="add_items" type="object" class="oe_highlight"/>
                            or
                            <button string="Cancel" class="oe_link" special="cancel"/>
                        </footer>
                    </form>
                </field>
            </record>
            <record id="action_set_product" model="ir.actions.act_window">
                <field name="name">Set</field>
                <field name="type">ir.actions.act_window</field>
                <field name="res_model">set.product</field>
                <field name="view_type">form</field>
                <field name="view_mode">form</field>
                <field name="target">new</field>
            </record>
        </data>
    </openerp>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: