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
    • 638
    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,

    1. import test

     

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

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

     

    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,

    1. from openerp.osv import osv, fields
    2. class test(osv.Model):
    3. _name = 'test'
    4. invoice_total_paid1 = fields.Text(string='Total payment', required=True)
    5. test()
    6.  
    7. class account_payment(osv.Model):
    8. _inherit = 'account.payment'
    9. @api.multi
    10. def post(self):
    11. super(account_payment,self).post()
    12. for inv in self.invoice_ids:
    13. inv_origin = inv.origin
    14. payment_ids = self.search([])
    15. pay_rec_list = []
    16. for pay in payment_ids:
    17. for inv in pay.invoice_ids:
    18. if inv_origin == inv.origin:
    19. pay_rec_list.append(pay.id)
    20. cur_payment_ids = self.search([('id','in',pay_rec_list)])
    21. total = 0
    22. for p in cur_payment_ids:
    23. total += p.amount
    24. rent_rec_id = self.pool.get('rent.order').search(self.env.cr,self.env.uid,[('reference','=',inv_origin)])
    25. self.pool.get('rent.order').write(self.env.cr,self.env.uid,rent_rec_id,{'invoice_total_paid1':total})
    26.  

     

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

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <openerp>
    3. <data>
    4. <!-- Here is a rent order tree view -->
    5. <record model="ir.ui.view" id="rent_order_tree_view">
    6. <field name="name">test.order.tree.view</field>
    7. <field name="model">test</field>
    8. <field name="type">tree</field>
    9. <field name="arch" type="xml">
    10. <tree string="test Orders">
    11. <field name="invoice_total_paid1"/>
    12. </tree>
    13. </field>
    14. </record>
    15. <record model="ir.ui.view" id="rent_order_form_view">
    16. <field name="name">test.order.form.view</field>
    17. <field name="model">test</field>
    18. <field name="type">form</field>
    19. <field name="arch" type="xml">
    20. <form string="test Order">
    21. <group colspan="4" col="6">
    22. <group>
    23. <field name="invoice_total_paid1"/>
    24. </group>
    25. </group>
    26. </form>
    27. </field>
    28. </record>
    29.  
    30.  
    31. <record model="ir.actions.act_window" id="rent_action_form">
    32. <field name="name">test Order</field>
    33. <field name="res_model">test</field>
    34. <field name="view_type">form</field>
    35. <field name="view_mode">tree,form,calendar</field>
    36. <field name="usage">menu</field>
    37. <field name="search_view_id" ref="rent_order_search_view"/>
    38. </record>
    39. <menuitem id="rent_order_menu" parent="base.menu_sales" groups="base.group_sale_salesman"
    40. name="Tests" action="rent_action_form"/>
    41.  
    42. </data>
    43. </openerp>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: