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
    • 827
    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 file in your own module and pass this file in the 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,,,1,1, partner_id =['value']
                line_vals.update({'product_id' :,'name' :, 'order_id'})          
                ress = purchase_line.create(cr, uid, line_vals, context=context)
                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 file. And create view using xml file.

    Using this code given below

          <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">
                            <field name="sequences"/>
                        <field name="line_set">
                            <tree string="Set lines" editable="bottom"> 
                                <field name="product_id"/> 
                            <button string="Add purchase Item" name="add_items" type="object" class="oe_highlight"/>
                            <button string="Cancel" class="oe_link" special="cancel"/>
            <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>

 0 Comment(s)

Sign In

Sign up using

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: