diff --git a/xe_currency_converter/README.rst b/xe_currency_converter/README.rst new file mode 100644 index 000000000..226a13cca --- /dev/null +++ b/xe_currency_converter/README.rst @@ -0,0 +1,28 @@ +XE Currency Converter +===================== +* Convert currency rate based on company currency by using xe.com platform +* Start working at 5:00 am UTC + +Tech +==== +* [Python] - Models +* [XML] - Odoo views + +Installation +============ +- www.odoo.com/documentation/12.0/setup/install.html +- Install our custom addon + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + + +Developer +========= +* Developer: + odoo v12 Varsha Vivek + +Contacts +======== +* Cybrosys Technologies diff --git a/xe_currency_converter/__init__.py b/xe_currency_converter/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/xe_currency_converter/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/xe_currency_converter/__manifest__.py b/xe_currency_converter/__manifest__.py new file mode 100644 index 000000000..129a4d4d3 --- /dev/null +++ b/xe_currency_converter/__manifest__.py @@ -0,0 +1,19 @@ +{ + 'name': 'XE Currency Converter', + 'version': '12.0.1.0.0', + 'category': 'Accounting', + 'description': """Convert currency rate based on company currency by using xe.com platform""", + 'category': 'Accounting', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'maintainer': 'Cybrosys Techno Solutions', + 'depends': ['base', 'account'], + 'data': ['views/config_settings_views.xml', + 'views/service_cron.xml'], + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/xe_currency_converter/doc/RELEASE_NOTES.md b/xe_currency_converter/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..581f9ecda --- /dev/null +++ b/xe_currency_converter/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 20.06.2019 +#### Version 12.0.1.0.0 +##### ADD +- Initial Commit diff --git a/xe_currency_converter/models/__init__.py b/xe_currency_converter/models/__init__.py new file mode 100644 index 000000000..969d61542 --- /dev/null +++ b/xe_currency_converter/models/__init__.py @@ -0,0 +1 @@ +from . import config_settings diff --git a/xe_currency_converter/models/config_settings.py b/xe_currency_converter/models/config_settings.py new file mode 100644 index 000000000..0be11544f --- /dev/null +++ b/xe_currency_converter/models/config_settings.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +""" +Convert currency rate based on company currency by using xe.com platform +""" +import requests +from lxml import etree +from odoo import api, fields, models +from odoo.exceptions import UserError + + +class ResConfigSettings(models.TransientModel): + """List out the service provider for exchange the currency rate based on our company currency""" + _inherit = 'res.config.settings' + + currency_update = fields.Boolean(string='Live Currency Rate Update') + service_provider = fields.Selection(related="company_id.service_provider", readonly=False) + + @api.model + def get_values(self): + """get values from the fields""" + res = super(ResConfigSettings, self).get_values() + res.update( + currency_update=self.env['ir.config_parameter'].sudo().get_param('currency_update'), + service_provider=self.env['ir.config_parameter'].sudo().get_param('service_provider') + ) + return res + + @api.multi + def set_values(self): + """Set values in the fields""" + super(ResConfigSettings, self).set_values() + self.env['ir.config_parameter'].sudo().set_param('service_provider', self.service_provider) + self.env['ir.config_parameter'].sudo().set_param('currency_update', self.currency_update) + + def update_rate(self): + """Update the currency rate manually""" + self.ensure_one() + if self.company_id.service_provider != 'xe_com': + raise UserError("Please select a service provider. ") + + if not (self.company_id.currency_rate_updates()): + raise UserError('Unable to connect at this this time.' + 'Please try again later.') + + +class ResCompany(models.Model): + """This class generate the current currency rate from xe.com website""" + _inherit = 'res.company' + + service_provider = fields.Selection([ + ('xe_com', 'xe.com'), + ], string='Service', default='xe_com') + + @api.multi + def currency_rate_updates(self): + """This method is used to update all currencies given by the provider.""" + result = True + active_currencies = self.env['res.currency'].search([]) + for (service_provider, companies) in self.currency_provider().items(): + results = None + if service_provider == 'xe_com': + function = getattr(companies, service_provider + '_data') + results = function(active_currencies) + if service_provider != 'xe_com': + raise UserError("Unavailable currency rate web service.") + else: + companies.res_currency_rate(results) + + return result + + def currency_provider(self): + """Returns a dictionary the companies in self by currency + rate provider.""" + result = {} + for company in self: + if not company.service_provider: + continue + else: + result[company.service_provider] = company + return result + + def res_currency_rate(self, data): + """Generate the entries of currency rates for the company, + using the result of a function, given as parameter, to get the rates data.""" + res_currency = self.env['res.currency'] + currency_rate = self.env['res.currency.rate'] + for company in self: + currency_rate_info = data.get(company.currency_id.name, None) + if not currency_rate_info: + raise UserError(("Main currency %s is not supported by this service provider. " + "Choose another one.") % company.currency_id.name) + + base_currency = currency_rate_info[0] + for currency, (rate, date_rate) in data.items(): + value = rate/base_currency + currency_object = res_currency.search([('name', '=', currency)]) + existing_rate = currency_rate.search([('currency_id', '=', currency_object.id), + ('name', '=', date_rate), + ('company_id', '=', company.id)]) + if existing_rate: + existing_rate.rate = value + else: + currency_rate.create({'currency_id': currency_object.id, + 'rate': value, + 'name': date_rate, + 'company_id': company.id}) + + def xe_com_data(self, currencies): + """Import the currency rates data from the xe.com service provider. + As this provider does not have an API, here we directly extract exchange rate + from HTML.""" + + url = 'http://www.xe.com/currencytables/?from=%(currency_code)s&date=%(date)s' + today = fields.Date.today() + data = requests.request('GET', url % {'currency_code': 'INR', 'date': today}) + result = {} + available_currencies = currencies.mapped('name') + html_content = etree.fromstring(data.content, etree.HTMLParser()) + table_rate = html_content.find(".//table[@id='historicalRateTbl']/tbody") + for table_entry in list(table_rate): + if type( + table_entry) != etree._Comment: + code = table_entry.find('.//a').text + if code in available_currencies: + rate = float(table_entry.find( + "td[@class='historicalRateTable-rateHeader']").text) + result[code] = (rate, today) + return result + + @api.model + def cron_update(self): + """Update currency rate automatically by using cron job""" + update_company = self.env['res.company'].search([]) + update_company.currency_rate_updates() diff --git a/xe_currency_converter/static/description/bank_book_dynamic_reports.png b/xe_currency_converter/static/description/bank_book_dynamic_reports.png new file mode 100644 index 000000000..d74daba97 Binary files /dev/null and b/xe_currency_converter/static/description/bank_book_dynamic_reports.png differ diff --git a/xe_currency_converter/static/description/banner.png b/xe_currency_converter/static/description/banner.png new file mode 100644 index 000000000..1e54c5cad Binary files /dev/null and b/xe_currency_converter/static/description/banner.png differ diff --git a/xe_currency_converter/static/description/cash_book_dynamic_reports.png b/xe_currency_converter/static/description/cash_book_dynamic_reports.png new file mode 100644 index 000000000..35bd4aee9 Binary files /dev/null and b/xe_currency_converter/static/description/cash_book_dynamic_reports.png differ diff --git a/xe_currency_converter/static/description/checked.png b/xe_currency_converter/static/description/checked.png new file mode 100644 index 000000000..578cedb80 Binary files /dev/null and b/xe_currency_converter/static/description/checked.png differ diff --git a/xe_currency_converter/static/description/day_book.jpeg b/xe_currency_converter/static/description/day_book.jpeg new file mode 100644 index 000000000..2409df5bb Binary files /dev/null and b/xe_currency_converter/static/description/day_book.jpeg differ diff --git a/xe_currency_converter/static/description/dynamic_financial_report.gif b/xe_currency_converter/static/description/dynamic_financial_report.gif new file mode 100644 index 000000000..d4530e466 Binary files /dev/null and b/xe_currency_converter/static/description/dynamic_financial_report.gif differ diff --git a/xe_currency_converter/static/description/icon.png b/xe_currency_converter/static/description/icon.png new file mode 100644 index 000000000..d4be3b589 Binary files /dev/null and b/xe_currency_converter/static/description/icon.png differ diff --git a/xe_currency_converter/static/description/index.html b/xe_currency_converter/static/description/index.html new file mode 100644 index 000000000..5024c7838 --- /dev/null +++ b/xe_currency_converter/static/description/index.html @@ -0,0 +1,443 @@ + + + + + + + Bootstrap 101 Template + + + + + + +
+
+
+

XE Currency Converter

+

Convert currency rates in real-time.

+
+

Key Highlights

+
    +
  • check Currency converter for Odoo12 community edition.
  • +
  • check Convert 180+ currencies.
  • +
  • check Get accurate currency rates for every world currency.
  • +
  • check Globally trusted exchange rates of currency.
  • +
  • check Daily / Live rates.
  • +
+
+ + Video Demo +
+
+
+ +
+
+
+
+

Overview

+
+

+ This module brings you an XE Currency Converter featuring easy convertion of business currencies in real-time. +

Convert your currencies by using the currency exchange platform xe.com

+

+

+
+ +
+
+ +
+
+
+
+

XE Currency Converter

+
    +
  • + Available in Odoo 12.0 community edition. +
  • +
  • + Easy activation and deactivation of the update. +
  • +
  • + Convert 180+ currencies. +
  • +
  • + This module uses an internal ir.cron feature from Odoo to schedule conversion activity. +
  • +
  • + Cron job is launched once the server is started. +
  • +
+
+
+
+
+

+ To enable/disable XE currency converter, go to Invoicing > Configuration > Settings > Enable/Disable Live Currency Update.Then click on update button. +

+
+ +
+
+
+

+ After that, check the currency rate. +

+
+ +
+
+
+

+ Cron job for scheduling the activity. +

+
+ +
+
+ +
+
+
Default 3
+ +
+
+
+ +
+
+
+

Video Demo

+
+

Odoo12 XE Currency Converter Demo

+ +
+ + + + + +
+
+ +
+
+ +

Suggested Products

+
+ + +
+ + +
+

Our Service

+
+ +
+
+
+

Our Industries

+
+ +
+
+
+
+ + Odoo Industry + +
+
+
+

+ + Trading + +

+

+ Easily procure and sell your products. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + Manufacturing +

+

+ Plan, track and schedule your operations. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + Restaurant +

+

+ Run your bar or restaurant methodical. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + POS +

+

+ Easy configuring and convivial selling. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + E-commerce & Website +

+

+ Mobile friendly, awe-inspiring product pages. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + Hotel Management +

+

+ An all-inclusive hotel management application. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + Education +

+

+ A Collaborative platform for educational management. +

+
+
+
+
+
+ + Odoo Industry + +
+
+
+

+ + Service Management +

+

+ Keep track of services and invoice accordingly. +

+
+
+
+
+
+ +
+ +
+ + + + + + + diff --git a/xe_currency_converter/static/description/print_financial_repot.png b/xe_currency_converter/static/description/print_financial_repot.png new file mode 100644 index 000000000..16745e06c Binary files /dev/null and b/xe_currency_converter/static/description/print_financial_repot.png differ diff --git a/xe_currency_converter/static/description/report_excel.jpeg b/xe_currency_converter/static/description/report_excel.jpeg new file mode 100644 index 000000000..b3ce5bdcc Binary files /dev/null and b/xe_currency_converter/static/description/report_excel.jpeg differ diff --git a/xe_currency_converter/static/description/xe-currency-converter-1.png b/xe_currency_converter/static/description/xe-currency-converter-1.png new file mode 100644 index 000000000..1b916bcab Binary files /dev/null and b/xe_currency_converter/static/description/xe-currency-converter-1.png differ diff --git a/xe_currency_converter/static/description/xe-currency-converter-2.png b/xe_currency_converter/static/description/xe-currency-converter-2.png new file mode 100644 index 000000000..6a14f8529 Binary files /dev/null and b/xe_currency_converter/static/description/xe-currency-converter-2.png differ diff --git a/xe_currency_converter/static/description/xe-currency-converter-3.png b/xe_currency_converter/static/description/xe-currency-converter-3.png new file mode 100644 index 000000000..87a4423e3 Binary files /dev/null and b/xe_currency_converter/static/description/xe-currency-converter-3.png differ diff --git a/xe_currency_converter/static/description/xe_currency_converter-4.png b/xe_currency_converter/static/description/xe_currency_converter-4.png new file mode 100644 index 000000000..ccf33866c Binary files /dev/null and b/xe_currency_converter/static/description/xe_currency_converter-4.png differ diff --git a/xe_currency_converter/static/description/xe_currency_converter-5.png b/xe_currency_converter/static/description/xe_currency_converter-5.png new file mode 100644 index 000000000..679a7fee8 Binary files /dev/null and b/xe_currency_converter/static/description/xe_currency_converter-5.png differ diff --git a/xe_currency_converter/views/config_settings_views.xml b/xe_currency_converter/views/config_settings_views.xml new file mode 100644 index 000000000..98b88795b --- /dev/null +++ b/xe_currency_converter/views/config_settings_views.xml @@ -0,0 +1,34 @@ + + + + inherited_res_config_settings_view + res.config.settings + + + +
+
+
+ +
+
+
+
+
+
+
+
+
diff --git a/xe_currency_converter/views/service_cron.xml b/xe_currency_converter/views/service_cron.xml new file mode 100644 index 000000000..d7565027d --- /dev/null +++ b/xe_currency_converter/views/service_cron.xml @@ -0,0 +1,13 @@ + + + + Update Currency Rate + + code + model.cron_update() + 1 + days + -1 + + +