Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to show the customer payment Total in fields in OpenERP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 229
    Comment on it

    In OpenERP first, create a custom module and then inherits the account.payment object in your own module like module name test.

    Follow these steps given below

    Step1- First create the __init__.py file in your test module and use this code given below,

    import test

     

    Step2- Then create another file like:  __openerp__.py file in your test module and use this code shown in below

    {
        "name": "Test",
        "version": "1.0",
        "author": "sachin singh",
        "description" : "this module basically for show all amount when customer payment is full then all amount show in your fields",
        "depends": ["base","account"],
        "category" : "Generic Modules/Others",
        "init_xml": [],
        "update_xml": ["test.xml"],
        "active": False,
        "installable": True,
     }

     

    Step3- Now create another file like: test.py file in your test module and then create a nnew field in this file, use this code shown below,

    from openerp.osv import osv, fields
    class test(osv.Model):
        _name = 'test'
        invoice_total_paid1 = fields.Text(string='Total payment', required=True)
       
    test()
    
    class account_payment(osv.Model):
        _inherit = 'account.payment'
        
        @api.multi
        def post(self):
            super(account_payment,self).post()
            for inv in self.invoice_ids:
                inv_origin = inv.origin
                
            payment_ids = self.search([])
            pay_rec_list = []
            for pay in payment_ids:
                for inv in pay.invoice_ids:
                    if inv_origin == inv.origin:
                        pay_rec_list.append(pay.id)
            
            cur_payment_ids = self.search([('id','in',pay_rec_list)])
            total = 0
            for p in cur_payment_ids:
                total += p.amount
            rent_rec_id = self.pool.get('rent.order').search(self.env.cr,self.env.uid,[('reference','=',inv_origin)])
            self.pool.get('rent.order').write(self.env.cr,self.env.uid,rent_rec_id,{'invoice_total_paid1':total})
    

     

    Step4- Last step is to create the test.xml file in your own module and use this code shown below

    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
     <!--  Here is a rent order tree view -->   
          <record model="ir.ui.view" id="rent_order_tree_view">
                <field name="name">test.order.tree.view</field>
                <field name="model">test</field>
                <field name="type">tree</field>
                <field name="arch" type="xml">
                    <tree string="test Orders">
                        <field name="invoice_total_paid1"/>
                    </tree>
                </field>
            </record>
     <record model="ir.ui.view" id="rent_order_form_view">
                <field name="name">test.order.form.view</field>
                <field name="model">test</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="test Order">
                        <group colspan="4" col="6">
                           <group>
                            <field name="invoice_total_paid1"/>
                            </group>
                        </group>
                    </form>
               </field>
       </record>
    
    
     <record model="ir.actions.act_window" id="rent_action_form">
                <field name="name">test Order</field>
                <field name="res_model">test</field>
                <field name="view_type">form</field>
                <field name="view_mode">tree,form,calendar</field>
                <field name="usage">menu</field>
                <field name="search_view_id" ref="rent_order_search_view"/>
            </record>
            <menuitem id="rent_order_menu" parent="base.menu_sales" groups="base.group_sale_salesman"
                      name="Tests" action="rent_action_form"/>
    
    </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: