diff --git a/ext/custom-addons/cam_invoice_skonto/__init__.py b/ext/custom-addons/cam_invoice_skonto/__init__.py new file mode 100644 index 00000000..e9c3887f --- /dev/null +++ b/ext/custom-addons/cam_invoice_skonto/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# cam_invoice_skonto, Custom Module for OpenERP +# Copyright (C) 2014 Camadeus Consulting GmbH (). +# +# 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 . +# +############################################################################## + +import cam_invoice_skonto + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/cam_invoice_skonto/__openerp__.py b/ext/custom-addons/cam_invoice_skonto/__openerp__.py new file mode 100644 index 00000000..543479a1 --- /dev/null +++ b/ext/custom-addons/cam_invoice_skonto/__openerp__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# cam_invoice_skonto, Custom Module for OpenERP +# Copyright (C) 2014 Camadeus Consulting GmbH (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Camadeus Invoice Skonto', + 'version': '1.0', + 'category': 'Custom', + 'description': + """ + - Fügt die Felder Netto Tage, Skonto Tage, Skonto Prozent zu Zahlungsbedingungen (account.payment.term) hinzu. + - Fügt die Felder Skonto Fälligkeit und Betrag inkl. Skonto zur Rechnung (account.invoice) hinzu. + """, + 'author': 'camadeus GmbH', + 'website': 'http://www.camadeus.at', + 'depends': ['account'], + 'data': [ + 'cam_invoice_skonto_view.xml', + 'cam_invoice_skonto_data.xml', + ], + 'installable': True, + 'auto_install': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto.py b/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto.py new file mode 100644 index 00000000..f9f26bc5 --- /dev/null +++ b/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# cam_invoice_skonto, Custom Module for OpenERP +# Copyright (C) 2014 Camadeus Consulting GmbH (). +# +# 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 . +# +############################################################################## + +from openerp.osv import fields, osv +from openerp import models, fields as f, api +import openerp.addons.decimal_precision as dp +from datetime import date, timedelta, datetime + +class account_payment_term(osv.osv): + _inherit = 'account.payment.term' + + _columns = { + 'netto_tage': fields.integer('Netto Tage'), + 'skonto_tage': fields.integer('Skonto Tage'), + 'skonto_prozent': fields.float('Skonto Prozent'), + } + + def write(self, cr, uid, ids, values, context=None): + if context is None: + context = {} + + tl_obj = self.pool.get('account.payment.term.line') + for pay_term in self.browse(cr, uid, ids, context=context): + # Delete old account.payment.term.line + for tl_id in pay_term.line_ids: + tl_obj.unlink(cr, uid, tl_id.id, context=context) + # Create new account.payment.term.line based on netto_tage + days = 0 + if('netto_tage' in values): + days = values['netto_tage'] + else: + days = pay_term.netto_tage + values['line_ids'] = [(0,0, {'payment_id':pay_term.id, 'value': 'balance', 'days': days, 'days2':0})] + + return super(account_payment_term, self).write(cr, uid, ids, values, context=context) + + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + + new_id = super(account_payment_term, self).create(cr, uid, vals, context=context) + self.write(cr, uid, new_id, {'netto_tage': vals['netto_tage']}, context=context) + + return new_id + +class account_invoice(models.Model): + _inherit = 'account.invoice' + + @api.one + def _skonto_betrag_inkl(self): + if self.payment_term and self.payment_term.skonto_prozent: + self.skonto_betrag_inkl = self.amount_total * (1 - self.payment_term.skonto_prozent/100.0) + + skonto_faelligkeit = f.Date(string=u'Skonto Fälligkeit', readonly=True) + skonto_betrag_inkl = f.Float(string='Betrag inkl. Skonto', digits=dp.get_precision('Account'), readonly=True, compute='_skonto_betrag_inkl') + + @api.multi + def action_skonto_faelligkeit_assign(self): + for inv in self: + if inv.payment_term and inv.payment_term.skonto_tage: + inv.write({'skonto_faelligkeit': datetime.strptime(inv.date_invoice, '%Y-%m-%d') + timedelta(days=inv.payment_term.skonto_tage)}) + return True + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto_data.xml b/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto_data.xml new file mode 100644 index 00000000..6e2a8349 --- /dev/null +++ b/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto_data.xml @@ -0,0 +1,38 @@ + + + + + + + + action_date_assign() +action_move_create() +action_number() +invoice_validate() +action_skonto_faelligkeit_assign() + + + diff --git a/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto_view.xml b/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto_view.xml new file mode 100644 index 00000000..9d3f7915 --- /dev/null +++ b/ext/custom-addons/cam_invoice_skonto/cam_invoice_skonto_view.xml @@ -0,0 +1,65 @@ + + + + + + + + + + cam_invoice_skonto.payment.term.form + account.payment.term + + + + + + + + + + + + + + + + + cam_invoice_skonto.invoice.form + account.invoice + + + + + + + + + + + + + diff --git a/ext/custom-addons/cam_invoice_skonto/static/src/img/icon.png b/ext/custom-addons/cam_invoice_skonto/static/src/img/icon.png new file mode 100644 index 00000000..9ad73d74 Binary files /dev/null and b/ext/custom-addons/cam_invoice_skonto/static/src/img/icon.png differ diff --git a/setup/lib/config_at.py b/setup/lib/config_at.py index fa3b64fd..e46f6261 100644 --- a/setup/lib/config_at.py +++ b/setup/lib/config_at.py @@ -115,10 +115,11 @@ class Config(): 'cam_max_width', 'oerp_no_phoning_home', 'cam_custom', - 'cam_reports', - 'account_cancel', + 'cam_reports', + 'account_cancel', + 'cam_invoice_skonto', #'crm', #'sale', #'cam_hr_overtime', #'cam_hr', - ] \ No newline at end of file + ]