← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~akretion-team/account-financial-tools/account-financial-tools-account-writeoff-autodelete into lp:account-financial-tools

 

Sébastien BEAU - http://www.akretion.com has proposed merging lp:~akretion-team/account-financial-tools/account-financial-tools-account-writeoff-autodelete into lp:account-financial-tools.

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

For more details, see:
https://code.launchpad.net/~akretion-team/account-financial-tools/account-financial-tools-account-writeoff-autodelete/+merge/219934
-- 
https://code.launchpad.net/~akretion-team/account-financial-tools/account-financial-tools-account-writeoff-autodelete/+merge/219934
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch lp:account-financial-tools.
=== added directory 'account_writeoff_autodelete'
=== added file 'account_writeoff_autodelete/__init__.py'
--- account_writeoff_autodelete/__init__.py	1970-01-01 00:00:00 +0000
+++ account_writeoff_autodelete/__init__.py	2014-05-17 13:57:41 +0000
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_writeoff_autodelete for OpenERP
+#   Copyright (C) 2013-TODAY Akretion <http://www.akretion.com>.
+#   @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+#
+#   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
+

=== added file 'account_writeoff_autodelete/__openerp__.py'
--- account_writeoff_autodelete/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_writeoff_autodelete/__openerp__.py	2014-05-17 13:57:41 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_writeoff_autodelete for OpenERP
+#   Copyright (C) 2013-TODAY Akretion <http://www.akretion.com>.
+#   @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+#
+#   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': 'account_writeoff_autodelete',
+    'version': '0.1',
+    'category': 'Generic Modules/Others',
+    'license': 'AGPL-3',
+    'description': """empty""",
+    'author': 'Akretion',
+    'website': 'http://www.akretion.com/',
+    'depends': ['account'], 
+    'init_xml': [],
+    'update_xml': [ 
+           'account_view.xml',
+    ],
+    'demo_xml': [],
+    'installable': True,
+    'active': False,
+}

=== added file 'account_writeoff_autodelete/account.py'
--- account_writeoff_autodelete/account.py	1970-01-01 00:00:00 +0000
+++ account_writeoff_autodelete/account.py	2014-05-17 13:57:41 +0000
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#
+#   account_writeoff_autodelete for OpenERP
+#   Copyright (C) 2013-TODAY Akretion <http://www.akretion.com>.
+#   @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+#
+#   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 osv, fields
+
+class account_move_line(osv.Model):
+    _inherit = "account.move.line"
+
+    def reconcile(self, *args, **kwargs):
+        context = kwargs.get('context')
+        if context is None:
+            ctx={}
+        else:
+            ctx = context.copy()
+        ctx['reconcile_mode'] = True
+        kwargs['context'] = ctx
+        res = super(account_move_line, self).reconcile(*args, **kwargs)
+
+
+class account_move(osv.Model):
+    _inherit = "account.move"
+
+    _columns = {
+        'writeoff': fields.boolean('WriteOff'),
+    }
+
+    def create(self, cr, uid, vals, context=None):
+        if context is None: context = {}
+        if context.get('reconcile_mode'):
+            vals['writeoff'] = True
+        return super(account_move, self).create(cr, uid, vals, context=context)
+
+
+class account_move_reconcile(osv.Model):
+    _inherit = "account.move.reconcile"
+
+    def unlink(self, cr, uid, ids, context=None):
+        ids = list(set(ids))
+        move_obj = self.pool.get('account.move')
+        for rec in self.browse(cr, uid, ids, context=context):
+            move_ids = []
+            for line in rec.line_id:
+                if line.move_id.writeoff and not line.move_id.id in move_ids:
+                    move_ids.append(line.move_id.id)
+            super(account_move_reconcile, self).unlink(cr, uid, [rec.id], context=context)
+            if move_ids:
+                move_obj.button_cancel(cr, uid, move_ids, context=context)
+                move_obj.unlink(cr, uid, move_ids, context=context)
+        return True
+

=== added file 'account_writeoff_autodelete/account_view.xml'
--- account_writeoff_autodelete/account_view.xml	1970-01-01 00:00:00 +0000
+++ account_writeoff_autodelete/account_view.xml	2014-05-17 13:57:41 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  account_writeoff_autodelete for OpenERP
+  Copyright (C) 2013-TODAY Akretion <http://www.akretion.com>.
+  The licence is in the file __openerp__.py
+-->
+
+<openerp>
+    <data>
+    
+        <!-- INHERITED VIEW FOR THE OBJECT : account_move_line -->
+
+        <record id="account_move_view_form" model="ir.ui.view">
+            <field name="name">account_writeoff_autodelete.account_move.view_form</field>
+            <field name="model">account.move</field>
+            <field name="inherit_id" ref="account.view_move_form" />
+            <field eval="16" name="priority"/>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <field name="ref" position="after">
+                    <field name="writeoff" readonly="1"
+                           attrs="{'invisible': [('writeoff','=', False)]}"/>
+                </field>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added directory 'account_writeoff_autodelete/patch'
=== added file 'account_writeoff_autodelete/patch/account_move_line.patch'
--- account_writeoff_autodelete/patch/account_move_line.patch	1970-01-01 00:00:00 +0000
+++ account_writeoff_autodelete/patch/account_move_line.patch	2014-05-17 13:57:41 +0000
@@ -0,0 +1,13 @@
+=== modified file 'account/account_move_line.py'
+--- account/account_move_line.py	2012-09-06 14:35:17 +0000
++++ account/account_move_line.py	2013-07-22 15:40:38 +0000
+@@ -912,7 +912,7 @@
+                 'date':date,
+                 'state': 'draft',
+                 'line_id': writeoff_lines
+-            })
++            }, context=context)
+ 
+             writeoff_line_ids = self.search(cr, uid, [('move_id', '=', writeoff_move_id), ('account_id', '=', account_id)])
+             if account_id == writeoff_acc_id:
+


References