Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to transfer bill from one customer to another customer in OpenERP-6.1?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 521
    Comment on it

    In OpenERP first, install the sale and account module so that users can transfer one bill to another bill.

    Follow these step given below:

    Step1- First create own module and then create file like as merge.py file and pass this file in your __init__.py file in your own module.

    Then create function in your own module and pass this function in button.

    Use this code given below

    class transfer_bill(osv.osv):
        _name = 'transfer.bill'    
        _columns ={
                    'partner_id':fields.many2one('res.partner','New Partner'),
                    'number':fields.char('Order Number',size=10),              
                    
                }
    
        def merge_bill_entries(self, cr, uid, ids, context=None):
            res = {}        
            for partners in self.browse(cr,uid,ids,context=context):
                print"====partners===",partners
                if partners:
                    pid = partners.partner_id.id
                    number = partners.number
    ##                raise orm.except_orm(_(''), (str(pid1)))
                    cr.execute('update sale_order set partner_id = %s where name = %s',(pid,number))                
                    cr.execute('update account_invoice set partner_id = %s where origin = %s RETURNING serial_number',(pid,number))
                    snumber = cr.fetchone()
                    cr.execute('update account_invoice_line set partner_id = %s where origin = %s',(pid,number))
                    cr.execute('update account_move set partner_id = %s where ref = %s RETURNING id',(pid,number))
                    move_id = cr.fetchone()
                    cr.execute('update account_move_line set partner_id = %s where ref = %s',(pid,number))
                    cr.execute('update account_voucher set partner_id = %s where move_id = %s',(pid,move_id))                
                    cr.execute('update stock_move set partner_id = %s where origin = %s',(pid,number))
                    cr.execute('update stock_picking set partner_id = %s where origin = %s',(pid,number))                
                    cr.execute('update account_voucher set partner_id = %s where name = %s RETURNING move_id',(pid,snumber))
                    move_id2 = cr.fetchone()
                    cr.execute('update account_move set partner_id = %s where id = %s',(pid,move_id2))
                    cr.execute('update account_move_line set partner_id = %s where move_id = %s',(pid,move_id2))
            return res
    transfer_bill()
    

     

    Step2- Then after creating the XML file like: merge.xml file and pass this file in __openerp__.py file in your own module.

    Use this code given below:

    <?xml version="1.0" ?>
    <openerp>
        <data>
    <record id="view_transfer_bill_form" model="ir.ui.view">
                <field name="name">transfer.bill.form</field>
                <field name="model">transfer.bill</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="Transfer Bill Entries" >
    					<field name="partner_id"/>
    					<field name="number"/>
    					<separator colspan="4" string="Actions" col="2"/>
                        <button name="merge_bill_entries" string="Transfer" icon="gtk-execute" type="object"/>	
                    </form>
                </field>
            </record>
    		
    		<record model="ir.actions.act_window" id="action_transfer_bill_form">
    			<field name="name">Transfer Bill Entries</field>
    			<field name="res_model">transfer.bill</field>
    		</record>
    <menuitem name="Merge Partners" id="menu_merge_partner"/>
    <menuitem name="Transfer Bill" id="menu_transfer_bill" parent="merge_partner.menu_merge_partner" action="action_transfer_bill_form" sequence="2"/>
    </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: