← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~nicolariolini/account-invoicing/add_module_account_payment_term_month into lp:account-invoicing

 

Nicola Riolini - Micronaet has proposed merging lp:~nicolariolini/account-invoicing/add_module_account_payment_term_month into lp:account-invoicing.

Requested reviews:
  Account Core Editors (account-core-editors)

For more details, see:
https://code.launchpad.net/~nicolariolini/account-invoicing/add_module_account_payment_term_month/+merge/212400

Module account_payment_term_month
Module for manage payment in 'commercial month' so extra months are not calculated in 30 days * month (with known problems in 28th february) but really in N month
-- 
https://code.launchpad.net/~nicolariolini/account-invoicing/add_module_account_payment_term_month/+merge/212400
Your team Account Core Editors is requested to review the proposed merge of lp:~nicolariolini/account-invoicing/add_module_account_payment_term_month into lp:account-invoicing.
=== added directory 'account_payment_term_month'
=== added file 'account_payment_term_month/__init__.py'
--- account_payment_term_month/__init__.py	1970-01-01 00:00:00 +0000
+++ account_payment_term_month/__init__.py	2014-03-24 12:27:56 +0000
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Micronaet SRL (<http://www.micronaet.it>).
+#
+#    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 payment
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_payment_term_month/__openerp__.py'
--- account_payment_term_month/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_payment_term_month/__openerp__.py	2014-03-24 12:27:56 +0000
@@ -0,0 +1,43 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Micronaet SRL (<http://www.micronaet.it>).
+#
+#    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 terms - Commercial month",
+    "version": "1.0",
+    "author": "Micronaet s.r.l.",
+    "website": "http://www.micronaet.it";,
+    "category": "Account / Payments",
+    "description": """
+         This module manage commercial month for end of month deadline
+    """,
+    "depends": [
+        "account",
+    ],
+    "init_xml": [],
+    "demo_xml": [],
+    "data": [
+        "payment_view.xml",
+    ],
+    "active": False,
+    "installable": True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'account_payment_term_month/i18n'
=== added file 'account_payment_term_month/i18n/it.po'
--- account_payment_term_month/i18n/it.po	1970-01-01 00:00:00 +0000
+++ account_payment_term_month/i18n/it.po	2014-03-24 12:27:56 +0000
@@ -0,0 +1,65 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# 	* account_payment_term_month
+# <> <>, 2014.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-02-07 06:40+0000\n"
+"PO-Revision-Date: 2014-02-07 07:43+0100\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: account_payment_term_month
+#: help:account.payment.term.line,months:0
+msgid ""
+"Number of month to add before computation of the day of month.If Date = "
+"15/01, Number of month = 1, Day of Month = -1, then the due date is 28/02."
+msgstr ""
+"Numero di mesi da aggiungere prima del calcolo del giorno del mese. Se la "
+"data = 29/01, Numero di mesi = 1, Giorno del mese = -1 allora la data di "
+"scadenza sarà 28/02."
+
+#. module: account_payment_term_month
+#: view:account.payment.term.line:0
+msgid ""
+"{'invisible':[('commercial_month','=',True)],'required':"
+"[('commercial_month','=',False)],}"
+msgstr ""
+"{'invisible':[('commercial_month','=',True)],'required':"
+"[('commercial_month','=',False)],}"
+
+#. module: account_payment_term_month
+#: field:account.payment.term.line,commercial_month:0
+msgid "Month period"
+msgstr "Mese commerciale"
+
+#. module: account_payment_term_month
+#: help:account.payment.term.line,commercial_month:0
+msgid ""
+"If checked use the period as a months instead of days (use for commercial "
+"month - end of month payment)"
+msgstr ""
+"Se spuntato utilizza il periodo come mesi al posto di giorni (consiglio: "
+"utilizzare il mese commerciale nei pagamenti a fine mese)"
+
+#. module: account_payment_term_month
+#: model:ir.model,name:account_payment_term_month.model_account_payment_term
+msgid "Payment Term"
+msgstr "Termine di pagamento"
+
+#. module: account_payment_term_month
+#: model:ir.model,name:account_payment_term_month.model_account_payment_term_line
+msgid "Payment Term Line"
+msgstr "Riga termine di pagamento"
+
+#. module: account_payment_term_month
+#: field:account.payment.term.line,months:0
+msgid "Number of month"
+msgstr "Numero di mesi"

=== added file 'account_payment_term_month/payment.py'
--- account_payment_term_month/payment.py	1970-01-01 00:00:00 +0000
+++ account_payment_term_month/payment.py	2014-03-24 12:27:56 +0000
@@ -0,0 +1,108 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Micronaet SRL (<http://www.micronaet.it>).
+#
+#    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/>.
+#
+##############################################################################
+import logging
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+from operator import itemgetter
+import time
+
+import openerp
+from openerp import SUPERUSER_ID
+from openerp import pooler, tools
+from openerp.osv import fields, osv, expression
+from openerp.tools.translate import _
+from openerp.tools.float_utils import float_round
+
+import openerp.addons.decimal_precision as dp
+
+
+class account_payment_term_line(osv.osv):
+    ''' Add extra field for manage commercial payments
+    '''
+    _name = "account.payment.term.line"
+    _inherit = "account.payment.term.line"
+
+    _columns = {
+        'commercial_month': fields.boolean(
+            'Month period',
+            help="If checked"
+                 "use the period as a months instead of days (use for"
+                 "commercial month - end of month payment)"),
+        'months': fields.integer(
+            'Number of month', required=False,
+            help="Number of month to add before computation of the day of"
+                 "month. If Date=15-01, Number of month=1, Day of Month=-1,"
+                 "then the due date is 28-02."),
+    }
+    _defaults = {
+        'commercial_month': False,
+        'months': 0,
+    }
+
+
+class account_payment_term(osv.osv):
+    ''' Override compunte method and add month check
+    '''
+    _name = "account.payment.term"
+    _inherit = "account.payment.term"
+
+    def compute(self, cr, uid, id, value, date_ref=False, context=None):
+        ''' Function overrided for check also month values
+        '''
+        if not date_ref:
+            date_ref = datetime.now().strftime('%Y-%m-%d')
+        pt = self.browse(cr, uid, id, context=context)
+        amount = value
+        result = []
+        obj_precision = self.pool.get('decimal.precision')
+        prec = obj_precision.precision_get(cr, uid, 'Account')
+        for line in pt.line_ids:
+            if line.value == 'fixed':
+                amt = round(line.value_amount, prec)
+            elif line.value == 'procent':
+                amt = round(value * line.value_amount, prec)
+            elif line.value == 'balance':
+                amt = round(amount, prec)
+            if amt:
+                if line.commercial_month:  # commercial months
+                    next_date = (
+                        datetime.strptime(date_ref, '%Y-%m-%d') +
+                        relativedelta(months=line.months))
+                else:  # days
+                    next_date = (
+                        datetime.strptime(date_ref, '%Y-%m-%d') +
+                        relativedelta(days=line.days))
+                if line.days2 < 0:
+                    next_first_date = next_date + relativedelta(
+                        day=1, months=1)  # Getting 1st of next month
+                    next_date = next_first_date + relativedelta(
+                        days=line.days2)
+                if line.days2 > 0:
+                    next_date += relativedelta(day=line.days2, months=1)
+                result.append((next_date.strftime('%Y-%m-%d'), amt))
+                amount -= amt
+
+        amount = reduce(lambda x, y: x+y[1], result, 0.0)
+        dist = round(value-amount, prec)
+        if dist:
+            result.append((time.strftime('%Y-%m-%d'), dist))
+        return result
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_payment_term_month/payment_view.xml'
--- account_payment_term_month/payment_view.xml	1970-01-01 00:00:00 +0000
+++ account_payment_term_month/payment_view.xml	2014-03-24 12:27:56 +0000
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- Payment Terms Line -->
+        <record id="view_payment_term_line_tree_month" model="ir.ui.view">
+            <field name="name">account.payment.term.line.tree.month</field>
+            <field name="model">account.payment.term.line</field>
+            <field name="inherit_id" ref="account.view_payment_term_line_tree"/>
+            <field name="arch" type="xml">
+                <field name="days" position="after">
+                    <field name="commercial_month"/>
+                    <field name="months"/>
+                </field>
+            </field>
+        </record>
+
+        <record id="view_payment_term_line_form_month" model="ir.ui.view">
+            <field name="name">account.payment.term.line.form.month</field>
+            <field name="model">account.payment.term.line</field>
+            <field name="inherit_id" ref="account.view_payment_term_line_form"/>
+            <field name="arch" type="xml">
+                   <field name="days" position="before">
+                       <field name="commercial_month" />
+                       <field name="months" attrs="{'invisible':[('commercial_month','=',False)],'required':[('commercial_month','=',True)],}"/>
+                   </field>
+                   <xpath expr="/form/group/group/field[@name='days']" position="attributes">
+                       <attribute name="attrs">{'invisible':[('commercial_month','=',True)],'required':[('commercial_month','=',False)],}</attribute>
+                   </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>        

=== added directory 'account_payment_term_month/security'
=== added directory 'account_payment_term_month/static'
=== added directory 'account_payment_term_month/static/src'
=== added directory 'account_payment_term_month/static/src/img'
=== added file 'account_payment_term_month/static/src/img/icon.png'
Binary files account_payment_term_month/static/src/img/icon.png	1970-01-01 00:00:00 +0000 and account_payment_term_month/static/src/img/icon.png	2014-03-24 12:27:56 +0000 differ

Follow ups