clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00852
lp:~rr.clearcorp/openerp-ccorp-addons/6.1-res_currency_sequence into lp:openerp-ccorp-addons/6.1
Ronald Rubi has proposed merging lp:~rr.clearcorp/openerp-ccorp-addons/6.1-res_currency_sequence into lp:openerp-ccorp-addons/6.1.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~rr.clearcorp/openerp-ccorp-addons/6.1-res_currency_sequence/+merge/177493
[ADD] Add module res_currency_sequence, add dependence base_import_exchange_rates
--
https://code.launchpad.net/~rr.clearcorp/openerp-ccorp-addons/6.1-res_currency_sequence/+merge/177493
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons/6.1.
=== modified file 'base_import_exchange_rates/__terp__.py'
--- base_import_exchange_rates/__terp__.py 2013-04-01 17:37:08 +0000
+++ base_import_exchange_rates/__terp__.py 2013-07-29 23:02:28 +0000
@@ -54,13 +54,15 @@
""",
- 'depends': ['account'],
+ 'depends': [
+ 'account',
+ 'res_currency_sequence',
+ ],
'init_xml': ['security/security.xml'],
'demo_xml': [],
'update_xml': [
'currency_rate_update.xml',
'company_view.xml',
- 'res_currency_view.xml',
],
'license': 'Other OSI approved licence',
'installable': True,
=== modified file 'base_import_exchange_rates/currency_rate_update.py'
--- base_import_exchange_rates/currency_rate_update.py 2013-04-01 18:10:21 +0000
+++ base_import_exchange_rates/currency_rate_update.py 2013-07-29 23:02:28 +0000
@@ -153,9 +153,12 @@
def run_currency_update(self, cr, uid):
"update currency at the given frequence"
- factory = Currency_getter_factory()
curr_obj = self.pool.get('res.currency')
rate_obj = self.pool.get('res.currency.rate')
+
+ factory = Currency_getter_factory()
+ res_currency_base_id = curr_obj.search(cr, uid, [('base', '=', True)])
+ res_currency_base = curr_obj.browse(cr, uid, res_currency_base_id)[0]
companies = self.pool.get('res.company').search(cr, uid, [])
for comp in self.pool.get('res.company').browse(cr, uid, companies):
##the multi company currency can beset or no so we handle
@@ -185,7 +188,7 @@
rate_ids = rate_obj.search(cr, uid, [('currency_id','=',curr.id),('name','=',name)])
if not len(rate_ids):
rate = float(rate)
- if curr.import_inverted:
+ if curr.sequence > res_currency_base.sequence:
rate = 1.0/float(rate)
vals = {'currency_id': curr.id, 'rate': rate, 'name': name}
=== removed file 'base_import_exchange_rates/res_currency.py'
--- base_import_exchange_rates/res_currency.py 2013-04-01 17:37:08 +0000
+++ base_import_exchange_rates/res_currency.py 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# base_currency_symbol.py
-# base_currency_symbol
-# First author: Carlos Vásquez <carlos.vasquez@xxxxxxxxxxxxxxx> (ClearCorp S.A.)
-# Copyright (c) 2010-TODAY ClearCorp S.A. (http://clearcorp.co.cr). All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without modification, are
-# permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice, this list of
-# conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice, this list
-# of conditions and the following disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
-# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and documentation are those of the
-# authors and should not be interpreted as representing official policies, either expressed
-# or implied, of ClearCorp S.A..
-#
-##############################################################################
-
-from osv import osv,fields
-
-class res_currency(osv.osv):
-
- _inherit = 'res.currency'
-
- _columns = {
- #True if need to change the rate= 1/rate
- 'import_inverted': fields.boolean('Import Inverted'),
- }
-res_currency()
=== removed file 'base_import_exchange_rates/res_currency_view.xml'
--- base_import_exchange_rates/res_currency_view.xml 2013-04-01 17:37:08 +0000
+++ base_import_exchange_rates/res_currency_view.xml 1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
- <data>
- <!--
- Resource: res.currency
- -->
- <record id="view_currency_form_rate" model="ir.ui.view">
- <field name="name">res.currency.rate_update</field>
- <field name="model">res.currency</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="base.view_currency_form"/>
- <field name="arch" type="xml">
- <field name="accuracy" position="after">
- <field name="import_inverted"/>
- </field>
- </field>
- </record>
- </data>
-</openerp>
=== added directory 'res_currency_sequence'
=== added file 'res_currency_sequence/__init__.py'
--- res_currency_sequence/__init__.py 1970-01-01 00:00:00 +0000
+++ res_currency_sequence/__init__.py 2013-07-29 23:02:28 +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 res_currency_sequence
=== added file 'res_currency_sequence/__openerp__.py'
--- res_currency_sequence/__openerp__.py 1970-01-01 00:00:00 +0000
+++ res_currency_sequence/__openerp__.py 2013-07-29 23:02:28 +0000
@@ -0,0 +1,46 @@
+# -*- 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" : 'ResCurrencySequence',
+ "version" : '1.0',
+ "author" : 'CLEARCORP S.A.',
+ #easy, normal, expert
+ 'complexity': 'normal',
+ "description": """
+ res_currency_sequence
+ """,
+ "category": 'Accounting & Finance',
+ "sequence": 4,
+ "website" : "http://clearcorp.co.cr",
+ "images" : [],
+ "icon" : False,
+ "depends" : ["base",],
+ "init_xml" : [],
+ "update_xml" : ["res_currency_sequence_view.xml",],
+ "test" : [],
+ "auto_install": False,
+ "application": False,
+ "installable": True,
+ 'license': 'AGPL-3',
+}
=== added directory 'res_currency_sequence/i18n'
=== added symlink 'res_currency_sequence/i18n/es.po'
=== target is u'es_CR.po'
=== added file 'res_currency_sequence/i18n/es_CR.po'
--- res_currency_sequence/i18n/es_CR.po 1970-01-01 00:00:00 +0000
+++ res_currency_sequence/i18n/es_CR.po 2013-07-29 23:02:28 +0000
@@ -0,0 +1,42 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * res_currency_sequence
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-07-25 21:04+0000\n"
+"PO-Revision-Date: 2013-07-25 21:04+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: res_currency_sequence
+#: model:ir.model,name:res_currency_sequence.model_res_currency
+msgid "Currency"
+msgstr "Moneda"
+
+#. module: res_currency_sequence
+#: sql_constraint:res.currency:0
+msgid "Sequence must be unique per currency!"
+msgstr "La secuencia debe ser única por moneda!"
+
+#. module: res_currency_sequence
+#: help:res.currency,sequence:0
+msgid "Use to arrange calculation sequence"
+msgstr "Se utiliza para organizar la secuencia de cálculo"
+
+#. module: res_currency_sequence
+#: sql_constraint:res.currency:0
+msgid "The currency code must be unique per company!"
+msgstr "¡El código de moneda debe ser único por compañía!"
+
+#. module: res_currency_sequence
+#: field:res.currency,sequence:0
+msgid "Sequence"
+msgstr "Secuencia"
+
=== added file 'res_currency_sequence/res_currency_sequence.py'
--- res_currency_sequence/res_currency_sequence.py 1970-01-01 00:00:00 +0000
+++ res_currency_sequence/res_currency_sequence.py 2013-07-29 23:02:28 +0000
@@ -0,0 +1,68 @@
+# -*- 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 ResCurrency(osv.osv):
+ _name = "res.currency"
+ _inherit = "res.currency"
+
+ _columns = {
+ 'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence', select=True),
+ }
+
+ _defaults = {
+ 'sequence': 0,
+ }
+
+ _sql_constraints = [
+ ('res_currency_sequence', 'unique(sequence)', 'Sequence must be unique per currency!'),
+ ]
+
+ _order = 'sequence'
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ default = default or {}
+ default.update({
+ 'sequence': None,
+ })
+ return super(ResCurrency, self).copy(cr, uid, id, default, context)
+
+ def get_exchange_rate(self, cr, uid, res_currency_initial, res_currency_finally, name, context=None):
+ """
+ :param name: date of exchange rate
+ """
+ res_currency_rate_obj = self.pool.get('res.currency.rate')
+ result = 0.00
+
+ res_currency_base_id = self.search(cr, uid, [('base', '=', True)])
+ res_currency_base = self.browse(cr, uid, res_currency_base_id)[0]
+
+ if res_currency_initial.id == res_currency_base.id:
+ exchange_rate_dict = self.pool.get('res.currency')._current_rate(cr, uid, [res_currency_finally.id], name, arg=None, context=context)
+ result = exchange_rate_dict[res_currency_finally.id]
+ else:
+ currency_rate_initial = self.pool.get('res.currency')._current_rate(cr, uid, [res_currency_initial.id], name, arg=None, context=context)[res_currency_initial.id]
+ currency_rate_finally = self.pool.get('res.currency')._current_rate(cr, uid, [res_currency_finally.id], name, arg=None, context=context)[res_currency_finally.id]
+ result = currency_rate_initial * currency_rate_finally
+ return result
=== added file 'res_currency_sequence/res_currency_sequence_view.xml'
--- res_currency_sequence/res_currency_sequence_view.xml 1970-01-01 00:00:00 +0000
+++ res_currency_sequence/res_currency_sequence_view.xml 2013-07-29 23:02:28 +0000
@@ -0,0 +1,41 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<openerp>
+ <data>
+
+ <!--
+ ======================================
+ Res Currency
+ ======================================
+ -->
+
+ <record model = "ir.ui.view" id = "view_currency_tree_sequence">
+ <field name = "name">view.currency.tree.sequence</field>
+ <field name = "model">res.currency</field>
+ <field name = "type">tree</field>
+ <field name="inherit_id" ref="base.view_currency_tree"/>
+ <field name = "arch" type = "xml">
+ <data>
+ <field name = "active" position = "after">
+ <field name = "sequence" invisible="1"/>
+ </field>
+ </data>
+ </field>
+ </record>
+
+ <record model = "ir.ui.view" id = "view_currency_form_sequence">
+ <field name = "name">view.currency.form.sequence</field>
+ <field name = "model">res.currency</field>
+ <field name = "type">form</field>
+ <field name="inherit_id" ref="base.view_currency_form"/>
+ <field name = "arch" type = "xml">
+ <data>
+ <field name = "active" position = "after">
+ <field name = "sequence" />
+ </field>
+ </data>
+ </field>
+ </record>
+
+ </data>
+</openerp>
+
Follow ups