Merge pull request #167 from acsone/8.0-imp-credit-control-total-due-ape

[IMP][Credit Control] Include the fees in the total due
This commit is contained in:
Guewen Baconnier
2015-03-16 16:05:49 +01:00
4 changed files with 69 additions and 5 deletions

View File

@@ -68,17 +68,25 @@ class CreditCommunication(models.TransientModel):
total_invoiced = fields.Float(string='Total Invoiced',
compute='_compute_total')
total_due = fields.Float(string='Total Invoiced',
total_due = fields.Float(string='Total Due',
compute='_compute_total')
@api.model
def _get_total(self):
amount_field = 'credit_control_line_ids.amount_due'
return sum(self.mapped(amount_field))
@api.model
def _get_total_due(self):
balance_field = 'credit_control_line_ids.balance_due'
return sum(self.mapped(balance_field))
@api.depends('credit_control_line_ids',
'credit_control_line_ids.amount_due',
'credit_control_line_ids.balance_due')
def _compute_total(self):
amount_field = 'credit_control_line_ids.amount_due'
balance_field = 'credit_control_line_ids.balance_due'
self.total_invoiced = sum(self.mapped(amount_field))
self.total_due = sum(self.mapped(balance_field))
self.total_invoiced = self._get_total()
self.total_due = self._get_total_due()
@api.model
@api.returns('self', lambda value: value.id)

View File

@@ -19,3 +19,4 @@
#
##############################################################################
from . import model
from . import wizard

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import credit_control_communication

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, api
class CreditCommunication(models.TransientModel):
_inherit = 'credit.control.communication'
@api.model
def _get_total_due(self):
balance_field = 'credit_control_line_ids.balance_due_total'
return sum(self.mapped(balance_field))