Skip to Content
Menu
This question has been flagged
2 Replies
18687 Views

class hr_extra(osv.osv):
       

      _inherit = "res.partner"
      _columns = {
              
                  'date_join': fields.date('Date of Joining'),
                  'service_date': fields.date('Service Benefit Payment Date'),
                  'order_line': fields.one2many('hr.payment.line','order_id','Payment Structure'),
                  'amount_total': fields.function(_amount,string='Total', multi="sums",help="The total amount"),
      }

class payment_description(osv.osv):

      _name = 'payment.description'
      _description = 'payment Description'
      _columns = {
                  'name': fields.char('Description'),
                        
      }


class hr_payment_description_line(osv.osv):
    

    _name ='hr.payment.description.line'
    _columns = {
        'description' :fields.many2one('payment.description','Description'),
        'amount':fields.float('Amount'),
        'order_id':fields.many2one('rea.partner','Payment Details'),  
       }

I have a description & amount field in my one2many relation.

I want to sum all the values, that given in the tree structure.

Where should i call the sum ans dispaly function?

What is the code?

 

Please help me....

Thanks.

Avatar
Discard
Best Answer

Hi.

function should be in 'res.partner'. Use this function.

One2many seems linked with 'hr.payment.line'. But there seems no object decalred with 'hr.payment.line'.

    def _amount_total(self, cr, uid, ids, field_name, arg, context=None):
        res = {}
        for partner in self.browse(cr, uid, ids, context=context):
            total = 0.0
            for line in partner.order_line:
                total += line.amount
            res[partner.id] = total
        return res

'amount_total': fields.function(_amount_total, type='float', string='Total'),

Avatar
Discard
Best Answer

In xml file tree view add sum attributes. It calculates sum all the amount values in list view

    <field name="amount" sum="Total"/>

 

 

Avatar
Discard

is there a way to export the sum value ??

I think no because it is a computed value, it is not stored in the database.

Related Posts Replies Views Activity
4
Apr 24
170709
0
Dec 23
595
5
Nov 24
217012
1
Dec 22
1692
2
Nov 22
1671