← Back to team overview

clearcorp team mailing list archive

[Merge] lp:~rr.clearcorp/openerp-costa-rica/6.1-l10n_cr_exchange_rates into lp:openerp-costa-rica/6.1

 

Ronald Rubi has proposed merging lp:~rr.clearcorp/openerp-costa-rica/6.1-l10n_cr_exchange_rates into lp:openerp-costa-rica/6.1.

Requested reviews:
  CLEARCORP drivers (clearcorp-drivers)

For more details, see:
https://code.launchpad.net/~rr.clearcorp/openerp-costa-rica/6.1-l10n_cr_exchange_rates/+merge/177492

[ADD] Add module l10n_cr_exchange_rates
-- 
https://code.launchpad.net/~rr.clearcorp/openerp-costa-rica/6.1-l10n_cr_exchange_rates/+merge/177492
Your team CLEARCORP development team is subscribed to branch lp:openerp-costa-rica/6.1.
=== added directory 'l10n_cr_exchange_rates'
=== added file 'l10n_cr_exchange_rates/__init__.py'
--- l10n_cr_exchange_rates/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/__init__.py	2013-07-29 23:00:35 +0000
@@ -0,0 +1,24 @@
+# -*- 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 l10n_cr_exchange_rates
+import wizard

=== added file 'l10n_cr_exchange_rates/__openerp__.py'
--- l10n_cr_exchange_rates/__openerp__.py	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/__openerp__.py	2013-07-29 23:00:35 +0000
@@ -0,0 +1,51 @@
+# -*- 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" : 'l10n_cr_exchange_rates',
+    "version" : '1.0',
+    "author" : 'CLEARCORP S.A',
+    'complexity': 'normal',
+    "description": """
+l10n_cr_exchange_rates
+    """,
+    "category": 'Accounting & Finance',
+    "sequence": 4,
+    "website" : "http://clearcorp.co.cr";,
+    "images" : [],
+    "icon" : False,
+    "depends" : [
+                    "account", 
+                    "base_import_exchange_rates", 
+                    "res_currency_sequence",
+                ],
+    "init_xml" : [],
+    "demo_xml" : [],
+    "update_xml" : [
+                    "l10n_cr_exchange_rates_view.xml",
+                    "wizard/l10n_cr_exchange_rates_wizard.xml",
+                ],
+    "test" : [],
+    "auto_install": False,
+    "application": False,
+    "installable": True,
+}

=== added directory 'l10n_cr_exchange_rates/i18n'
=== added symlink 'l10n_cr_exchange_rates/i18n/es.po'
=== target is u'es_CR.po'
=== added file 'l10n_cr_exchange_rates/i18n/es_CR.po'
--- l10n_cr_exchange_rates/i18n/es_CR.po	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/i18n/es_CR.po	2013-07-29 23:00:35 +0000
@@ -0,0 +1,183 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* l10n_cr_exchange_rates
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-07-25 21:36+0000\n"
+"PO-Revision-Date: 2013-07-25 21:36+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: l10n_cr_exchange_rates
+#: constraint:account.move:0
+msgid "You can not create more than one move per period on centralized journal"
+msgstr "No puede crear más de un asiento por periodo en un diario centralizado"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.move.line:0
+msgid "Company must be the same for its related account and period."
+msgstr "La compañía debe ser la misma para su cuenta y periodos relacionados"
+
+#. module: l10n_cr_exchange_rates
+#: model:ir.model,name:l10n_cr_exchange_rates.model_generate_exchange_rates_wizard
+msgid "generate.exchange.rates.wizard"
+msgstr "generate.exchange.rates.wizard"
+
+#. module: l10n_cr_exchange_rates
+#: sql_constraint:account.account:0
+msgid "The code of the account must be unique per company !"
+msgstr "¡El código de la cuenta debe ser único por compañía!"
+
+#. module: l10n_cr_exchange_rates
+#: field:account.account,exchange_rate_adjustment:0
+msgid "Exchange rate adjustment"
+msgstr "Ajuste de la tasa de cambio"
+
+#. module: l10n_cr_exchange_rates
+#: help:account.move.line,amount_exchange_rate:0
+msgid "The amount of exchange rate."
+msgstr "El monto de tipo de cambio."
+
+#. module: l10n_cr_exchange_rates
+#: view:generate.exchange.rates.wizard:0
+msgid "This wizard will generates an move about exchange rate of the moves that belong to the selected period."
+msgstr "Este asistente genera un asiento sobre el tipo de cambio de los asientos que pertenecen al período seleccionado."
+
+#. module: l10n_cr_exchange_rates
+#: field:generate.exchange.rates.wizard,journal_id:0
+msgid "Journal"
+msgstr "Diario"
+
+#. module: l10n_cr_exchange_rates
+#: view:generate.exchange.rates.wizard:0
+#: model:ir.actions.act_window,name:l10n_cr_exchange_rates.action_generate_exchange_rates_wizard
+#: model:ir.ui.menu,name:l10n_cr_exchange_rates.menu_generate_exchange_rates_wizard
+msgid "Generate move exchange rate adjustment"
+msgstr "Generar asiento de ajuste cambiario"
+
+#. module: l10n_cr_exchange_rates
+#: model:ir.model,name:l10n_cr_exchange_rates.model_account_move_line
+msgid "Journal Items"
+msgstr "Apuntes contables"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.move.line:0
+msgid "You can not create journal items on an account of type view."
+msgstr "No puede crear asientos en una cuenta de tipo vista"
+
+#. module: l10n_cr_exchange_rates
+#: help:account.move.line,amount_base_import_exchange_rate:0
+msgid "Exchange rate in the system."
+msgstr "Tipo de cambio en el sistema."
+
+#. module: l10n_cr_exchange_rates
+#: model:ir.model,name:l10n_cr_exchange_rates.model_account_account
+msgid "Account"
+msgstr "Cuenta"
+
+#. module: l10n_cr_exchange_rates
+#: view:generate.exchange.rates.wizard:0
+msgid "Compute"
+msgstr "Crear"
+
+#. module: l10n_cr_exchange_rates
+#: help:generate.exchange.rates.wizard,journal_id:0
+#: help:generate.exchange.rates.wizard,period_id:0
+msgid "Choose the journal for the move automatically generated"
+msgstr "Elija el diario para el asiento generado automáticamente"
+
+#. module: l10n_cr_exchange_rates
+#: field:account.move.line,amount_base_import_exchange_rate:0
+msgid "Base amount exchange rate"
+msgstr "Monto base del tipo de cambio"
+
+#. module: l10n_cr_exchange_rates
+#: view:generate.exchange.rates.wizard:0
+msgid "Select the options do you need"
+msgstr "Seleccione las opciones que necesita"
+
+#. module: l10n_cr_exchange_rates
+#: sql_constraint:account.move.line:0
+msgid "Wrong credit or debit value in accounting entry !"
+msgstr "¡Valor haber o debe erróneo en el asiento contable!"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.move.line:0
+msgid "You can not create journal items on closed account."
+msgstr "No puede crear asientos en cuentas cerradas"
+
+#. module: l10n_cr_exchange_rates
+#: model:ir.model,name:l10n_cr_exchange_rates.model_account_move
+msgid "Account Entry"
+msgstr "Asiento contable"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.account:0
+msgid "Error ! You can not create recursive accounts."
+msgstr "¡Error! No se pueden crear cuentas recursivas."
+
+#. module: l10n_cr_exchange_rates
+#: field:generate.exchange.rates.wizard,reference:0
+msgid "Reference"
+msgstr "Referencia"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.account:0
+msgid "Configuration Error! \n"
+"You can not select an account type with a deferral method different of \"Unreconciled\" for accounts with internal type \"Payable/Receivable\"! "
+msgstr "¡Error de configuración! \n"
+"¡No se puede seleccionar un tipo de cuenta con un método diferente de aplazamiento \"no reconciliadas\" para las cuentas con el tipo interno \"por pagar / por cobrar\"! "
+
+#. module: l10n_cr_exchange_rates
+#: field:account.move.line,amount_exchange_rate:0
+msgid "Amount of exchange rate"
+msgstr "Importe de tipo de cambio"
+
+#. module: l10n_cr_exchange_rates
+#: field:generate.exchange.rates.wizard,period_id:0
+msgid "Period"
+msgstr "Período"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.move.line:0
+msgid "The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal."
+msgstr "La cuenta seleccionada en su asiento fuerza a tener una moneda secundaria. Debería eliminar la moneda secundaria de la cuenta o asignar al diario una vista multi-moneda"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.move.line:0
+msgid "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
+msgstr "¡La fecha de su asiento no está en el periodo definido! Usted debería cambiar la fecha o borar esta restricción del diario."
+
+#. module: l10n_cr_exchange_rates
+#: help:account.account,exchange_rate_adjustment:0
+msgid "Choose if the account needed an adjusted exchange rate"
+msgstr "Elija si la cuenta requiere ajuste de tipo de cambio"
+
+#. module: l10n_cr_exchange_rates
+#: constraint:account.account:0
+msgid "Configuration Error! \n"
+"You can not define children to an account with internal type different of \"View\"! "
+msgstr "¡Error de configuración! "
+
+#. module: l10n_cr_exchange_rates
+#: view:generate.exchange.rates.wizard:0
+msgid "Cancel"
+msgstr "Cancelar"
+
+#. module: l10n_cr_exchange_rates
+#: code:addons/l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.py:51
+#, python-format
+msgid "Created Account Moves"
+msgstr "Asientos contables creados"
+
+#. module: l10n_cr_exchange_rates
+#: field:account.move.line,adjustment:0
+msgid "Adjustment"
+msgstr "Ajuste"

=== added file 'l10n_cr_exchange_rates/l10n_cr_exchange_rates.py'
--- l10n_cr_exchange_rates/l10n_cr_exchange_rates.py	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/l10n_cr_exchange_rates.py	2013-07-29 23:00:35 +0000
@@ -0,0 +1,186 @@
+# -*- 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
+from tools.translate import _
+
+class AccountAccount(osv.osv):
+    _name = "account.account"
+    _inherit = "account.account"
+    
+    _columns = {
+        'exchange_rate_adjustment': fields.boolean('Exchange rate adjustment', help="Choose if the account needed an adjusted exchange rate"),
+    }
+    
+class AccountMoveLine(osv.osv):
+    _name = "account.move.line"
+    _inherit = "account.move.line"
+    
+    def _amount_exchange_rate(self, cr, uid, ids, field_names, args, context=None):
+        """
+           This function returns an amount of exchange rate base in the debit/credit and amount_currency,
+           and returns an amount of exchange rate of the day.
+        """
+        res = {}
+        if context is None:
+            context = {}
+        res_currency_obj = self.pool.get('res.currency')
+        res_currency_rate_obj = self.pool.get('res.currency.rate')
+        res_users_obj = self.pool.get('res.users')
+        
+        res_user = res_users_obj.browse(cr, uid, uid, context=context)
+        company_currency = res_user.company_id.currency_id
+        
+        lines = self.browse(cr, uid, ids, context=context)
+        for move_line in lines:
+            res[move_line.id] = {
+                'amount_exchange_rate': 0.0,
+                'amount_base_import_exchange_rate': 0.0,
+            }
+
+            if not move_line.currency_id or move_line.amount_currency == 0:
+                continue
+            if move_line.debit and move_line.debit > 0.00:
+                sign = move_line.amount_currency < 0 and -1 or 1
+                result = sign * move_line.debit / move_line.amount_currency
+                res[move_line.id]['amount_exchange_rate'] = res_currency_obj.round(cr, uid, move_line.currency_id, result) or result
+            elif move_line.credit and move_line.credit > 0.00:
+                sign = move_line.amount_currency < 0 and -1 or 1
+                result = sign * move_line.credit / move_line.amount_currency
+                res[move_line.id]['amount_exchange_rate'] = res_currency_obj.round(cr, uid, move_line.currency_id, result) or result
+            res[move_line.id]['amount_base_import_exchange_rate'] = res_currency_obj.get_exchange_rate(cr, uid, move_line.currency_id, company_currency, move_line.date, context)
+        return res
+    
+    _columns = {
+        'amount_exchange_rate': fields.function(_amount_exchange_rate, string='Amount of exchange rate', multi="residual", help="The amount of exchange rate."),
+        'amount_base_import_exchange_rate': fields.function(_amount_exchange_rate, string='Base amount exchange rate', multi="residual", help="Exchange rate in the system."),
+        'adjustment': fields.many2one('account.move.line', 'Adjustment'),
+    }
+    
+    def copy(self, cr, uid, id, default={}, context=None):
+        default.update({
+            'adjustment':False,
+        })
+
+class AccountMove(osv.osv):
+    _name = "account.move"
+    _inherit = "account.move"
+    
+    def get_balance_amount(self, cr, uid, id, context):
+        cr.execute( 'SELECT SUM(debit-credit) '\
+                    'FROM account_move_line '\
+                    'WHERE move_id = %s ', (id,))
+        result = cr.fetchall()
+        return result[0][0] or 0.00
+    
+    def generate_adjustment_move(self, cr, uid, reference, journal, period, context=None):
+        move_line_obj = self.pool.get('account.move.line')
+        res_currency_obj = self.pool.get('res.currency')
+        res_currency_rate_obj = self.pool.get('res.currency.rate')
+            
+        res_user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
+        company_currency = res_user.company_id.currency_id
+        name = reference + " " + period.name
+        
+        move_created = {
+                    'ref': name,
+                    'journal_id': journal.id,
+                    'period_id': period.id,
+                    'to_check': False,
+                    'company_id': res_user.company_id.id,
+                    }
+        move_created_id = self.create(cr, uid, move_created)
+        
+        total_credit = 0.00
+        total_debit = 0.00
+        exchange_rate_end_period = res_currency_obj._current_rate(cr, uid, [company_currency.id], period.date_stop, arg=None, context=context)[company_currency.id]
+        
+        account_ids = self.pool.get('account.account').search(cr, uid, [('exchange_rate_adjustment', '=', True)], context=context)
+        line_ids = move_line_obj.search(cr, uid, [('currency_id','!=',None), ('period_id','=',period.id), ('amount_currency','!=',0), ('account_id','in',account_ids), ('adjustment','=',None)], context=context)
+        lines = move_line_obj.browse(cr, uid, line_ids, context=context)
+        
+    
+        for line in lines:
+            if line.move_id.state == 'draft' or not line.amount_currency:
+                continue
+            
+            sign_amount_currency = line.amount_currency < 0 and -1 or 1
+            line_difference = 0
+            if line.credit != 0:
+                line_difference = sign_amount_currency * line.amount_currency * exchange_rate_end_period - line.credit
+            elif line.debit != 0:
+                line_difference = sign_amount_currency * line.amount_currency * exchange_rate_end_period - line.debit
+            
+            sign = line_difference < 0 and -1 or 1
+            if line_difference == 0:
+                continue
+            elif line.credit == 0 and exchange_rate_end_period > line.amount_exchange_rate or line.debit == 0 and exchange_rate_end_period < line.amount_exchange_rate:
+                credit = 0.00
+                debit = sign * line_difference
+            else:
+                credit = sign * line_difference
+                debit = 0.00
+            
+            move_line = {
+                         'name': line.name or '',
+                         'ref': line.ref or '',
+                         'debit': debit,
+                         'credit': credit,
+                         'account_id':line.account_id.id,
+                         'move_id': move_created_id,
+                         'period_id': line.period_id.id,
+                         'journal_id': line.journal_id.id,
+                         'partner_id': line.partner_id.id,
+                         'currency_id': line.account_id.currency_id.id,
+                         'amount_currency': 0.00,
+                         'state': 'valid',
+                         'company_id': line.company_id.id,
+                         }
+            line_created_id = move_line_obj.create(cr, uid, move_line)
+            move_line_obj.write(cr, uid, [line.id], {'adjustment' : line_created_id})
+    
+        amount = self.get_balance_amount(cr, uid, move_created_id, context=context)
+        if amount > 0:
+            account_id = res_user.company_id.expense_currency_exchange_account_id.id
+            credit = amount
+            debit = 0.00
+        else:
+            account_id = res_user.company_id.income_currency_exchange_account_id.id
+            credit = 0.00
+            debit = amount * -1
+        move_line = {
+                             'name': name,
+                             'ref': name,
+                             'debit': debit,
+                             'credit': credit,
+                             'account_id': account_id,
+                             'move_id': move_created_id,
+                             'period_id': period.id,
+                             'journal_id': journal.id,
+                             'currency_id': False,
+                             'amount_currency': 0.00,
+                             'state': 'valid',
+                             'company_id': res_user.company_id.id,
+                             }
+        line_created_id = move_line_obj.create(cr, uid, move_line)
+        return move_created_id
+    

=== added file 'l10n_cr_exchange_rates/l10n_cr_exchange_rates_view.xml'
--- l10n_cr_exchange_rates/l10n_cr_exchange_rates_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/l10n_cr_exchange_rates_view.xml	2013-07-29 23:00:35 +0000
@@ -0,0 +1,61 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<openerp>
+    <data>
+        
+        <!--
+        ======================================
+        account.account
+        ======================================
+        -->
+        
+        <record id="account_view_form" model="ir.ui.view">
+            <field name="name">account.view.form</field>
+            <field name="model">account.account</field>
+            <field name="inherit_id" ref="account.view_account_form"/>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <field name="currency_mode" position="after">
+                    <field name="exchange_rate_adjustment" groups="base.group_extended"/>
+                </field>
+            </field>
+        </record>
+        
+        <!--
+        ======================================
+        account.move.line
+        ======================================
+        -->
+        
+        <record model = "ir.ui.view" id = "view_move_line_form_l10n_cr">
+            <field name = "name">view.move.line.form.l10n.cr</field>
+            <field name = "model">account.move.line</field>
+            <field name = "type">form</field>
+            <field name="inherit_id" ref="account.view_move_line_form"/>
+            <field name = "arch" type = "xml">
+                <data>
+                    <field name = "amount_currency" position = "after">
+                        <field name = "amount_exchange_rate"/>
+                        <field name = "amount_base_import_exchange_rate"/>
+                    </field>
+                </data>
+            </field>
+        </record>
+        
+        <record model = "ir.ui.view" id = "view_move_line_form2_l10n_cr">
+            <field name = "name">view.move.line.form2.l10n.cr</field>
+            <field name = "model">account.move.line</field>
+            <field name = "type">form</field>
+            <field name="inherit_id" ref="account.view_move_line_form2"/>
+            <field name = "arch" type = "xml">
+                <data>
+                    <field name = "amount_currency" position = "after">
+                        <field name = "amount_exchange_rate"/>
+                        <field name = "amount_base_import_exchange_rate"/>
+                    </field>
+                </data>
+            </field>
+        </record>
+        
+    </data>
+</openerp>
+

=== added directory 'l10n_cr_exchange_rates/wizard'
=== added file 'l10n_cr_exchange_rates/wizard/__init__.py'
--- l10n_cr_exchange_rates/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/wizard/__init__.py	2013-07-29 23:00:35 +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 l10n_cr_exchange_rates_wizard

=== added file 'l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.py'
--- l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.py	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.py	2013-07-29 23:00:35 +0000
@@ -0,0 +1,62 @@
+# -*- 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
+from tools.translate import _
+
+class GenerateExchangeRatesWizard(osv.osv_memory):
+    _name = "generate.exchange.rates.wizard"
+    _description = "generate.exchange.rates.wizard"
+    _columns = {
+        'reference': fields.char('Reference', size=256, required=True),
+        'journal_id': fields.many2one('account.journal', 'Journal', required=True, help="Choose the journal for the move automatically generated"),
+        'period_id': fields.many2one('account.period', 'Period', required=True, help="Choose the journal for the move automatically generated"),
+    }
+   
+    def _get_period(self, cr, uid, context=None):
+        periods = self.pool.get('account.period').find(cr, uid)
+        if periods:
+            return periods[0]
+        return False
+ 
+    _defaults = {
+        'period_id': _get_period,
+    }
+
+    def generate_exchange_rates(self, cr, uid, ids, context):
+        account_move_obj = self.pool.get('account.move')
+        data = self.browse(cr, uid, ids, context=context)
+        reference = data[0].reference
+        journal = data[0].journal_id
+        period = data[0].period_id
+        created_move_id = account_move_obj.generate_adjustment_move(cr, uid, reference, journal, period, context=context)
+        return {
+            'name': _('Created Account Moves'),
+            'view_type': 'form',
+            'view_mode': 'tree,form',
+            'res_model': 'account.move',
+            'view_id': False,
+            'domain': "[('id','=',"+str(created_move_id)+")]",
+            'type': 'ir.actions.act_window',
+        }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.xml'
--- l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.xml	1970-01-01 00:00:00 +0000
+++ l10n_cr_exchange_rates/wizard/l10n_cr_exchange_rates_wizard.xml	2013-07-29 23:00:35 +0000
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="view_generate_exchange_rates_wizard" model="ir.ui.view">
+            <field name="name">view.generate.exchange.rates.wizard</field>
+            <field name="model">generate.exchange.rates.wizard</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                    <form string="Generate move exchange rate adjustment">
+                        <separator string="Select the options do you need" colspan="4"/>
+                        <label string="This wizard will generates an move about exchange rate of the moves that belong to the selected period." colspan="4"/>
+                        <newline/>
+                        <field name="reference" colspan="4"/>
+                        <field name="journal_id"/>
+                        <field name="period_id"/>
+                        <separator colspan="4"/>
+                        <group colspan="4" col="6">
+                           <label string="" colspan="2"/>
+                           <button icon="gtk-cancel" special="cancel" string="Cancel"/>
+                           <button icon="gtk-execute" string="Compute" name="generate_exchange_rates" type="object"/>
+                        </group>
+                     </form>
+                   </field>
+        </record>
+
+        <record id="action_generate_exchange_rates_wizard" model="ir.actions.act_window">
+            <field name="name">Generate move exchange rate adjustment</field>
+            <field name="res_model">generate.exchange.rates.wizard</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="view_id" ref="view_generate_exchange_rates_wizard"/>
+            <field name="target">new</field>
+        </record>
+
+        <menuitem action="action_generate_exchange_rates_wizard"
+            id="menu_generate_exchange_rates_wizard"
+            parent="account.menu_finance_recurrent_entries" />
+
+    </data>
+</openerp>


Follow ups