clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00208
lp:~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature into lp:openerp-ccorp-addons
Ronald Rubi has proposed merging lp:~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature into lp:openerp-ccorp-addons.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature/+merge/113468
Add module account_voucher_reverse
--
https://code.launchpad.net/~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature/+merge/113468
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== added directory 'account_voucher_reverse'
=== added file 'account_voucher_reverse/__init__.py'
--- account_voucher_reverse/__init__.py 1970-01-01 00:00:00 +0000
+++ account_voucher_reverse/__init__.py 2012-07-04 23:00:26 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# 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_voucher_reverse
=== added file 'account_voucher_reverse/__openerp__.py'
--- account_voucher_reverse/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_voucher_reverse/__openerp__.py 2012-07-04 23:00:26 +0000
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# 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 Voucher Reverse",
+ "version" : '1.0',
+ "author" : 'CLEARCORP S.A.',
+ 'complexity': 'normal',
+ "description": """
+Module for reverse account vouchers
+ """,
+ "category": 'Accounting & Finance',
+ "sequence": 4,
+ "website" : "http://clearcorp.co.cr",
+ "images" : [],
+ "icon" : False,
+ "depends" : ["account_voucher"],
+ "init_xml" : [],
+ "demo_xml" : [],
+ "update_xml" : [
+ "account_voucher_reverse_view.xml",
+ "workflow/account_voucher_reverse_workflow.xml",
+ ],
+ "test" : [],
+ "auto_install": False,
+ "application": False,
+ "installable": True,
+ 'license': 'AGPL-3',
+}
=== added file 'account_voucher_reverse/account_voucher_reverse.py'
--- account_voucher_reverse/account_voucher_reverse.py 1970-01-01 00:00:00 +0000
+++ account_voucher_reverse/account_voucher_reverse.py 2012-07-04 23:00:26 +0000
@@ -0,0 +1,141 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by CLEARCORP S.A.
+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+# 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 osv import osv, fields
+
+class account_voucher_reverse(osv.osv):
+ _name = 'account.voucher'
+ _inherit = 'account.voucher'
+
+ _columns = {
+ 'state':fields.selection(
+ [('draft','Draft'),
+ ('proforma','Pro-forma'),
+ ('posted','Posted'),
+ ('reverse','Reverse'),
+ ('cancel','Cancelled')
+ ], 'State', readonly=True, size=32,
+ help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Voucher. \
+ \n* The \'Pro-forma\' when voucher is in Pro-forma state,voucher does not have an voucher number. \
+ \n* The \'Posted\' state is used when user create voucher,a voucher number is generated and voucher entries are created in account \
+ \n* The \'Reverse\' state is used when user reverse voucher \
+ \n* The \'Cancelled\' state is used when user cancel voucher.'),
+ }
+
+ def reverse_voucher(self, cr, uid, ids, context=None):
+
+ self.write(cr, uid, ids, {'state' : 'reverse'}, context=context)
+
+ #To create a move reverse
+ self.account_voucher_move_reverse(cr, uid, ids, context=context)
+
+ return True
+
+ def account_voucher_move_reverse(self, cr, uid, ids, context=None):
+ # Initialize voucher variables and check if voucher has a move, a journal and an account
+ # If not, exit and return original result
+ voucher = self.browse(cr,uid,ids,context=context)[0]
+ if not voucher.move_id:
+ return False
+
+ original_move = voucher.move_id
+
+ if not original_move.line_id:
+ return False
+
+ move = {
+ 'name':'Reverse: ' + original_move.name,
+ 'ref':original_move.ref,
+ 'journal_id':original_move.journal_id.id,
+ 'period_id':original_move.period_id.id,
+ 'to_check':False,
+ 'partner_id':original_move.partner_id.id,
+ 'date':original_move.date,
+ 'narration':original_move.narration,
+ 'company_id':original_move.company_id.id,
+ }
+ move_id = self.pool.get('account.move').create(cr, uid, move)
+
+ move_reconcile_obj = self.pool.get('account.move.reconcile')
+
+ lines = original_move.line_id
+ for line in lines:
+ move_line = {
+ 'name':line.name,
+ 'debit':line.credit,
+ 'credit':line.debit,
+ 'account_id':line.account_id.id,
+ 'move_id': move_id,
+ 'amount_currency':line.amount_currency * -1,
+ 'period_id':line.period_id.id,
+ 'journal_id':line.journal_id.id,
+ 'partner_id':line.partner_id.id,
+ 'currency_id':line.currency_id.id,
+ 'date_maturity':line.date_maturity,
+ 'date':line.date,
+ 'date_created':line.date_created,
+ 'state':'valid',
+ 'company_id':line.company_id.id,
+ }
+
+ line_created_id = self.pool.get('account.move.line').create(cr, uid, move_line)
+
+ if (original_move.journal_id.entry_posted):
+ self.pool.get('account.move').post(cr, uid, [move_id], context={})
+
+ if line.reconcile_id:
+ reconcile = move_reconcile_obj.browse(cr,uid,[line.reconcile_id.id],context=context)[0]
+ if len(reconcile.line_id) > 2:
+ self.pool.get('account.move.line').write(cr,uid,line.id,{'reconcile_id': False })
+ for line in reconcile.line_id:
+ self.pool.get('account.move.line').write(cr,uid,line.id,{'reconcile_id': False,'reconcile_partial_id':line.reconcile_id.id})
+ else:
+ move_reconcile_obj.unlink(cr,uid,[line.reconcile_id.id],context=context)
+
+ if line.reconcile_partial_id:
+ reconcile = move_reconcile_obj.browse(cr,uid,[line.reconcile_partial_id.id],context=context)[0]
+ if len(reconcile.line_partial_ids) > 2:
+ self.pool.get('account.move.line').write(cr,uid,line.id,{'reconcile_partial_id': False })
+ else:
+ move_reconcile_obj.unlink(cr,uid,[line.reconcile_partial_id.id],context=context)
+
+ if line.account_id.reconcile:
+ reconcile_id = self.pool.get('account.move.reconcile').create(cr, uid, {'type': 'Account Reverse'})
+ self.pool.get('account.move.line').write(cr,uid,[line.id],{'reconcile_id': reconcile_id})
+ self.pool.get('account.move.line').write(cr,uid,[line_created_id],{'reconcile_id': reconcile_id})
+
+ return True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
=== added file 'account_voucher_reverse/account_voucher_reverse_view.xml'
--- account_voucher_reverse/account_voucher_reverse_view.xml 1970-01-01 00:00:00 +0000
+++ account_voucher_reverse/account_voucher_reverse_view.xml 2012-07-04 23:00:26 +0000
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+ <record id="view_vendor_receipt_reverse_form" model="ir.ui.view">
+ <field name="name">account.voucher.receipt.reverse.form</field>
+ <field name="model">account.voucher</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/>
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr = "/form/group/field[@name='state']" position = "after">
+ <button name="reverse_voucher" string="Reverse" type="object" states="posted" invisible="context.get('line_type', False)" icon="STOCK_REVERT_TO_SAVED" confirm="Are you sure to reverse this record ?"/>
+ </xpath>
+ <xpath expr = "/form/notebook/page[@string='Journal Items']" position = "replace">
+ <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': ['|','|',('state','=','draft'),('state','=','proforma'),('state','=','cancel')]}">
+ <group col="6" colspan="4">
+ <field name="period_id"/>
+ <field name="audit"/>
+ </group>
+ <field name="number" colspan="4"/>
+ <field name="move_ids" colspan="4" nolabel="1" readonly="1">
+ <tree string="Journal Items">
+ <field name="move_id"/>
+ <field name="ref"/>
+ <field name="date"/>
+ <field name="statement_id"/>
+ <field name="partner_id"/>
+ <field name="account_id"/>
+ <field name="name"/>
+ <field name="debit"/>
+ <field name="credit"/>
+ <field name="state"/>
+ <field name="reconcile_id"/>
+ <field name="amount_currency"/>
+ <field name="currency_id"/>
+ </tree>
+ </field>
+ </page>
+ </xpath>
+ </data>
+ </field>
+ </record>
+
+ <record id="view_vendor_payment_reverse_form" model="ir.ui.view">
+ <field name="name">account.voucher.payment.reverse.form</field>
+ <field name="model">account.voucher</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"/>
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr = "/form/group/field[@name='state']" position = "after">
+ <button name="reverse_voucher" string="Reverse" type="object" states="posted" invisible="context.get('line_type', False)" icon="STOCK_REVERT_TO_SAVED" confirm="Are you sure to reverse this record ?"/>
+ </xpath>
+ <xpath expr = "/form/notebook/page[@string='Journal Items']" position = "replace">
+ <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': ['|','|',('state','=','draft'),('state','=','proforma'),('state','=','cancel')]}">
+ <group col="6" colspan="4">
+ <field name="period_id"/>
+ <field name="audit"/>
+ </group>
+ <field name="number" colspan="4"/>
+ <field name="move_ids" colspan="4" nolabel="1" readonly="1">
+ <tree string="Journal Items">
+ <field name="move_id"/>
+ <field name="ref"/>
+ <field name="date"/>
+ <field name="statement_id"/>
+ <field name="partner_id"/>
+ <field name="account_id"/>
+ <field name="name"/>
+ <field name="debit"/>
+ <field name="credit"/>
+ <field name="state"/>
+ <field name="reconcile_id"/>
+ <field name="amount_currency"/>
+ <field name="currency_id"/>
+ </tree>
+ </field>
+ </page>
+ </xpath>
+ </data>
+ </field>
+ </record>
+ </data>
+</openerp>
=== added directory 'account_voucher_reverse/workflow'
=== added file 'account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml'
--- account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml 1970-01-01 00:00:00 +0000
+++ account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml 2012-07-04 23:00:26 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+
+ <record id="act_reverse" model="workflow.activity">
+ <field name="wkf_id" ref="account_voucher.wkf"/>
+ <field name="name">reverse</field>
+ <field name="flow_stop">True</field>
+ <field name="action">reverse_voucher()</field>
+ <field name="kind">function</field>
+ </record>
+
+ <record id="account_voucher_done2reverse" model="workflow.transition">
+ <field name="act_from" ref="account_voucher.act_done" />
+ <field name="act_to" ref="act_reverse" />
+ <!-- <field name="group_id" ref="account.Accountant" /> -->
+ <field name="signal">reverse_voucher</field>
+ </record>
+
+ </data>
+</openerp>
Follow ups