Skip to content

Commit

Permalink
[ADD]smile_payment_writeoff module
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieujoossen committed Nov 25, 2016
1 parent fad62ff commit 9789836
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 0 deletions.
23 changes: 23 additions & 0 deletions smile_payment_writeoff/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Smile (<http://www.smile.fr>). All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import models
import tests
47 changes: 47 additions & 0 deletions smile_payment_writeoff/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Smile (<http://www.smile.fr>). All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

{
"name": "Payment_writeoff amount",
"version": "0.1",
"sequence": 100,
"category": "Accounting & Finance",
"author": "Smile",
"license": 'AGPL-3',
"website": 'http://www.smile.fr',
"description": """
Payment_writeoff amount auto paid
=================================
This module add fields, on company, loss and profit amounts and accounts.
When a payment is done from invoice, if writeoff is in the allowed amount, mark invoice as fully paid with the profit/loss account.
Suggestions & Feedback to: [email protected]
""",
"depends": ["account_voucher"],
"data": [
'views/res_company_view.xml',
],
'installable': True,
'auto_install': False,
'application': False,
}
46 changes: 46 additions & 0 deletions smile_payment_writeoff/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * smile_payment_writeoff
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0-20161028\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-25 13:31+0000\n"
"PO-Revision-Date: 2016-11-25 13:31+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: smile_payment_writeoff
#: model:ir.model,name:smile_payment_writeoff.model_res_company
msgid "Companies"
msgstr "Sociétés"

#. module: smile_payment_writeoff
#: model:ir.model.fields,field_description:smile_payment_writeoff.field_res_company_invoice_loss_account_id
msgid "Loss Account"
msgstr "Compte de perte"

#. module: smile_payment_writeoff
#: model:ir.model.fields,field_description:smile_payment_writeoff.field_res_company_invoice_loss_amount
msgid "Max Loss Amount"
msgstr "Montant max. de perte"

#. module: smile_payment_writeoff
#: model:ir.model.fields,field_description:smile_payment_writeoff.field_res_company_invoice_profit_amount
msgid "Max Profit Amount"
msgstr "Montant max. de profit"

#. module: smile_payment_writeoff
#: model:ir.model,name:smile_payment_writeoff.model_account_payment
msgid "Payments"
msgstr "Paiements"

#. module: smile_payment_writeoff
#: model:ir.model.fields,field_description:smile_payment_writeoff.field_res_company_invoice_profit_account_id
msgid "Profit Account"
msgstr "Compte de résultat"
23 changes: 23 additions & 0 deletions smile_payment_writeoff/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Smile (<http://www.smile.fr>). All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import account_payment
import res_company
44 changes: 44 additions & 0 deletions smile_payment_writeoff/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Smile (<http://www.smile.fr>). All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from odoo import api, models


class AccountPayment(models.Model):
_inherit = 'account.payment'

@api.onchange('payment_difference')
def onchange_writeoff_amount(self):
pd = self.payment_difference
if pd > 0:
if pd < self.company_id.invoice_loss_amount and self.company_id.invoice_loss_account_id:
self.payment_difference_handling = 'reconcile'
self.writeoff_account_id = self.company_id.invoice_loss_account_id
else:
self.payment_difference_handling = 'open'
self.writeoff_account_id = False
elif pd < 0:
if abs(pd) < self.company_id.invoice_profit_amount and self.company_id.invoice_loss_account_id:
self.payment_difference_handling = 'reconcile'
self.writeoff_account_id = self.company_id.invoice_profit_account_id
else:
self.payment_difference_handling = 'open'
self.writeoff_account_id = False
32 changes: 32 additions & 0 deletions smile_payment_writeoff/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Smile (<http://www.smile.fr>). All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from odoo import fields, models
import odoo.addons.decimal_precision as dp


class ResCompany(models.Model):
_inherit = 'res.company'

invoice_loss_amount = fields.Float(string='Max Loss Amount', digits=dp.get_precision('Account'))
invoice_profit_amount = fields.Float(string='Max Profit Amount', digits=dp.get_precision('Account'))
invoice_loss_account_id = fields.Many2one('account.account', 'Loss Account', ondelete='restrict')
invoice_profit_account_id = fields.Many2one('account.account', 'Profit Account', ondelete='restrict')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions smile_payment_writeoff/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Smile (<http://www.smile.fr>). All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import test_invoice
Loading

0 comments on commit 9789836

Please sign in to comment.