123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- # -*- coding: utf-8 -*-
- from openerp import models, fields, api
- class res_partner(models.Model):
- _inherit= 'res.partner'
- total_debt_paid = fields.Float('Cobros Realizados:', compute='_compute_total_debt_paid', store=False)
- total_payment = fields.Float('Pagos Realizados:',compute='_compute_total_payment', store=False)
- debt_paid_ids = fields.One2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '!=', None), '&',('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')])
- debt_pending_ids = fields.One2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', None), '&',('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')])
- payment_done_ids = fields.One2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '!=', None), '&',('account_id.active','=', True), '&', ('account_id.type', '=', 'payable'), ('state', '!=', 'draft')])
- payment_pending_ids = fields.One2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', None), '&',('account_id.active','=', True), '&', ('account_id.type', '=', 'payable'), ('state', '!=', 'draft')])
- def _compute_total_debt_paid(self):
- res = {}
- for partner in self:
- suma = 0
- account = self.env['account.voucher'].search([('partner_id','=',partner.id),('type','=','receipt'),('state','=','posted')])
- for each in account:
- suma = suma + each.amount
- partner.total_debt_paid = suma
- res = partner.total_debt_paid
- return {'value': res}
- def _compute_total_payment(self):
- res = {}
- for partner in self:
- suma = 0
- account = self.env['account.voucher'].search([('partner_id','=',partner.id),('type','=','payment'),('state','=','posted')])
- for each in account:
- suma = suma + each.amount
- partner.total_payment = suma
- res = partner.total_payment
- return {'value': res}
- @api.model
- def get_debt_paid_ids(self, domain):
- data = []
- partner = self.env['res.partner'].search(domain)
- for each in partner.debt_paid_ids:
- print each
- data.append({
- 'journal_id': each.journal_id.name,
- 'ref' : each.ref,
- 'move_id': each.move_id.name,
- 'date_created': each.date_created,
- 'amount': each.credit,
- })
- return data
- @api.model
- def get_debt_pending_ids(self, domain):
- data = []
- partner = self.env['res.partner'].search(domain)
- for each in partner.debt_pending_ids:
- print each
- data.append({
- 'journal_id': each.journal_id.name,
- 'ref' : each.ref,
- 'move_id': each.move_id.name,
- 'date_maturity': each.date_maturity,
- 'amount': each.debit,
- })
- return data
- @api.model
- def get_payment_done_ids(self, domain):
- data = []
- partner = self.env['res.partner'].search(domain)
- for each in partner.payment_done_ids:
- print each
- data.append({
- 'journal_id': each.journal_id.name,
- 'ref' : each.ref,
- 'move_id': each.move_id.name,
- 'date_created': each.date_created,
- 'amount': each.credit,
- })
- return data
- @api.model
- def get_payment_pending_ids(self, domain):
- data = []
- partner = self.env['res.partner'].search(domain)
- for each in partner.payment_pending_ids:
- print each
- data.append({
- 'journal_id': each.journal_id.name,
- 'ref' : each.ref,
- 'move_id': each.move_id.name,
- 'date_maturity': each.date_maturity,
- 'amount': each.credit,
- })
- return data
|