Kevin Broodkoorn
9 years ago
9 changed files with 294 additions and 13 deletions
-
3account_financial_test_data/__init__.py
-
51account_financial_test_data/__openerp__.py
-
63account_financial_test_data/data/account_auto_installer.xml
-
76account_financial_test_data/data/partners_data.xml
-
8account_financial_test_data/data/settings_data.xml
-
4account_financial_test_data/models/__init__.py
-
64account_financial_test_data/models/account_installer.py
-
38account_financial_test_data/models/setting.py
-
BINaccount_financial_test_data/static/description/icon.png
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
@ -1,15 +1,40 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# |
|||
# 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 financial test data", |
|||
"summary": "Add all necessary data to test financial modules", |
|||
"version": "9.0.1.0.0", |
|||
"category": "Uncategorized", |
|||
"website": "https://odoo-community.org/", |
|||
"author": "Taktik, Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"application": False, |
|||
"installable": True, |
|||
"data": [ |
|||
] |
|||
'name': 'Account financial test data', |
|||
'version': '9.0.1.0.0', |
|||
'license': 'AGPL-3', |
|||
'author': "Taktik, Odoo Community Association (OCA)", |
|||
'category': 'Other', |
|||
'depends': [ |
|||
"base", |
|||
"account", |
|||
"account_accountant", |
|||
"l10n_fr", |
|||
], |
|||
'demo': [], |
|||
'data': [ |
|||
"data/settings_data.xml", |
|||
"data/account_auto_installer.xml", |
|||
"data/partners_data.xml", |
|||
], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,63 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
|
|||
<!-- Add a server action and a todo action to set accounting options for all companies without popup window --> |
|||
<record id="auto_config_charts_action_server" model="ir.actions.server"> |
|||
<field name="name">Set Accounting Options for all Companies</field> |
|||
<field name="condition">True</field> |
|||
<field name="type">ir.actions.server</field> |
|||
<field name="model_id" ref="account.model_wizard_multi_charts_accounts"/> |
|||
<field name="state">code</field> |
|||
<field name="code"> |
|||
self.auto_execute(cr, uid, context=context) |
|||
config = self.next(cr, uid, [], context=context) or {} |
|||
if config.get('type') not in ('ir.actions.act_window_close',): |
|||
action = config |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="auto_config_charts_action_todo" model="ir.actions.todo"> |
|||
<field name="action_id" ref="auto_config_charts_action_server"/> |
|||
<field name="sequence">10</field> |
|||
<field name="type">automatic</field> |
|||
<field name="state">open</field> |
|||
</record> |
|||
|
|||
<!-- Disable standard Configure Accounting Data wizard --> |
|||
<!--<record id="account.account_configuration_installer_todo" model="ir.actions.todo">--> |
|||
<!--<field name="state">done</field>--> |
|||
<!--</record>--> |
|||
|
|||
<!-- Disable standard Set Accounting Options wizard --> |
|||
<!--<record id="account.action_wizard_multi_chart_todo" model="ir.actions.todo">--> |
|||
<!--<field name="state">done</field>--> |
|||
<!--</record>--> |
|||
|
|||
<!--Main Company --> |
|||
|
|||
<!--<record id="ai-1" model="account.installer">--> |
|||
<!--<field name="company_id" ref="base.main_company"/>--> |
|||
<!--<field name="charts">l10n_fr</field>--> |
|||
<!--<field name="period">month</field>--> |
|||
<!--<field name="has_default_company" eval="1"/>--> |
|||
<!--</record>--> |
|||
|
|||
|
|||
<record id="wmca-1" model="wizard.multi.charts.accounts"> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="only_one_chart_template" eval="1"/> |
|||
<field name="complete_tax_set" eval="1"/> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
<field name="chart_template_id" ref="l10n_fr.l10n_fr_pcg_chart_template"/> |
|||
<field name="sale_tax" ref="l10n_fr.tva_normale"/> |
|||
<field name="purchase_tax" ref="l10n_fr.tva_acq_normale"/> |
|||
<field name="transfer_account_id" ref="l10n_fr.pcg_58"/> |
|||
<field name="code_digits" eval="6"/> |
|||
</record> |
|||
|
|||
<!-- Execute wizard multi charts accounts --> |
|||
<function model="wizard.multi.charts.accounts" name="auto_execute"/> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,76 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
<!--Partner a--> |
|||
<record id="data_partner_a" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER A</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
|
|||
<!--Partner b--> |
|||
<record id="data_partner_b" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER B</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
|
|||
<record id="data_partner_c" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER C</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
|
|||
<record id="data_partner_d" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER D</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
|
|||
<record id="data_partner_e" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER E</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
|
|||
<record id="data_partner_f" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER F</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
|
|||
<record id="data_partner_g" model="res.partner" |
|||
context="{'default_company_type': 'person'}"> |
|||
<field name="name">PARTNER G</field> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
<field name="customer" eval="True"/> |
|||
<field name="supplier" eval="False"/> |
|||
<field name="notify_email">always</field> |
|||
<field name="currency_id" ref="base.EUR"/> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
<record model="res.partner" id="base.partner_root"> |
|||
<field name="tz">Europe/Paris</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
import account_installer |
|||
import setting |
@ -0,0 +1,64 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from openerp.osv import orm |
|||
import logging |
|||
from openerp import models, fields, api, _, exceptions |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class WizardMultiChartsAccounts(orm.TransientModel): |
|||
""" |
|||
Execute wizard automatically without showing the wizard popup window |
|||
""" |
|||
_inherit = 'wizard.multi.charts.accounts' |
|||
|
|||
def auto_execute(self, cr, uid, ids=False, context=None): |
|||
if not context: |
|||
context = {} |
|||
context['lang'] = 'en_US' |
|||
if not ids: |
|||
ids = self.search(cr, uid, [], context=context) |
|||
account_obj = self.pool.get('account.account') |
|||
for wz in self.browse(cr, uid, ids, context=context): |
|||
account_id = account_obj.search( |
|||
cr, |
|||
uid, |
|||
[('company_id', '=', wz.company_id.id)], |
|||
limit=1, |
|||
context=context |
|||
) |
|||
if not account_id: |
|||
# execute original wizard method |
|||
_logger.info( |
|||
'Configure Accounting Data for Company: %s' % |
|||
wz.company_id.name |
|||
) |
|||
self.execute(cr, uid, [wz.id], context=context) |
|||
|
|||
|
|||
class AccountAccountTemplate(models.Model): |
|||
_inherit = "account.account.template" |
|||
|
|||
@api.model |
|||
def generate_account( |
|||
self, |
|||
chart_template_id, |
|||
tax_template_ref, |
|||
acc_template_ref, |
|||
code_digits, |
|||
company_id): |
|||
res = super(AccountAccountTemplate, self).generate_account( |
|||
chart_template_id, |
|||
tax_template_ref, |
|||
acc_template_ref, |
|||
code_digits, |
|||
company_id |
|||
) |
|||
main_company_id = self.env['ir.model.data'].xmlid_to_res_id( |
|||
'base.main_company' |
|||
) |
|||
if company_id == main_company_id: |
|||
account_ids = [] |
|||
for template_account_id in res: |
|||
account_ids.append(res[template_account_id]) |
|||
return res |
@ -0,0 +1,38 @@ |
|||
from openerp import api, models, fields, exceptions, _ |
|||
from openerp.modules.module import get_module_resource |
|||
|
|||
|
|||
class SettingCurrency(models.Model): |
|||
_name = 'setting.currency' |
|||
|
|||
@api.model |
|||
def _update_currency(self): |
|||
data_obj = self.env['ir.model.data'] |
|||
|
|||
eur = data_obj.xmlid_to_object('base.EUR') |
|||
usd = data_obj.xmlid_to_object('base.USD') |
|||
|
|||
eur.base = False |
|||
self.env['res.currency.rate'].search([ |
|||
('currency_id', '=', eur.id) |
|||
]).write({'rate': 0.8000}) |
|||
|
|||
main_company = data_obj.xmlid_to_object('base.main_company') |
|||
main_company.auto_currency_up = True |
|||
|
|||
services = self.env['currency.rate.update.service'].search( |
|||
[('company_id', '=', main_company.id), |
|||
('service', '=', 'ECB_getter')] |
|||
) |
|||
if services: |
|||
main_company.services_to_use = services[0] |
|||
else: |
|||
main_company.services_to_use = self.env[ |
|||
'currency.rate.update.service' |
|||
].create({ |
|||
'service': 'ECB_getter', |
|||
'max_delta_days': 1, |
|||
'currency_to_update': [(6, 0, [eur.id, usd.id])] |
|||
}) |
|||
|
|||
main_company.button_refresh_currency() |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue