Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to merge partner in OpenERP-6.1?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 601
    Comment on it

    In OpenERP first, install the sale and account module and then create the own module.

    Follow these step given below:

    Step1- Create your own module and then create merge_partner file and then pass this file in __init__.py file in your own module. Then create the function and pass this function in button.

    Use this function given below:

    import time
    from lxml import etree
    import decimal_precision as dp
    from tools.translate import _
    import netsvc
    import pooler
    from osv import fields, osv, orm
    import datetime
    from datetime import datetime
    from datetime import date, timedelta
    import types
    
    
    class merge_partner(osv.osv):
        _name = 'merge.partner'    
        _columns ={
                    'name1':fields.many2one('res.partner','Partner to Merge'),
                    'name2':fields.many2one('res.partner','Partner on Merge'),              
                    
                }
    
        def merge_on_partner(self, cr, uid, ids, context=None):
            res = {}
            for partners in self.browse(cr,uid,ids,context=None):
                print "===partners====",partners
                if partners:
                    pid1 = partners.name1.id
                    pid2 = partners.name2.id
                    cr.execute('update sale_order set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update sale_order_line set order_partner_id = %s where order_partner_id = %s',(pid2,pid1))
                    cr.execute('update account_invoice set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update account_invoice_line set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update account_move set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update account_move_line set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update account_voucher set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update crm_claim set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update stock_move set partner_id = %s where partner_id = %s',(pid2,pid1))
                    cr.execute('update stock_picking set partner_id = %s where partner_id = %s',(pid2,pid1))
          
            return res
    
    merge_partner()
     

     

    Step2- Then create merge_partner.xml file in your own module and pass this file in __openerp__.py file.

    Use this code given below:

    <?xml version="1.0" ?>
    <openerp>
        <data>
            
            <record id="view_merge_partner_form" model="ir.ui.view">
                <field name="name">merge.partner.form</field>
                <field name="model">merge.partner</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="Merge Partner Entries" >
    					<field name="name1"/>
    					<field name="name2"/>
    					<separator colspan="4" string="Actions" col="2"/>
                        <button name="merge_on_partner" string="Merge Partner" icon="gtk-execute" type="object"/>
    					<button name="delete_partner" string="Delete" icon="gtk-execute" type="object"/>
    									
                    </form>
                </field>
            </record>
    		
    		<record model="ir.actions.act_window" id="action_merge_partner_form">
    			<field name="name">Merge Partners</field>
    			<field name="res_model">merge.partner</field>
    		</record>
    		 
    <menuitem name="Merge Partners" id="menu_merge_partner"/>
    <menuitem name="Merge Partner" id="menu_merge" parent="merge_partner.menu_merge_partner" action="action_merge_partner_form" sequence="1"/>
    	</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: