=== added directory 'account_deferred_charge'
=== added file 'account_deferred_charge/__init__.py'
--- account_deferred_charge/__init__.py	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/__init__.py	2013-10-22 13:25:12 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+#    @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
+#
+#    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 account
+import company

=== added file 'account_deferred_charge/__openerp__.py'
--- account_deferred_charge/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/__openerp__.py	2013-10-22 13:25:12 +0000
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+#    @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
+#
+#    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/>.
+#
+##############################################################################
+
+{
+    'name': "Deferred charged invoices",
+    'version': '0.1',
+    'category' : 'Accounting & Finance',
+    'description': """
+This module hanldes invoices with deferred charges.
+
+You have to configure 'Deferred charge journal' in account settings.
+
+In order to generate the deferred charge journal entry, in the invoice line you have to
+set the 'Deferred charge account' and the time range of the deferred charge.
+Optionally, you can set the 'Reversal date': when the deferred charge move has
+to be reverted.
+""",
+    'author': 'Agile Business Group',
+    'website': 'http://www.agilebg.com',
+    'license': 'AGPL-3',
+    "depends" : ['account_reversal'],
+    "data" : [
+        'company_view.xml',
+        'account_invoice_view.xml',
+        ],
+    "demo" : [],
+    "test": [
+        'test/invoice.yml',
+        ],
+    "active": False,
+    "installable": True
+}

=== added file 'account_deferred_charge/account.py'
--- account_deferred_charge/account.py	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/account.py	2013-10-22 13:25:12 +0000
@@ -0,0 +1,112 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+#    @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
+#
+#    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 __future__ import division
+from openerp.osv import fields, orm
+from datetime import datetime
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
+from openerp.tools.translate import _
+
+class account_invoice(orm.Model):
+
+    _inherit = "account.invoice"
+    
+    _columns = {
+        'deferred_charge_move_ids': fields.many2many('account.move',
+            'invoice_deferred_charge_move_ids_rel', 'invoice_id', 'move_id',
+            'Deferred charge Entries', readonly=True),
+        }
+
+    def action_move_create(self, cr, uid, ids, context=None):
+        move_obj = self.pool.get('account.move')
+        res = super(account_invoice,self).action_move_create(cr, uid, ids, context=context)
+        for invoice in self.browse(cr, uid, ids, context):
+            for inv_line in invoice.invoice_line:
+                if inv_line.deferrede_charge:
+                    if not invoice.company_id.deferred_charge_journal_id:
+                        raise orm.except_orm(_('Error'),
+                            _('No deferred charge journal configured in accounting settings'))
+                    if (not inv_line.deferred_charge_account_id
+                        or not inv_line.deferred_charge_from
+                        or not inv_line.deferred_charge_to):
+                        raise orm.except_orm(_('Error'), _('Missing deferred charge data'))
+                    date_from = datetime.strptime(inv_line.deferred_charge_from,
+                        DEFAULT_SERVER_DATE_FORMAT)
+                    date_to = datetime.strptime(inv_line.deferred_charge_to,
+                        DEFAULT_SERVER_DATE_FORMAT)
+                    if date_from.year == date_to.year:
+                        raise orm.except_orm(_('Error'),
+                            _('Deferred charge: start date and end are on the same year'))
+                    total_delta = date_to - date_from
+                    current_year_delta  = datetime(date_from.year, 12, 31) - date_from
+                    current_year_amount = inv_line.price_subtotal * (
+                        current_year_delta.days / total_delta.days)
+                    next_year_amount = inv_line.price_subtotal - current_year_amount
+                    move_vals = {
+                        'period_id': invoice.move_id.period_id.id,
+                        'journal_id': invoice.company_id.deferred_charge_journal_id.id,
+                        'date': invoice.move_id.date,
+                        'line_id': [
+                            (0,0, {
+                                'name': _("Deferred charge") + ': ' + inv_line.name,
+                                'account_id': inv_line.account_id.id,
+                                'credit': next_year_amount,
+                                'debit': 0.0,
+                                }),
+                            (0,0, {
+                                'name': _("Deferred charge") + ': ' + inv_line.name,
+                                'account_id': inv_line.deferred_charge_account_id.id,
+                                'debit': next_year_amount,
+                                'credit': 0.0,
+                                }),
+                            ],
+                        }
+                    move_id = move_obj.create(cr, uid, move_vals, context=context)
+                    invoice.write({
+                        'deferred_charge_move_ids': [
+                            (4, move_id),
+                            ],
+                        }, context=context)
+                    
+                    if inv_line.reversal_date:
+                        move_obj.create_reversals(cr, uid, [move_id], inv_line.reversal_date)
+        return res
+    
+    def action_cancel(self, cr, uid, ids, context=None):
+        res = super(account_invoice,self).action_cancel(cr, uid, ids, context=context)
+        account_move_obj = self.pool.get('account.move')
+        for inv in self.browse(cr, uid, ids, context):
+            for move in inv.deferred_charge_move_ids:
+                account_move_obj.button_cancel(cr, uid, [move.id], context=context)
+                account_move_obj.unlink(cr, uid, [move.id], context=context)
+        return res
+
+class account_invoice_line(orm.Model):
+    _inherit = 'account.invoice.line'
+
+    _columns = {
+        'deferrede_charge': fields.boolean('Deferred charge'),
+        'deferred_charge_account_id': fields.many2one('account.account',
+            'Deferred charge account'),
+        'deferred_charge_from': fields.date('Deferred charge from date'),
+        'deferred_charge_to': fields.date('Deferred charge to date'),
+        'reversal_date': fields.date('Reversal date'),
+        }

=== added file 'account_deferred_charge/account_invoice_view.xml'
--- account_deferred_charge/account_invoice_view.xml	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/account_invoice_view.xml	2013-10-22 13:25:12 +0000
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<openerp>
+  <data>
+    <record model="ir.ui.view" id="invoice_form_deferred_charge_1">
+      <field name="name">account.invoice.form.editable</field>
+      <field name="model">account.invoice</field>
+      <field name="inherit_id" ref="account.invoice_form"/>
+      <field name="arch" type="xml">
+        <xpath expr="//field[@name='invoice_line']/tree" position="attributes" >
+          <attribute name="editable" eval="False"/>
+        </xpath>
+      </field>
+    </record>
+
+    <record model="ir.ui.view" id="invoice_form_deferred_charge_1b">
+      <field name="name">account.invoice.form.supplier.editable</field>
+      <field name="model">account.invoice</field>
+      <field name="inherit_id" ref="account.invoice_supplier_form"/>
+      <field name="arch" type="xml">
+        <xpath expr="//field[@name='invoice_line']/tree" position="attributes" >
+          <attribute name="editable" eval="False"/>
+        </xpath>
+      </field>
+    </record>
+
+    <record model="ir.ui.view" id="invoice_form_deferred_charge_moves">
+      <field name="name">account.invoice.form.add.moves</field>
+      <field name="model">account.invoice</field>
+      <field name="inherit_id" ref="account.invoice_form"/>
+      <field name="arch" type="xml">
+        <page string="Payments" position="after" >
+            <page string="Deferred moves" >
+                <field name="deferred_charge_move_ids" />
+          </page>
+        </page>
+      </field>
+    </record>
+
+    <!-- attrs not working. bug?
+    -->
+    <record model="ir.ui.view" id="invoice_form_deferred_charge_supplier_moves">
+      <field name="name">account.invoice.form.add.supplier.moves</field>
+      <field name="model">account.invoice</field>
+      <field name="inherit_id" ref="account.invoice_supplier_form"/>
+      <field name="arch" type="xml">
+        <page string="Payments" position="after" >
+            <page string="Deferred moves" attrs="{'invisible': [('payment_ids','=', False)]}">
+                <field name="deferred_charge_move_ids" />
+          </page>
+        </page>
+      </field>
+    </record>
+    
+    <record model="ir.ui.view" id="invoice_form_deferred_charge">
+      <field name="name">account.invoice.form.deferred.charge</field>
+      <field name="model">account.invoice.line</field>
+      <field name="inherit_id" ref="account.view_invoice_line_form"/>
+      <field name="arch" type="xml">
+        <field name="name" position="after">
+          <group>
+          <field name="deferrede_charge"/>
+          <field name="deferred_charge_account_id" attrs="{'invisible': [('deferrede_charge','=',False)],
+            'required': [('deferrede_charge','=', True)]}"/>
+          <field name="deferred_charge_from" attrs="{'invisible': [('deferrede_charge','=',False)],
+            'required': [('deferrede_charge','=', True)]}"/>
+          <field name="deferred_charge_to" attrs="{'invisible': [('deferrede_charge','=',False)],
+            'required': [('deferrede_charge','=', True)]}"/>
+          <field name="reversal_date" attrs="{'invisible': [('deferrede_charge','=',False)]}"/>
+          </group>
+        </field>
+      </field>
+    </record>
+  </data>
+</openerp>

=== added file 'account_deferred_charge/company.py'
--- account_deferred_charge/company.py	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/company.py	2013-10-22 13:25:12 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+#    @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
+#
+#    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.osv import fields, orm
+
+class res_company(orm.Model):
+    _inherit = 'res.company'
+    _columns = {
+        'deferred_charge_journal_id': fields.many2one('account.journal',
+            'Deferred charge journal'),
+        }
+    
+class account_config_settings(orm.TransientModel):
+    _inherit = 'account.config.settings'
+    _columns = {
+        'deferred_charge_journal_id': fields.related(
+            'company_id', 'deferred_charge_journal_id',
+            type='many2one',
+            relation="account.journal",
+            string="Deferred charge journal"),
+    }

=== added file 'account_deferred_charge/company_view.xml'
--- account_deferred_charge/company_view.xml	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/company_view.xml	2013-10-22 13:25:12 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="view_account_config_settings" model="ir.ui.view">
+            <field name="name">view_account_config_settings</field>
+            <field name="model">account.config.settings</field>
+            <field name="inherit_id" ref="account.view_account_config_settings"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form/group[6]" position="after">
+                    <separator string="Deferred charge"/>
+                    <group name="Deferred charge">
+                        <label for="id" string="Configuration"/>
+                        <div>
+                            <div>
+                                <label for="deferred_charge_journal_id"/>
+                                <field name="deferred_charge_journal_id" class="oe_inline"/>
+                            </div>
+                        </div>
+                    </group>
+                </xpath>
+            </field>
+        </record>
+	</data>
+</openerp>

=== added directory 'account_deferred_charge/i18n'
=== added file 'account_deferred_charge/i18n/account_deferred_charge.pot'
--- account_deferred_charge/i18n/account_deferred_charge.pot	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/i18n/account_deferred_charge.pot	2013-10-22 13:25:12 +0000
@@ -0,0 +1,118 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* account_deferred_charge
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-10-22 13:24+0000\n"
+"PO-Revision-Date: 2013-10-22 13:24+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: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:46
+#, python-format
+msgid "No deferred charge journal configured in accounting settings"
+msgstr ""
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,deferred_charge_to:0
+msgid "Deferred charge to date"
+msgstr ""
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_account_invoice
+msgid "Invoice"
+msgstr ""
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_account_config_settings
+msgid "account.config.settings"
+msgstr ""
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:50
+#, python-format
+msgid "Missing deferred charge data"
+msgstr ""
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_res_company
+msgid "Companies"
+msgstr ""
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_account_invoice_line
+msgid "Invoice Line"
+msgstr ""
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:57
+#, python-format
+msgid "Deferred charge: start date and end are on the same year"
+msgstr ""
+
+#. module: account_deferred_charge
+#: view:account.invoice:0
+msgid "Deferred moves"
+msgstr ""
+
+#. module: account_deferred_charge
+#: view:account.config.settings:0
+#: field:account.invoice.line,deferrede_charge:0
+#: code:addons/account_deferred_charge/account.py:69
+#: code:addons/account_deferred_charge/account.py:75
+#, python-format
+msgid "Deferred charge"
+msgstr ""
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,deferred_charge_account_id:0
+msgid "Deferred charge account"
+msgstr ""
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,reversal_date:0
+msgid "Reversal date"
+msgstr ""
+
+#. module: account_deferred_charge
+#: view:account.invoice:0
+msgid "Payments"
+msgstr ""
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,deferred_charge_from:0
+msgid "Deferred charge from date"
+msgstr ""
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:45
+#: code:addons/account_deferred_charge/account.py:50
+#: code:addons/account_deferred_charge/account.py:56
+#, python-format
+msgid "Error"
+msgstr ""
+
+#. module: account_deferred_charge
+#: field:account.invoice,deferred_charge_move_ids:0
+msgid "Deferred charge Entries"
+msgstr ""
+
+#. module: account_deferred_charge
+#: view:account.config.settings:0
+msgid "Configuration"
+msgstr ""
+
+#. module: account_deferred_charge
+#: field:account.config.settings,deferred_charge_journal_id:0
+#: field:res.company,deferred_charge_journal_id:0
+msgid "Deferred charge journal"
+msgstr ""
+

=== added file 'account_deferred_charge/i18n/it.po'
--- account_deferred_charge/i18n/it.po	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/i18n/it.po	2013-10-22 13:25:12 +0000
@@ -0,0 +1,120 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# 	* account_deferred_charge
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-10-22 12:43+0000\n"
+"PO-Revision-Date: 2013-10-22 15:23+0100\n"
+"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"X-Generator: Poedit 1.5.4\n"
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:46
+#, python-format
+msgid "No deferred charge journal configured in accounting settings"
+msgstr ""
+"Nessun sezionale di ratei/risconti configurato nelle impostazioni della "
+"contabilità"
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,deferred_charge_to:0
+msgid "Deferred charge to date"
+msgstr "Alla data"
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_account_invoice
+msgid "Invoice"
+msgstr "Fattura"
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_account_config_settings
+msgid "account.config.settings"
+msgstr "account.config.settings"
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:50
+#, python-format
+msgid "Missing deferred charge data"
+msgstr "Mancano i dati per il rateo/risconto"
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_res_company
+msgid "Companies"
+msgstr "Aziende"
+
+#. module: account_deferred_charge
+#: model:ir.model,name:account_deferred_charge.model_account_invoice_line
+msgid "Invoice Line"
+msgstr "Righe Fattura"
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:57
+#, python-format
+msgid "Deferred charge: start date and end are on the same year"
+msgstr "Rateo/risconto: data inizio e data fine sono nello stesso anno"
+
+#. module: account_deferred_charge
+#: view:account.invoice:0
+msgid "Deferred moves"
+msgstr "Registrazioni contabili ratei/risconti"
+
+#. module: account_deferred_charge
+#: view:account.config.settings:0
+#: field:account.invoice.line,deferrede_charge:0
+#: code:addons/account_deferred_charge/account.py:69
+#: code:addons/account_deferred_charge/account.py:75
+#, python-format
+msgid "Deferred charge"
+msgstr "Rateo/risconto"
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,deferred_charge_account_id:0
+msgid "Deferred charge account"
+msgstr "Conto rateo/risconto"
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,reversal_date:0
+msgid "Reversal date"
+msgstr "Data di storno"
+
+#. module: account_deferred_charge
+#: view:account.invoice:0
+msgid "Payments"
+msgstr "Pagamenti"
+
+#. module: account_deferred_charge
+#: field:account.invoice.line,deferred_charge_from:0
+msgid "Deferred charge from date"
+msgstr "Dalla data"
+
+#. module: account_deferred_charge
+#: code:addons/account_deferred_charge/account.py:45
+#: code:addons/account_deferred_charge/account.py:50
+#: code:addons/account_deferred_charge/account.py:56
+#, python-format
+msgid "Error"
+msgstr "Errore"
+
+#. module: account_deferred_charge
+#: field:account.invoice,deferred_charge_move_ids:0
+msgid "Deferred charge Entries"
+msgstr "Registrazioni contabili ratei/risconti"
+
+#. module: account_deferred_charge
+#: view:account.config.settings:0
+msgid "Configuration"
+msgstr "Configurazione"
+
+#. module: account_deferred_charge
+#: field:account.config.settings,deferred_charge_journal_id:0
+#: field:res.company,deferred_charge_journal_id:0
+msgid "Deferred charge journal"
+msgstr "Sezionale ratei/risconti"

=== added directory 'account_deferred_charge/test'
=== added file 'account_deferred_charge/test/invoice.yml'
--- account_deferred_charge/test/invoice.yml	1970-01-01 00:00:00 +0000
+++ account_deferred_charge/test/invoice.yml	2013-10-22 13:25:12 +0000
@@ -0,0 +1,77 @@
+-
+  I create next year
+-
+  !record {model: account.fiscalyear, id: next_year}:
+    name: 'next year'
+    code: 'next year'
+    date_start: !eval "'%s-01-01'% (datetime.now().year+1)"
+    date_stop: !eval "'%s-12-31'% (datetime.now().year+1)"
+-
+  I create periods
+-
+  !python {model: account.fiscalyear}: |
+    self.create_period(cr, uid, [ref('next_year')])
+-
+  I configure deferred charge journal
+-
+  !record {model: res.company, id: base.main_company}:
+    deferred_charge_journal_id: account.expenses_journal
+-
+  I create a supplier invoice
+-
+  !record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form}:
+    account_id: account.a_pay
+    check_total: 1200
+    company_id: base.main_company
+    currency_id: base.EUR
+    invoice_line:
+      - account_id: account.a_expense
+        name: 'Insurance'
+        price_unit: 1200
+        quantity: 1
+        uos_id: product.product_uom_unit
+        deferred_charge_from: !eval "'%s-12-01'% (datetime.now().year)"
+        deferred_charge_to: !eval "'%s-11-30'% (datetime.now().year+1)"
+        deferred_charge_account_id: account.stk
+        reversal_date: !eval "'%s-01-01'% (datetime.now().year+1)"
+        deferrede_charge: True
+    journal_id: account.expenses_journal
+    partner_id: base.res_partner_12
+    type: in_invoice
+-
+  I check that Initially supplier invoice state is "Draft"
+-
+  !assert {model: account.invoice, id: account_invoice_supplier0}:
+    - state == 'draft'
+-
+  I change the state of invoice to open by clicking Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
+-
+  I check that the invoice state is now "Open"
+-
+  !assert {model: account.invoice, id: account_invoice_supplier0}:
+    - state == 'open'
+-
+  I verify that account move is created
+-
+  !python {model: account.invoice}: |
+    from datetime import datetime
+    move_obj = self.pool.get('account.move')
+    inv = self.browse(cr, uid, ref('account_invoice_supplier0'))
+    move = inv.move_id
+    get_period = move_obj._get_period(cr, uid, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
+      'active_ids': [ref('account.menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('account.menu_action_move_journal_line_form')})
+    amt = move_obj._search_amount(cr, uid, move_obj, 'amount', [('amount', '=', 1200.0)], {'lang': u'en_US', 'active_model': 'ir.ui.menu',
+      'active_ids': [ref('account.menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('account.menu_action_move_journal_line_form')})
+    ids = amt[0][2]
+    amt_compute = move_obj._amount_compute(cr, uid, list(ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
+      'active_ids': [ref('account.menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('account.menu_action_move_journal_line_form')}, where ='')
+    move_amount = amt_compute.values()
+    assert(inv.move_id and move.period_id.id == get_period and move_amount[0] == 1200.0), ('Journal Entries has not been created')
+    assert (inv.deferred_charge_move_ids) , 'No deferred charge move generated'
+    if inv.deferred_charge_move_ids:
+        for move_line in inv.deferred_charge_move_ids[0].line_id:
+            if move_line.account_id.id == ref('account.stk'):
+                assert(move_line.debit == 1101.1), 'Wrong deferred charge amount'
+        assert (inv.deferred_charge_move_ids[0].reversal_id and inv.deferred_charge_move_ids[0].reversal_id.date == '%s-01-01'% (datetime.now().year+1)), 'Wrong reversal move'

