import time
import datetime
from dateutil.relativedelta import relativedelta
-from operator import itemgetter
-from os.path import join as opj
-from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT as DF
+import openerp
+from openerp import SUPERUSER_ID
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from openerp.tools.translate import _
from openerp.osv import fields, osv
-from openerp import tools
class account_config_settings(osv.osv_memory):
_name = 'account.config.settings'
'currency_id': fields.related('company_id', 'currency_id', type='many2one', relation='res.currency', required=True,
string='Default company currency', help="Main currency of the company."),
'paypal_account': fields.related('company_id', 'paypal_account', type='char', size=128,
- string='Paypal account', help="Paypal account (email) for receiving online payments (credit card, etc.) If you set a paypal account, the customer will be able to pay your invoices or quotations with a button \"Pay with Paypal\" in automated emails or through the OpenERP portal."),
+ string='Paypal account', help="Paypal account (email) for receiving online payments (credit card, etc.) If you set a paypal account, the customer will be able to pay your invoices or quotations with a button \"Pay with Paypal\" in automated emails or through the Odoo portal."),
'company_footer': fields.related('company_id', 'rml_footer', type='text', readonly=True,
string='Bank accounts footer preview', help="Bank accounts as printed in the footer of each printed document"),
'module_account_check_writing': fields.boolean('Pay your suppliers by check',
help='This allows you to check writing and printing.\n'
- 'This installs the module account_check_writing.'),
+ '-This installs the module account_check_writing.'),
'module_account_accountant': fields.boolean('Full accounting features: journals, legal statements, chart of accounts, etc.',
help="""If you do not check this box, you will be able to do invoicing & payments, but not accounting (Journal Items, Chart of Accounts, ...)"""),
'module_account_asset': fields.boolean('Assets management',
help='This allows you to manage the assets owned by a company or a person.\n'
- 'It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.\n'
- 'This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, '
- 'but not accounting (Journal Items, Chart of Accounts, ...)'),
+ 'It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.\n'
+ '-This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, '
+ 'but not accounting (Journal Items, Chart of Accounts, ...)'),
'module_account_budget': fields.boolean('Budget management',
help='This allows accountants to manage analytic and crossovered budgets. '
- 'Once the master budgets and the budgets are defined, '
- 'the project managers can set the planned amount on each analytic account.\n'
- 'This installs the module account_budget.'),
+ 'Once the master budgets and the budgets are defined, '
+ 'the project managers can set the planned amount on each analytic account.\n'
+ '-This installs the module account_budget.'),
'module_account_payment': fields.boolean('Manage payment orders',
help='This allows you to create and manage your payment orders, with purposes to \n'
- '* serve as base for an easy plug-in of various automated payment mechanisms, and \n'
- '* provide a more efficient way to manage invoice payments.\n'
- 'This installs the module account_payment.' ),
+ '* serve as base for an easy plug-in of various automated payment mechanisms, and \n'
+ '* provide a more efficient way to manage invoice payments.\n'
+ '-This installs the module account_payment.' ),
'module_account_voucher': fields.boolean('Manage customer payments',
help='This includes all the basic requirements of voucher entries for bank, cash, sales, purchase, expense, contra, etc.\n'
- 'This installs the module account_voucher.'),
+ '-This installs the module account_voucher.'),
'module_account_followup': fields.boolean('Manage customer payment follow-ups',
help='This allows to automate letters for unpaid invoices, with multi-level recalls.\n'
- 'This installs the module account_followup.'),
+ '-This installs the module account_followup.'),
+ 'module_product_email_template': fields.boolean('Send products tools and information at the invoice confirmation',
+ help='With this module, link your products to a template to send complete information and tools to your customer.\n'
+ 'For instance when invoicing a training, the training agenda and materials will automatically be send to your customers.'),
'group_proforma_invoices': fields.boolean('Allow pro-forma invoices',
implied_group='account.group_proforma_invoices',
help="Allows you to put invoices in pro-forma state."),
help="Allows you to use the analytic accounting."),
'group_check_supplier_invoice_total': fields.boolean('Check the total of supplier invoices',
implied_group="account.group_supplier_inv_check_total"),
+ 'income_currency_exchange_account_id': fields.related(
+ 'company_id', 'income_currency_exchange_account_id',
+ type='many2one',
+ relation='account.account',
+ string="Gain Exchange Rate Account",
+ domain="[('type', '=', 'other')]"),
+ 'expense_currency_exchange_account_id': fields.related(
+ 'company_id', 'expense_currency_exchange_account_id',
+ type="many2one",
+ relation='account.account',
+ string="Loss Exchange Rate Account",
+ domain="[('type', '=', 'other')]"),
}
def _default_company(self, cr, uid, context=None):
else:
return (time.strftime('%Y-01-01'), time.strftime('%Y-12-31'), 'month')
-
_defaults = {
'company_id': _default_company,
'has_default_company': _default_has_default_company,
})
# update taxes
ir_values = self.pool.get('ir.values')
- taxes_id = ir_values.get_default(cr, uid, 'product.product', 'taxes_id', company_id=company_id)
- supplier_taxes_id = ir_values.get_default(cr, uid, 'product.product', 'supplier_taxes_id', company_id=company_id)
+ taxes_id = ir_values.get_default(cr, uid, 'product.template', 'taxes_id', company_id=company_id)
+ supplier_taxes_id = ir_values.get_default(cr, uid, 'product.template', 'supplier_taxes_id', company_id=company_id)
values.update({
'default_sale_tax': isinstance(taxes_id, list) and taxes_id[0] or taxes_id,
'default_purchase_tax': isinstance(supplier_taxes_id, list) and supplier_taxes_id[0] or supplier_taxes_id,
})
+ # update gain/loss exchange rate accounts
+ values.update({
+ 'income_currency_exchange_account_id': company.income_currency_exchange_account_id and company.income_currency_exchange_account_id.id or False,
+ 'expense_currency_exchange_account_id': company.expense_currency_exchange_account_id and company.expense_currency_exchange_account_id.id or False
+ })
+
return {'value': values}
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id, context=None):
def onchange_tax_rate(self, cr, uid, ids, rate, context=None):
return {'value': {'purchase_tax_rate': rate or False}}
+ def onchange_multi_currency(self, cr, uid, ids, group_multi_currency, context=None):
+ res = {}
+ if not group_multi_currency:
+ res['value'] = {'income_currency_exchange_account_id': False, 'expense_currency_exchange_account_id': False}
+ return res
+
def onchange_start_date(self, cr, uid, id, start_date):
if start_date:
start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d")
def set_default_taxes(self, cr, uid, ids, context=None):
""" set default sale and purchase taxes for products """
+ if uid != SUPERUSER_ID and not self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager'):
+ raise openerp.exceptions.AccessError(_("Only administrators can change the settings"))
ir_values = self.pool.get('ir.values')
config = self.browse(cr, uid, ids[0], context)
- ir_values.set_default(cr, uid, 'product.product', 'taxes_id',
+ ir_values.set_default(cr, SUPERUSER_ID, 'product.template', 'taxes_id',
config.default_sale_tax and [config.default_sale_tax.id] or False, company_id=config.company_id.id)
- ir_values.set_default(cr, uid, 'product.product', 'supplier_taxes_id',
+ ir_values.set_default(cr, SUPERUSER_ID, 'product.template', 'supplier_taxes_id',
config.default_purchase_tax and [config.default_purchase_tax.id] or False, company_id=config.company_id.id)
def set_chart_of_accounts(self, cr, uid, ids, context=None):