diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 08122f5af30..7045f5c069c 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -104,6 +104,7 @@ module named account_voucher. 'account_invoice_view.xml', 'partner_view.xml', 'data/account_data.xml', + 'data/data_account_type.xml', 'account_invoice_workflow.xml', 'project/project_view.xml', 'project/project_report.xml', diff --git a/addons/account/account.py b/addons/account/account.py index a15a04dcffe..fd8a0506d01 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -131,7 +131,7 @@ class account_account_type(osv.osv): _name = "account.account.type" _description = "Account Type" _columns = { - 'name': fields.char('Account Type', size=64, required=True), + 'name': fields.char('Account Type', size=64, required=True, translate=True), 'code': fields.char('Code', size=32, required=True), 'close_method': fields.selection([('none', 'None'), ('balance', 'Balance'), ('detail', 'Detail'), ('unreconciled', 'Unreconciled')], 'Deferral Method', required=True, help="""Set here the method that will be used to generate the end of year journal entries for all the accounts of this type. @@ -771,7 +771,9 @@ class account_journal(osv.osv): def create(self, cr, uid, vals, context=None): if not 'sequence_id' in vals or not vals['sequence_id']: - vals.update({'sequence_id': self.create_sequence(cr, uid, vals, context)}) + # if we have the right to create a journal, we should be able to + # create it's sequence. + vals.update({'sequence_id': self.create_sequence(cr, 1, vals, context)}) return super(account_journal, self).create(cr, uid, vals, context) def name_get(self, cr, user, ids, context=None): @@ -2429,6 +2431,7 @@ class account_account_template(osv.osv): 'child_parent_ids':fields.one2many('account.account.template', 'parent_id', 'Children'), 'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel', 'account_id', 'tax_id', 'Default Taxes'), 'nocreate': fields.boolean('Optional create', help="If checked, the new chart of accounts will not contain this by default."), + 'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', help="This optional field allow you to link an account template to a specific chart template that may differ from the one its root parent belongs to. This allow you to define chart templates that extend another and complete it with few new accounts (You don't need to define the whole structure that is common to both several times)."), } _defaults = { @@ -2465,6 +2468,59 @@ class account_account_template(osv.osv): res.append((record['id'],name )) return res + def generate_account(self, cr, uid, chart_template_id, tax_template_ref, acc_template_ref, code_digits, company_id, context=None): + """ + This method for generating accounts from templates. + + :param chart_template_id: id of the chart template chosen in the wizard + :param tax_template_ref: Taxes templates reference for write taxes_id in account_account. + :paramacc_template_ref: dictionary with the mappping between the account templates and the real accounts. + :param code_digits: number of digits got from wizard.multi.charts.accounts, this is use for account code. + :param company_id: company_id selected from wizard.multi.charts.accounts. + :returns: return acc_template_ref for reference purpose. + :rtype: dict + """ + if context is None: + context = {} + obj_acc = self.pool.get('account.account') + company_name = self.pool.get('res.company').browse(cr, uid, company_id, context=context).name + template = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context) + #deactivate the parent_store functionnality on account_account for rapidity purpose + ctx = context.copy() + ctx.update({'defer_parent_store_computation': True}) + children_acc_template = self.search(cr, uid, ['|', ('chart_template_id','=', [chart_template_id]),'&',('parent_id','child_of', [template.account_root_id.id]),('chart_template_id','=', False), ('nocreate','!=',True)], order='id') + for account_template in self.browse(cr, uid, children_acc_template, context=context): + # skip the root of COA if it's not the main one + if (template.account_root_id.id == account_template.id) and template.parent_id: + continue + tax_ids = [] + for tax in account_template.tax_ids: + tax_ids.append(tax_template_ref[tax.id]) + + code_main = account_template.code and len(account_template.code) or 0 + code_acc = account_template.code or '' + if code_main > 0 and code_main <= code_digits and account_template.type != 'view': + code_acc = str(code_acc) + (str('0'*(code_digits-code_main))) + vals={ + 'name': (template.account_root_id.id == account_template.id) and company_name or account_template.name, + 'currency_id': account_template.currency_id and account_template.currency_id.id or False, + 'code': code_acc, + 'type': account_template.type, + 'user_type': account_template.user_type and account_template.user_type.id or False, + 'reconcile': account_template.reconcile, + 'shortcut': account_template.shortcut, + 'note': account_template.note, + 'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False, + 'tax_ids': [(6,0,tax_ids)], + 'company_id': company_id, + } + new_account = obj_acc.create(cr, uid, vals, context=ctx) + acc_template_ref[account_template.id] = new_account + + #reactivate the parent_store functionnality on account_account + obj_acc._parent_store_compute(cr) + return acc_template_ref + account_account_template() class account_add_tmpl_wizard(osv.osv_memory): @@ -2542,6 +2598,41 @@ class account_tax_code_template(osv.osv): 'notprintable': False, } + def generate_tax_code(self, cr, uid, tax_code_root_id, company_id, context=None): + ''' + This function generates the tax codes from the templates of tax code that are children of the given one passed + in argument. Then it returns a dictionary with the mappping between the templates and the real objects. + + :param tax_code_root_id: id of the root of all the tax code templates to process + :param company_id: id of the company the wizard is running for + :returns: dictionary with the mappping between the templates and the real objects. + :rtype: dict + ''' + obj_tax_code_template = self.pool.get('account.tax.code.template') + obj_tax_code = self.pool.get('account.tax.code') + tax_code_template_ref = {} + company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) + + #find all the children of the tax_code_root_id + children_tax_code_template = obj_tax_code_template.search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') + for tax_code_template in obj_tax_code_template.browse(cr, uid, children_tax_code_template, context=context): + vals = { + 'name': (tax_code_root_id == tax_code_template.id) and company.name or tax_code_template.name, + 'code': tax_code_template.code, + 'info': tax_code_template.info, + 'parent_id': tax_code_template.parent_id and ((tax_code_template.parent_id.id in tax_code_template_ref) and tax_code_template_ref[tax_code_template.parent_id.id]) or False, + 'company_id': company_id, + 'sign': tax_code_template.sign, + } + #check if this tax code already exists + rec_list = obj_tax_code.search(cr, uid, [('name', '=', vals['name']),('code', '=', vals['code']),('company_id', '=', vals['company_id'])], context=context) + if not rec_list: + #if not yet, create it + new_tax_code = obj_tax_code.create(cr, uid, vals) + #recording the new tax code to do the mapping + tax_code_template_ref[tax_code_template.id] = new_tax_code + return tax_code_template_ref + def name_get(self, cr, uid, ids, context=None): if not ids: return [] @@ -2565,19 +2656,29 @@ class account_chart_template(osv.osv): _columns={ 'name': fields.char('Name', size=64, required=True), - 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)]), - 'tax_code_root_id': fields.many2one('account.tax.code.template','Root Tax Code',required=True,domain=[('parent_id','=',False)]), + 'parent_id': fields.many2one('account.chart.template', 'Parent Chart Template'), + 'code_digits': fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"), + 'visible': fields.boolean('Can be Visible?', help="Set this to False if you don't want this template to be used actively in the wizard that generate Chart of Accounts from templates, this is useful when you want to generate accounts of this template only when loading its child template."), + 'complete_tax_set': fields.boolean('Complete Set of Taxes', help='This boolean helps you to choose if you want to propose to the user to encode the sale and purchase rates or choose from list of taxes. This last choice assumes that the set of tax defined on this template is complete'), + 'account_root_id': fields.many2one('account.account.template', 'Root Account', domain=[('parent_id','=',False)]), + 'tax_code_root_id': fields.many2one('account.tax.code.template', 'Root Tax Code', domain=[('parent_id','=',False)]), 'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'), - 'bank_account_view_id': fields.many2one('account.account.template','Bank Account',required=True), - 'property_account_receivable': fields.many2one('account.account.template','Receivable Account'), - 'property_account_payable': fields.many2one('account.account.template','Payable Account'), - 'property_account_expense_categ': fields.many2one('account.account.template','Expense Category Account'), - 'property_account_income_categ': fields.many2one('account.account.template','Income Category Account'), - 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), - 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), + 'bank_account_view_id': fields.many2one('account.account.template', 'Bank Account'), + 'property_account_receivable': fields.many2one('account.account.template', 'Receivable Account'), + 'property_account_payable': fields.many2one('account.account.template', 'Payable Account'), + 'property_account_expense_categ': fields.many2one('account.account.template', 'Expense Category Account'), + 'property_account_income_categ': fields.many2one('account.account.template', 'Income Category Account'), + 'property_account_expense': fields.many2one('account.account.template', 'Expense Account on Product Template'), + 'property_account_income': fields.many2one('account.account.template', 'Income Account on Product Template'), 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Profit/Loss Account', domain=[('type', '=', 'payable')], help='This Account is used for transferring Profit/Loss(If It is Profit: Amount will be added, Loss: Amount will be deducted.), Which is calculated from Profilt & Loss Report'), - 'property_account_income_opening': fields.many2one('account.account.template','Opening Entries Income Account'), - 'property_account_expense_opening': fields.many2one('account.account.template','Opening Entries Expense Account'), + 'property_account_income_opening': fields.many2one('account.account.template', 'Opening Entries Income Account'), + 'property_account_expense_opening': fields.many2one('account.account.template', 'Opening Entries Expense Account'), + } + + _defaults = { + 'visible': True, + 'code_digits': 6, + 'complete_tax_set': True, } account_chart_template() @@ -2655,6 +2756,61 @@ class account_tax_template(osv.osv): } _order = 'sequence' + def _generate_tax(self, cr, uid, tax_templates, tax_code_template_ref, company_id, context=None): + """ + This method generate taxes from templates. + + :param tax_templates: list of browse record of the tax templates to process + :param tax_code_template_ref: Taxcode templates reference. + :param company_id: id of the company the wizard is running for + :returns: + { + 'tax_template_to_tax': mapping between tax template and the newly generated taxes corresponding, + 'account_dict': dictionary containing a to-do list with all the accounts to assign on new taxes + } + """ + if context is None: + context = {} + res = {} + todo_dict = {} + tax_template_to_tax = {} + for tax in tax_templates: + vals_tax = { + 'name':tax.name, + 'sequence': tax.sequence, + 'amount': tax.amount, + 'type': tax.type, + 'applicable_type': tax.applicable_type, + 'domain': tax.domain, + 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_to_tax) and tax_template_to_tax[tax.parent_id.id]) or False, + 'child_depend': tax.child_depend, + 'python_compute': tax.python_compute, + 'python_compute_inv': tax.python_compute_inv, + 'python_applicable': tax.python_applicable, + 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, + 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, + 'base_sign': tax.base_sign, + 'tax_sign': tax.tax_sign, + 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, + 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, + 'ref_base_sign': tax.ref_base_sign, + 'ref_tax_sign': tax.ref_tax_sign, + 'include_base_amount': tax.include_base_amount, + 'description': tax.description, + 'company_id': company_id, + 'type_tax_use': tax.type_tax_use, + 'price_include': tax.price_include + } + new_tax = self.pool.get('account.tax').create(cr, uid, vals_tax) + tax_template_to_tax[tax.id] = new_tax + #as the accounts have not been created yet, we have to wait before filling these fields + todo_dict[new_tax] = { + 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, + 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, + } + res.update({'tax_template_to_tax': tax_template_to_tax, 'account_dict': todo_dict}) + return res + account_tax_template() # Fiscal Position Templates @@ -2671,6 +2827,38 @@ class account_fiscal_position_template(osv.osv): 'note': fields.text('Notes', translate=True), } + def generate_fiscal_position(self, cr, uid, chart_temp_id, tax_template_ref, acc_template_ref, company_id, context=None): + """ + This method generate Fiscal Position, Fiscal Position Accounts and Fiscal Position Taxes from templates. + + :param chart_temp_id: Chart Template Id. + :param taxes_ids: Taxes templates reference for generating account.fiscal.position.tax. + :param acc_template_ref: Account templates reference for generating account.fiscal.position.account. + :param company_id: company_id selected from wizard.multi.charts.accounts. + :returns: True + """ + if context is None: + context = {} + obj_tax_fp = self.pool.get('account.fiscal.position.tax') + obj_ac_fp = self.pool.get('account.fiscal.position.account') + obj_fiscal_position = self.pool.get('account.fiscal.position') + fp_ids = self.search(cr, uid, [('chart_template_id', '=', chart_temp_id)]) + for position in self.browse(cr, uid, fp_ids, context=context): + new_fp = obj_fiscal_position.create(cr, uid, {'company_id': company_id, 'name': position.name}) + for tax in position.tax_ids: + obj_tax_fp.create(cr, uid, { + 'tax_src_id': tax_template_ref[tax.tax_src_id.id], + 'tax_dest_id': tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False, + 'position_id': new_fp + }) + for acc in position.account_ids: + obj_ac_fp.create(cr, uid, { + 'account_src_id': acc_template_ref[acc.account_src_id.id], + 'account_dest_id': acc_template_ref[acc.account_dest_id.id], + 'position_id': new_fp + }) + return True + account_fiscal_position_template() class account_fiscal_position_tax_template(osv.osv): @@ -2805,66 +2993,64 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."), "sale_tax": fields.many2one("account.tax.template", "Default Sale Tax"), "purchase_tax": fields.many2one("account.tax.template", "Default Purchase Tax"), + 'sale_tax_rate': fields.float('Sales Tax(%)'), + 'purchase_tax_rate': fields.float('Purchase Tax(%)'), + 'complete_tax_set': fields.boolean('Complete Set of Taxes', help='This boolean helps you to choose if you want to propose to the user to encode the sales and purchase rates or use the usual m2o fields. This last choice assumes that the set of tax defined for the chosen template is complete'), } def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): res = {} - res['value'] = {} - res['value']["sale_tax"] = False - res['value']["purchase_tax"] = False + tax_templ_obj = self.pool.get('account.tax.template') + res['value'] = {'complete_tax_set': False, 'sale_tax': False, 'purchase_tax': False} if chart_template_id: - # default tax is given by the lowest sequence. For same sequence we will take the latest created as it will be the case for tax created while installing the generic chart of accounts - sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" - , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence, id desc") - purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" - , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence, id desc") + data = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context) + res['value'].update({'complete_tax_set': data.complete_tax_set}) + if data.complete_tax_set: + # default tax is given by the lowest sequence. For same sequence we will take the latest created as it will be the case for tax created while isntalling the generic chart of account + sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence, id desc") + purchase_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence, id desc") + res['value'].update({'sale_tax': sale_tax_ids and sale_tax_ids[0] or False, 'purchase_tax': purchase_tax_ids and purchase_tax_ids[0] or False}) - res['value']["sale_tax"] = sale_tax_ids and sale_tax_ids[0] or False - res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False + if data.code_digits: + res['value'].update({'code_digits': data.code_digits}) return res - def _get_purchase_tax(self, cr, uid, context=None): - ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) + + def default_get(self, cr, uid, fields, context=None): + res = super(wizard_multi_charts_accounts, self).default_get(cr, uid, fields, context=context) + tax_templ_obj = self.pool.get('account.tax.template') + + if 'bank_accounts_id' in fields: + res.update({'bank_accounts_id': [{'acc_name': _('Current'), 'account_type': 'bank'}, + {'acc_name': _('Deposit'), 'account_type': 'bank'}, + {'acc_name': _('Cash'), 'account_type': 'cash'}]}) + if 'company_id' in fields: + res.update({'company_id': self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0].company_id.id}) + if 'seq_journal' in fields: + res.update({'seq_journal': True}) + + ids = self.pool.get('account.chart.template').search(cr, uid, [('visible', '=', True)], context=context) if ids: - chart_template_id = ids[0] - purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" - , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") - return purchase_tax_ids and purchase_tax_ids[0] or False - return False - - def _get_sale_tax(self, cr, uid, context=None): - ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) - if ids: - chart_template_id = ids[0] - sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" - , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence") - return sale_tax_ids and sale_tax_ids[0] or False - return False - - def _get_chart(self, cr, uid, context=None): - ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) - if ids: - return ids[0] - return False - - def _get_default_accounts(self, cr, uid, context=None): - return [ - {'acc_name': _('Cash'),'account_type':'cash'} - ] - - _defaults = { - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, - 'chart_template_id': _get_chart, - 'bank_accounts_id': _get_default_accounts, - 'sale_tax': _get_sale_tax, - 'purchase_tax': _get_purchase_tax, - 'code_digits': 6, - 'seq_journal': True - } + if 'chart_template_id' in fields: + res.update({'chart_template_id': ids[0]}) + if 'sale_tax' in fields: + sale_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", ids[0]), ('type_tax_use', 'in', ('sale','all'))], order="sequence") + res.update({'sale_tax': sale_tax_ids and sale_tax_ids[0] or False}) + if 'purchase_tax' in fields: + purchase_tax_ids = tax_templ_obj.search(cr, uid, [("chart_template_id" + , "=", ids[0]), ('type_tax_use', 'in', ('purchase','all'))], order="sequence") + res.update({'purchase_tax': purchase_tax_ids and purchase_tax_ids[0] or False}) + return res def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(wizard_multi_charts_accounts, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) cmp_select = [] - company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) + acc_template_obj = self.pool.get('account.chart.template') + company_obj = self.pool.get('res.company') + + company_ids = company_obj.search(cr, uid, [], context=context) #display in the widget selection of companies, only the companies that haven't been configured yet (but don't care about the demo chart of accounts) cr.execute("SELECT company_id FROM account_account WHERE active = 't' AND account_account.parent_id IS NULL AND name != %s", ("Chart For Automated Tests",)) configured_cmp = [r[0] for r in cr.fetchall()] @@ -2874,305 +3060,118 @@ class wizard_multi_charts_accounts(osv.osv_memory): res['fields'][field]['domain'] = [('id','in',unconfigured_cmp)] res['fields'][field]['selection'] = [('', '')] if unconfigured_cmp: - cmp_select = [(line.id, line.name) for line in self.pool.get('res.company').browse(cr, uid, unconfigured_cmp)] + cmp_select = [(line.id, line.name) for line in company_obj.browse(cr, uid, unconfigured_cmp)] res['fields'][field]['selection'] = cmp_select return res - def execute(self, cr, uid, ids, context=None): - obj_multi = self.browse(cr, uid, ids[0]) - obj_acc = self.pool.get('account.account') - obj_acc_tax = self.pool.get('account.tax') + def check_created_journals(self, cr, uid, vals_journal, company_id, context=None): + """ + This method used for checking journals already created or not. If not then create new journal. + """ obj_journal = self.pool.get('account.journal') - obj_acc_template = self.pool.get('account.account.template') - obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') - obj_fiscal_position = self.pool.get('account.fiscal.position') + rec_list = obj_journal.search(cr, uid, [('name','=', vals_journal['name']),('company_id', '=', company_id)], context=context) + if not rec_list: + obj_journal.create(cr, uid, vals_journal, context=context) + return True + + def generate_journals(self, cr, uid, chart_template_id, acc_template_ref, company_id, context=None): + """ + This method is used for creating journals. + + :param chart_temp_id: Chart Template Id. + :param acc_template_ref: Account templates reference. + :param company_id: company_id selected from wizard.multi.charts.accounts. + :returns: True + """ + journal_data = self._prepare_all_journals(cr, uid, chart_template_id, acc_template_ref, company_id, context=context) + for vals_journal in journal_data: + self.check_created_journals(cr, uid, vals_journal, company_id, context=context) + return True + + def _prepare_all_journals(self, cr, uid, chart_template_id, acc_template_ref, company_id, context=None): + def _get_analytic_journal(journal_type): + # Get the analytic journal + analytic_journal_ids = [] + if journal_type in ('sale', 'sale_refund'): + analytical_journal_ids = analytic_journal_obj.search(cr, uid, [('type','=','sale')], context=context) + elif journal_type in ('purchase', 'purchase_refund'): + analytical_journal_ids = analytic_journal_obj.search(cr, uid, [('type','=','purchase')], context=context) + elif journal_type == 'general': + analytical_journal_ids = analytic_journal_obj.search(cr, uid, [('type', '=', 'situation')], context=context) + return analytic_journal_ids and analytic_journal_ids[0] or False + + def _get_default_account(journal_type, type='debit'): + # Get the default accounts + default_account = False + if journal_type in ('sale', 'sale_refund'): + default_account = acc_template_ref.get(template.property_account_income_categ.id) + elif journal_type in ('purchase', 'purchase_refund'): + default_account = acc_template_ref.get(template.property_account_expense_categ.id) + elif journal_type == 'situation': + if type == 'debit': + default_account = acc_template_ref.get(template.property_account_expense_opening.id) + else: + default_account = acc_template_ref.get(template.property_account_income_opening.id) + return default_account + + def _get_view_id(journal_type): + # Get the journal views + if journal_type in ('general', 'situation'): + data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_view') + elif journal_type in ('sale_refund', 'purchase_refund'): + data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_refund_journal_view') + else: + data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_journal_view') + return data and data[1] or False + + journal_names = { + 'sale': _('Sales Journal'), + 'purchase': _('Purchase Journal'), + 'sale_refund': _('Sales Refund Journal'), + 'purchase_refund': _('Purchase Refund Journal'), + 'general': _('Miscellaneous Journal'), + 'situation': _('Opening Entries Journal'), + } + journal_codes = { + 'sale': _('SAJ'), + 'purchase': _('EXJ'), + 'sale_refund': _('SCNJ'), + 'purchase_refund': _('ECNJ'), + 'general': _('MISC'), + 'situation': _('OPEJ'), + } + obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') - obj_tax_code = self.pool.get('account.tax.code') - obj_tax_code_template = self.pool.get('account.tax.code.template') - ir_values_obj = self.pool.get('ir.values') - # Creating Account - obj_acc_root = obj_multi.chart_template_id.account_root_id - tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id - company_id = obj_multi.company_id.id + template = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context) - #new code - acc_template_ref = {} - tax_template_ref = {} - tax_code_template_ref = {} - todo_dict = {} - - #create all the tax code - children_tax_code_template = obj_tax_code_template.search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') - children_tax_code_template.sort() - for tax_code_template in obj_tax_code_template.browse(cr, uid, children_tax_code_template, context=context): + journal_data = [] + for journal_type in ['sale', 'purchase', 'sale_refund', 'purchase_refund', 'general', 'situation']: vals = { - 'name': (tax_code_root_id == tax_code_template.id) and obj_multi.company_id.name or tax_code_template.name, - 'code': tax_code_template.code, - 'info': tax_code_template.info, - 'parent_id': tax_code_template.parent_id and ((tax_code_template.parent_id.id in tax_code_template_ref) and tax_code_template_ref[tax_code_template.parent_id.id]) or False, + 'type': journal_type, + 'name': journal_names[journal_type], + 'code': journal_codes[journal_type], 'company_id': company_id, - 'sign': tax_code_template.sign, + 'centralisation': journal_type == 'situation', + 'view_id': _get_view_id(journal_type), + 'analytic_journal_id': _get_analytic_journal(journal_type), + 'default_credit_account_id': _get_default_account(journal_type, 'credit'), + 'default_debit_account_id': _get_default_account(journal_type, 'debit'), } - new_tax_code = obj_tax_code.create(cr, uid, vals) - #recording the new tax code to do the mapping - tax_code_template_ref[tax_code_template.id] = new_tax_code + journal_data.append(vals) + return journal_data - #create all the tax - tax_template_to_tax = {} - for tax in obj_multi.chart_template_id.tax_template_ids: - #create it - vals_tax = { - 'name':tax.name, - 'sequence': tax.sequence, - 'amount':tax.amount, - 'type':tax.type, - 'applicable_type': tax.applicable_type, - 'domain':tax.domain, - 'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False, - 'child_depend': tax.child_depend, - 'python_compute': tax.python_compute, - 'python_compute_inv': tax.python_compute_inv, - 'python_applicable': tax.python_applicable, - 'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False, - 'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False, - 'base_sign': tax.base_sign, - 'tax_sign': tax.tax_sign, - 'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False, - 'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False, - 'ref_base_sign': tax.ref_base_sign, - 'ref_tax_sign': tax.ref_tax_sign, - 'include_base_amount': tax.include_base_amount, - 'description':tax.description, - 'company_id': company_id, - 'type_tax_use': tax.type_tax_use, - 'price_include': tax.price_include - } - new_tax = obj_acc_tax.create(cr, uid, vals_tax) - tax_template_to_tax[tax.id] = new_tax - #as the accounts have not been created yet, we have to wait before filling these fields - todo_dict[new_tax] = { - 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, - 'account_paid_id': tax.account_paid_id and tax.account_paid_id.id or False, - } - tax_template_ref[tax.id] = new_tax - #deactivate the parent_store functionnality on account_account for rapidity purpose - ctx = context and context.copy() or {} - ctx['defer_parent_store_computation'] = True + def generate_properties(self, cr, uid, chart_template_id, acc_template_ref, company_id, context=None): + """ + This method used for creating properties. - children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)]) - children_acc_template.sort() - for account_template in obj_acc_template.browse(cr, uid, children_acc_template, context=context): - tax_ids = [] - for tax in account_template.tax_ids: - tax_ids.append(tax_template_ref[tax.id]) - #create the account_account - - dig = obj_multi.code_digits - code_main = account_template.code and len(account_template.code) or 0 - code_acc = account_template.code or '' - if code_main>0 and code_main<=dig and account_template.type != 'view': - code_acc=str(code_acc) + (str('0'*(dig-code_main))) - vals={ - 'name': (obj_acc_root.id == account_template.id) and obj_multi.company_id.name or account_template.name, - 'currency_id': account_template.currency_id and account_template.currency_id.id or False, - 'code': code_acc, - 'type': account_template.type, - 'user_type': account_template.user_type and account_template.user_type.id or False, - 'reconcile': account_template.reconcile, - 'shortcut': account_template.shortcut, - 'note': account_template.note, - 'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False, - 'tax_ids': [(6,0,tax_ids)], - 'company_id': company_id, - } - new_account = obj_acc.create(cr, uid, vals, context=ctx) - acc_template_ref[account_template.id] = new_account - - - #reactivate the parent_store functionnality on account_account - obj_acc._parent_store_compute(cr) - - for key,value in todo_dict.items(): - if value['account_collected_id'] or value['account_paid_id']: - obj_acc_tax.write(cr, uid, [key], { - 'account_collected_id': acc_template_ref.get(value['account_collected_id'], False), - 'account_paid_id': acc_template_ref.get(value['account_paid_id'], False), - }) - - # Creating Journals - data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')]) - data = obj_data.browse(cr, uid, data_id[0], context=context) - view_id = data.res_id - - #Sales Journal - analytical_sale_ids = analytic_journal_obj.search(cr,uid,[('type','=','sale')]) - analytical_journal_sale = analytical_sale_ids and analytical_sale_ids[0] or False - - vals_journal = { - 'name': _('Sales Journal'), - 'type': 'sale', - 'code': _('SAJ'), - 'view_id': view_id, - 'company_id': company_id, - 'analytic_journal_id': analytical_journal_sale, - } - - if obj_multi.chart_template_id.property_account_receivable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] - - obj_journal.create(cr,uid,vals_journal) - - # Purchase Journal - analytical_purchase_ids = analytic_journal_obj.search(cr,uid,[('type','=','purchase')]) - analytical_journal_purchase = analytical_purchase_ids and analytical_purchase_ids[0] or False - - vals_journal = { - 'name': _('Purchase Journal'), - 'type': 'purchase', - 'code': _('EXJ'), - 'view_id': view_id, - 'company_id': company_id, - 'analytic_journal_id': analytical_journal_purchase, - } - - if obj_multi.chart_template_id.property_account_payable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] - obj_journal.create(cr,uid,vals_journal) - - # Creating Journals Sales Refund and Purchase Refund - data_id = obj_data.search(cr, uid, [('model', '=', 'account.journal.view'), ('name', '=', 'account_sp_refund_journal_view')], context=context) - data = obj_data.browse(cr, uid, data_id[0], context=context) - view_id = data.res_id - - #Sales Refund Journal - vals_journal = { - 'name': _('Sales Refund Journal'), - 'type': 'sale_refund', - 'code': _('SCNJ'), - 'view_id': view_id, - 'analytic_journal_id': analytical_journal_sale, - 'company_id': company_id - } - - if obj_multi.chart_template_id.property_account_receivable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] - - obj_journal.create(cr, uid, vals_journal, context=context) - - # Purchase Refund Journal - vals_journal = { - 'name': _('Purchase Refund Journal'), - 'type': 'purchase_refund', - 'code': _('ECNJ'), - 'view_id': view_id, - 'analytic_journal_id': analytical_journal_purchase, - 'company_id': company_id - } - - if obj_multi.chart_template_id.property_account_payable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] - - obj_journal.create(cr, uid, vals_journal, context=context) - - # Miscellaneous Journal - data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_view')]) - data = obj_data.browse(cr, uid, data_id[0], context=context) - view_id = data.res_id - - analytical_miscellaneous_ids = analytic_journal_obj.search(cr, uid, [('type', '=', 'situation')], context=context) - analytical_journal_miscellaneous = analytical_miscellaneous_ids and analytical_miscellaneous_ids[0] or False - - vals_journal = { - 'name': _('Miscellaneous Journal'), - 'type': 'general', - 'code': _('MISC'), - 'view_id': view_id, - 'analytic_journal_id': analytical_journal_miscellaneous, - 'company_id': company_id - } - - obj_journal.create(cr, uid, vals_journal, context=context) - - # Opening Entries Journal - if obj_multi.chart_template_id.property_account_income_opening and obj_multi.chart_template_id.property_account_expense_opening: - vals_journal = { - 'name': _('Opening Entries Journal'), - 'type': 'situation', - 'code': _('OPEJ'), - 'view_id': view_id, - 'company_id': company_id, - 'centralisation': True, - 'default_credit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_income_opening.id], - 'default_debit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_expense_opening.id] - } - obj_journal.create(cr, uid, vals_journal, context=context) - - # Bank Journals - data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) - data = obj_data.browse(cr, uid, data_id[0], context=context) - view_id_cash = data.res_id - - data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')]) - data = obj_data.browse(cr, uid, data_id[0], context=context) - view_id_cur = data.res_id - ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id - - current_num = 1 - valid = True - for line in obj_multi.bank_accounts_id: - #create the account_account for this bank journal - tmp = line.acc_name - dig = obj_multi.code_digits - if not ref_acc_bank.code: - raise osv.except_osv(_('Configuration Error !'), _('The bank account defined on the selected chart of accounts hasn\'t a code.')) - while True: - new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)), '0')) + str(current_num) - ids = obj_acc.search(cr, uid, [('code', '=', new_code), ('company_id', '=', company_id)]) - if not ids: - break - else: - current_num += 1 - vals = { - 'name': tmp, - 'currency_id': line.currency_id and line.currency_id.id or False, - 'code': new_code, - 'type': 'liquidity', - 'user_type': account_template.user_type and account_template.user_type.id or False, - 'reconcile': True, - 'parent_id': acc_template_ref[ref_acc_bank.id] or False, - 'company_id': company_id, - } - acc_cash_id = obj_acc.create(cr,uid,vals) - - #create the bank journal - vals_journal = { - 'name': vals['name'], - 'code': _('BNK') + str(current_num), - 'type': line.account_type == 'cash' and 'cash' or 'bank', - 'company_id': company_id, - 'analytic_journal_id': False, - 'currency': False, - } - if line.currency_id: - vals_journal['view_id'] = view_id_cur - vals_journal['currency'] = line.currency_id.id - else: - vals_journal['view_id'] = view_id_cash - vals_journal['default_credit_account_id'] = acc_cash_id - vals_journal['default_debit_account_id'] = acc_cash_id - obj_journal.create(cr, uid, vals_journal) - current_num += 1 - valid = True - - #create the properties + :param chart_template_id: id of the current chart template for which we need to create properties + :param acc_template_ref: Mapping between ids of account templates and real accounts created from them + :param company_id: company_id selected from wizard.multi.charts.accounts. + :returns: True + """ property_obj = self.pool.get('ir.property') - fields_obj = self.pool.get('ir.model.fields') - + field_obj = self.pool.get('ir.model.fields') todo_list = [ ('property_account_receivable','res.partner','account.account'), ('property_account_payable','res.partner','account.account'), @@ -3182,61 +3181,314 @@ class wizard_multi_charts_accounts(osv.osv_memory): ('property_account_income','product.template','account.account'), ('property_reserve_and_surplus_account','res.company','account.account') ] + template = self.pool.get('account.chart.template').browse(cr, uid, chart_template_id, context=context) for record in todo_list: - r = [] - r = property_obj.search(cr, uid, [('name','=', record[0] ),('company_id','=',company_id)]) - account = getattr(obj_multi.chart_template_id, record[0]) - field = fields_obj.search(cr, uid, [('name','=',record[0]),('model','=',record[1]),('relation','=',record[2])]) - vals = { - 'name': record[0], - 'company_id': company_id, - 'fields_id': field[0], - 'value': account and 'account.account,' + str(acc_template_ref[account.id]) or False, + account = getattr(template, record[0]) + value = account and 'account.account,' + str(acc_template_ref[account.id]) or False + if value: + field = field_obj.search(cr, uid, [('name', '=', record[0]),('model', '=', record[1]),('relation', '=', record[2])], context=context) + vals = { + 'name': record[0], + 'company_id': company_id, + 'fields_id': field[0], + 'value': value, + } + property_ids = property_obj.search(cr, uid, [('name','=', record[0]),('company_id', '=', company_id)], context=context) + if property_ids: + #the property exist: modify it + property_obj.write(cr, uid, property_ids, vals, context=context) + else: + #create the property + property_obj.create(cr, uid, vals, context=context) + return True + + def _install_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, acc_ref={}, taxes_ref={}, tax_code_ref={}, context=None): + ''' + This function recursively loads the template objects and create the real objects from them. + + :param template_id: id of the chart template to load + :param company_id: id of the company the wizard is running for + :param code_digits: integer that depicts the number of digits the accounts code should have in the COA + :param obj_wizard: the current wizard for generating the COA from the templates + :param acc_ref: Mapping between ids of account templates and real accounts created from them + :param taxes_ref: Mapping between ids of tax templates and real taxes created from them + :param tax_code_ref: Mapping between ids of tax code templates and real tax codes created from them + :returns: return a tuple with a dictionary containing + * the mapping between the account template ids and the ids of the real accounts that have been generated + from them, as first item, + * a similar dictionary for mapping the tax templates and taxes, as second item, + * a last identical containing the mapping of tax code templates and tax codes + :rtype: tuple(dict, dict, dict) + ''' + template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) + if template.parent_id: + tmp1, tmp2, tmp3 = self._install_template(cr, uid, template.parent_id.id, company_id, code_digits=code_digits, acc_ref=acc_ref, taxes_ref=taxes_ref, tax_code_ref=tax_code_ref, context=context) + acc_ref.update(tmp1) + taxes_ref.update(tmp2) + tax_code_ref.update(tmp3) + tmp1, tmp2, tmp3 = self._load_template(cr, uid, template_id, company_id, code_digits=code_digits, obj_wizard=obj_wizard, account_ref=acc_ref, taxes_ref=taxes_ref, tax_code_ref=tax_code_ref, context=context) + acc_ref.update(tmp1) + taxes_ref.update(tmp2) + tax_code_ref.update(tmp3) + return acc_ref, taxes_ref, tax_code_ref + + def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref={}, taxes_ref={}, tax_code_ref={}, context=None): + ''' + This function generates all the objects from the templates + + :param template_id: id of the chart template to load + :param company_id: id of the company the wizard is running for + :param code_digits: integer that depicts the number of digits the accounts code should have in the COA + :param obj_wizard: the current wizard for generating the COA from the templates + :param acc_ref: Mapping between ids of account templates and real accounts created from them + :param taxes_ref: Mapping between ids of tax templates and real taxes created from them + :param tax_code_ref: Mapping between ids of tax code templates and real tax codes created from them + :returns: return a tuple with a dictionary containing + * the mapping between the account template ids and the ids of the real accounts that have been generated + from them, as first item, + * a similar dictionary for mapping the tax templates and taxes, as second item, + * a last identical containing the mapping of tax code templates and tax codes + :rtype: tuple(dict, dict, dict) + ''' + template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context) + obj_tax_code_template = self.pool.get('account.tax.code.template') + obj_acc_tax = self.pool.get('account.tax') + obj_tax_temp = self.pool.get('account.tax.template') + obj_acc_template = self.pool.get('account.account.template') + obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') + + # create all the tax code. + tax_code_ref.update(obj_tax_code_template.generate_tax_code(cr, uid, template.tax_code_root_id.id, company_id, context=context)) + + # Generate taxes from templates. + tax_templates = [x for x in template.tax_template_ids] + generated_tax_res = obj_tax_temp._generate_tax(cr, uid, tax_templates, tax_code_ref, company_id, context=context) + taxes_ref.update(generated_tax_res['tax_template_to_tax']) + + # Generating Accounts from templates. + account_template_ref = obj_acc_template.generate_account(cr, uid, template_id, taxes_ref, account_ref, code_digits, company_id, context=context) + account_ref.update(account_template_ref) + + # writing account values on tax after creation of accounts + for key,value in generated_tax_res['account_dict'].items(): + if value['account_collected_id'] or value['account_paid_id']: + obj_acc_tax.write(cr, uid, [key], { + 'account_collected_id': account_ref.get(value['account_collected_id'], False), + 'account_paid_id': account_ref.get(value['account_paid_id'], False), + }) + + # Create Journals + self.generate_journals(cr, uid, template_id, account_ref, company_id, context=context) + + # generate properties function + self.generate_properties(cr, uid, template_id, account_ref, company_id, context=context) + + # Generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates + obj_fiscal_position_template.generate_fiscal_position(cr, uid, template_id, taxes_ref, account_ref, company_id, context=context) + + return account_ref, taxes_ref, tax_code_ref + + def _create_tax_templates_from_rates(self, cr, uid, obj_wizard, company_id, context=None): + ''' + This function checks if the chosen chart template is configured as containing a full set of taxes, and if + it's not the case, it creates the templates for account.tax.code and for account.account.tax objects accordingly + to the provided sale/purchase rates. Then it saves the new tax templates as default taxes to use for this chart + template. + + :param obj_wizard: browse record of wizard to generate COA from templates + :param company_id: id of the company for wich the wizard is running + :return: True + ''' + obj_tax_code_template = self.pool.get('account.tax.code.template') + obj_tax_temp = self.pool.get('account.tax.template') + chart_template = obj_wizard.chart_template_id + vals = {} + # create tax templates and tax code templates from purchase_tax_rate and sale_tax_rate fields + if not chart_template.complete_tax_set: + tax_data = { + 'sale': obj_wizard.sale_tax_rate, + 'purchase': obj_wizard.purchase_tax_rate, } - if r: - #the property exist: modify it - property_obj.write(cr, uid, r, vals) - else: - #create the property - property_obj.create(cr, uid, vals) + for tax_type, value in tax_data.items(): + # don't consider cases where entered value in rates are lower than 0 + if value >= 0.0: + #create the tax code templates for base and tax + base_code_vals = { + 'name': (tax_type == 'sale' and _('Taxable Sales at %s') or _('Taxable Purchases at %s')) % value, + 'code': (tax_type == 'sale' and _('BASE-S-%s') or _('BASE-P-%s')) %value, + 'parent_id': chart_template.tax_code_root_id.id, + 'company_id': company_id, + } + new_base_code_id = obj_tax_code_template.create(cr, uid, base_code_vals, context=context) + tax_code_vals = { + 'name': (tax_type == 'sale' and _('Tax Received at %s') or _('Tax Paid at %s')) % value, + 'code': (tax_type == 'sale' and _('TAX-S-%s') or _('TAX-P-%s')) %value, + 'parent_id': chart_template.tax_code_root_id.id, + 'company_id': company_id, + } + new_tax_code_id = obj_tax_code_template.create(cr, uid, tax_code_vals, context=context) + #create the tax + tax_template_id = obj_tax_temp.create(cr, uid, { + 'name': _('Tax %s%%') % value, + 'amount': value/100, + 'base_code_id': new_base_code_id, + 'tax_code_id': new_tax_code_id, + 'ref_base_code_id': new_base_code_id, + 'ref_tax_code_id': new_tax_code_id, + 'type_tax_use': tax_type, + 'type': 'percent', + 'sequence': 0, + 'chart_template_id': chart_template.id or False, + }, context=context) + #record this new tax_template as default for this chart template + field_name = tax_type == 'sale' and 'sale_tax' or 'purchase_tax' + vals[field_name] = tax_template_id + self.write(cr, uid, obj_wizard.id, vals, context=context) + return True - fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)]) + def execute(self, cr, uid, ids, context=None): + ''' + This function is called at the confirmation of the wizard to generate the COA from the templates. It will read + all the provided information to create the accounts, the banks, the journals, the taxes, the tax codes, the + accounting properties... accordingly for the chosen company. + ''' + ir_values_obj = self.pool.get('ir.values') + obj_wizard = self.browse(cr, uid, ids[0]) + company_id = obj_wizard.company_id.id + # If the floats for sale/purchase rates have been filled, create templates from them + self._create_tax_templates_from_rates(cr, uid, obj_wizard, company_id, context=context) - if fp_ids: - obj_tax_fp = self.pool.get('account.fiscal.position.tax') - obj_ac_fp = self.pool.get('account.fiscal.position.account') + # Install all the templates objects and generate the real objects + acc_template_ref, taxes_ref, tax_code_ref = self._install_template(cr, uid, obj_wizard.chart_template_id.id, company_id, code_digits=obj_wizard.code_digits, obj_wizard=obj_wizard, context=context) - for position in obj_fiscal_position_template.browse(cr, uid, fp_ids, context=context): + # write values of default taxes for product + if obj_wizard.sale_tax and taxes_ref: + ir_values_obj.set(cr, uid, key='default', key2=False, name="taxes_id", company=company_id, + models =[('product.product',False)], value=[taxes_ref[obj_wizard.sale_tax.id]]) + if obj_wizard.purchase_tax and taxes_ref: + ir_values_obj.set(cr, uid, key='default', key2=False, name="supplier_taxes_id", company=company_id, + models =[('product.product',False)], value=[taxes_ref[obj_wizard.purchase_tax.id]]) - vals_fp = { - 'company_id': company_id, - 'name': position.name, + # Create Bank journals + self._create_bank_journals_from_o2m(cr, uid, obj_wizard, company_id, acc_template_ref, context=context) + return True + + def _prepare_bank_journal(self, cr, uid, line, current_num, default_account_id, company_id, context=None): + ''' + This function prepares the value to use for the creation of a bank journal created through the wizard of + generating COA from templates. + + :param line: dictionary containing the values encoded by the user related to his bank account + :param current_num: integer corresponding to a counter of the already created bank journals through this wizard. + :param default_account_id: id of the default debit.credit account created before for this journal. + :param company_id: id of the company for which the wizard is running + :return: mapping of field names and values + :rtype: dict + ''' + obj_data = self.pool.get('ir.model.data') + # Get the id of journal views + tmp = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view_multi') + view_id_cur = tmp and tmp[1] or False + tmp = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view') + view_id_cash = tmp and tmp[1] or False + vals = { + 'name': line['acc_name'], + 'code': _('BNK') + str(current_num), + 'type': line['account_type'] == 'cash' and 'cash' or 'bank', + 'company_id': company_id, + 'analytic_journal_id': False, + 'currency': False, + 'default_credit_account_id': default_account_id, + 'default_debit_account_id': default_account_id, + } + if line['currency_id']: + vals['view_id'] = view_id_cur + vals['currency'] = line['currency_id'] + else: + vals['view_id'] = view_id_cash + return vals + + def _prepare_bank_account(self, cr, uid, line, new_code, acc_template_ref, ref_acc_bank, company_id, context=None): + ''' + This function prepares the value to use for the creation of the default debit and credit accounts of a + bank journal created through the wizard of generating COA from templates. + + :param line: dictionary containing the values encoded by the user related to his bank account + :param new_code: integer corresponding to the next available number to use as account code + :param acc_template_ref: the dictionary containing the mapping between the ids of account templates and the ids + of the accounts that have been generated from them. + :param ref_acc_bank: browse record of the account template set as root of all bank accounts for the chosen + template + :param company_id: id of the company for which the wizard is running + :return: mapping of field names and values + :rtype: dict + ''' + obj_data = self.pool.get('ir.model.data') + + # Get the id of the user types fr-or cash and bank + tmp = obj_data.get_object_reference(cr, uid, 'account', 'data_account_type_cash') + cash_type = tmp and tmp[1] or False + tmp = obj_data.get_object_reference(cr, uid, 'account', 'data_account_type_bank') + bank_type = tmp and tmp[1] or False + return { + 'name': line['acc_name'], + 'currency_id': line['currency_id'], + 'code': new_code, + 'type': 'liquidity', + 'user_type': line['account_type'] == 'cash' and cash_type or bank_type, + 'parent_id': acc_template_ref[ref_acc_bank.id] or False, + 'company_id': company_id, + } + + def _create_bank_journals_from_o2m(self, cr, uid, obj_wizard, company_id, acc_template_ref, context=None): + ''' + This function creates bank journals and its accounts for each line encoded in the field bank_accounts_id of the + wizard. + + :param obj_wizard: the current wizard that generates the COA from the templates. + :param company_id: the id of the company for which the wizard is running. + :param acc_template_ref: the dictionary containing the mapping between the ids of account templates and the ids + of the accounts that have been generated from them. + :return: True + ''' + obj_acc = self.pool.get('account.account') + obj_journal = self.pool.get('account.journal') + code_digits = obj_wizard.code_digits + + # Build a list with all the data to process + journal_data = [] + if obj_wizard.bank_accounts_id: + for acc in obj_wizard.bank_accounts_id: + vals = { + 'acc_name': acc.acc_name, + 'account_type': acc.account_type, + 'currency_id': acc.currency_id.id, } - new_fp = obj_fiscal_position.create(cr, uid, vals_fp) + journal_data.append(vals) + ref_acc_bank = obj_wizard.chart_template_id.bank_account_view_id + if journal_data and not ref_acc_bank.code: + raise osv.except_osv(_('Configuration Error !'), _('The bank account defined on the selected chart of accounts hasn\'t a code.')) - for tax in position.tax_ids: - vals_tax = { - 'tax_src_id': tax_template_ref[tax.tax_src_id.id], - 'tax_dest_id': tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False, - 'position_id': new_fp, - } - obj_tax_fp.create(cr, uid, vals_tax) + current_num = 1 + for line in journal_data: + # Seek the next available number for the account code + while True: + new_code = str(ref_acc_bank.code.ljust(code_digits-len(str(current_num)), '0')) + str(current_num) + ids = obj_acc.search(cr, uid, [('code', '=', new_code), ('company_id', '=', company_id)]) + if not ids: + break + else: + current_num += 1 + # Create the default debit/credit accounts for this bank journal + vals = self._prepare_bank_account(cr, uid, line, new_code, acc_template_ref, ref_acc_bank, company_id, context=context) + default_account_id = obj_acc.create(cr, uid, vals, context=context) - for acc in position.account_ids: - vals_acc = { - 'account_src_id': acc_template_ref[acc.account_src_id.id], - 'account_dest_id': acc_template_ref[acc.account_dest_id.id], - 'position_id': new_fp, - } - obj_ac_fp.create(cr, uid, vals_acc) - - if obj_multi.sale_tax: - ir_values_obj.set(cr, uid, key='default', key2=False, name="taxes_id", company=obj_multi.company_id.id, - models =[('product.product',False)], value=[tax_template_to_tax[obj_multi.sale_tax.id]]) - if obj_multi.purchase_tax: - ir_values_obj.set(cr, uid, key='default', key2=False, name="supplier_taxes_id", company=obj_multi.company_id.id, - models =[('product.product',False)], value=[tax_template_to_tax[obj_multi.purchase_tax.id]]) + #create the bank journal + vals_journal = self._prepare_bank_journal(cr, uid, line, current_num, default_account_id, company_id, context=context) + obj_journal.create(cr, uid, vals_journal) + current_num += 1 + return True wizard_multi_charts_accounts() diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 85d9805eb32..ab36586fe2f 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -34,8 +34,6 @@ class account_bank_statement(osv.osv): for line in vals['line_ids']: seq += 1 line[2]['sequence'] = seq - new_line_ids += tuple(line) - vals['line_ids'] = new_line_ids return super(account_bank_statement, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index e249f8fa872..cbdb665e157 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -34,10 +34,6 @@ - - - - diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 0d664d45d32..59a2a8eaa19 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1753,18 +1753,18 @@
- - - - - - - - - - - - + + + + + + + + + + + + @@ -2114,6 +2114,7 @@ + @@ -2184,9 +2185,13 @@ - - - + + + + + + + @@ -2270,7 +2275,9 @@ - + + + @@ -2437,10 +2444,13 @@ - - - - + + + + + + + diff --git a/addons/account/board_account_view.xml b/addons/account/board_account_view.xml index 5108a62cf3e..63b525ca0b9 100644 --- a/addons/account/board_account_view.xml +++ b/addons/account/board_account_view.xml @@ -46,7 +46,6 @@ - diff --git a/addons/account/data/data_account_type.xml b/addons/account/data/data_account_type.xml new file mode 100644 index 00000000000..ebed0ebb5de --- /dev/null +++ b/addons/account/data/data_account_type.xml @@ -0,0 +1,51 @@ + + + + + View + view + none + + + Receivable + receivable + unreconciled + + + Payable + payable + unreconciled + + + Bank + bank + balance + + + Cash + cash + balance + + + Asset + asset + balance + + + Liability + liability + balance + + + Income + income + none + + + Expense + expense + none + + + + diff --git a/addons/account/installer.py b/addons/account/installer.py index a0157e51c8e..cfd434833ae 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -23,7 +23,6 @@ import logging import time import datetime from dateutil.relativedelta import relativedelta -from os.path import join as opj from operator import itemgetter from tools.translate import _ @@ -58,8 +57,6 @@ class account_installer(osv.osv_memory): 'date_start': fields.date('Start Date', required=True), 'date_stop': fields.date('End Date', required=True), 'period': fields.selection([('month', 'Monthly'), ('3months','3 Monthly')], 'Periods', required=True), - 'sale_tax': fields.float('Sale Tax(%)'), - 'purchase_tax': fields.float('Purchase Tax(%)'), 'company_id': fields.many2one('res.company', 'Company', required=True), 'has_default_company' : fields.boolean('Has Default Company', readonly=True), } @@ -76,8 +73,6 @@ class account_installer(osv.osv_memory): 'date_start': lambda *a: time.strftime('%Y-01-01'), 'date_stop': lambda *a: time.strftime('%Y-12-31'), 'period': 'month', - 'sale_tax': 0.0, - 'purchase_tax': 0.0, 'company_id': _default_company, 'has_default_company': _default_has_default_company, 'charts': 'configurable' @@ -100,9 +95,6 @@ class account_installer(osv.osv_memory): res['fields'][field]['selection'] = cmp_select return res - def on_change_tax(self, cr, uid, id, tax): - return {'value': {'purchase_tax': tax}} - def on_change_start_date(self, cr, uid, id, start_date=False): if start_date: start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d") @@ -118,92 +110,7 @@ class account_installer(osv.osv_memory): if context is None: context = {} fy_obj = self.pool.get('account.fiscalyear') - mod_obj = self.pool.get('ir.model.data') - obj_acc_temp = self.pool.get('account.account.template') - obj_tax_code_temp = self.pool.get('account.tax.code.template') - obj_tax_temp = self.pool.get('account.tax.template') - obj_acc_chart_temp = self.pool.get('account.chart.template') - record = self.browse(cr, uid, ids, context=context)[0] for res in self.read(cr, uid, ids, context=context): - if record.charts == 'configurable': - fp = tools.file_open(opj('account', 'configurable_account_chart.xml')) - tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None) - fp.close() - s_tax = (res.get('sale_tax', 0.0))/100 - p_tax = (res.get('purchase_tax', 0.0))/100 - pur_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_purchases') - pur_temp_tax_id = pur_temp_tax and pur_temp_tax[1] or False - - pur_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_output') - pur_temp_tax_paid_id = pur_temp_tax_paid and pur_temp_tax_paid[1] or False - - sale_temp_tax = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_base_sales') - sale_temp_tax_id = sale_temp_tax and sale_temp_tax[1] or False - - sale_temp_tax_paid = mod_obj.get_object_reference(cr, uid, 'account', 'tax_code_input') - sale_temp_tax_paid_id = sale_temp_tax_paid and sale_temp_tax_paid[1] or False - - chart_temp_ids = obj_acc_chart_temp.search(cr, uid, [('name','=','Configurable Account Chart Template')], context=context) - chart_temp_id = chart_temp_ids and chart_temp_ids[0] or False - if s_tax * 100 > 0.0: - tax_account_ids = obj_acc_temp.search(cr, uid, [('name', '=', 'Tax Received')], context=context) - sales_tax_account_id = tax_account_ids and tax_account_ids[0] or False - vals_tax_code_temp = { - 'name': _('TAX %s%%') % (s_tax*100), - 'code': _('TAX %s%%') % (s_tax*100), - 'parent_id': sale_temp_tax_id - } - new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context) - vals_paid_tax_code_temp = { - 'name': _('TAX Received %s%%') % (s_tax*100), - 'code': _('TAX Received %s%%') % (s_tax*100), - 'parent_id': sale_temp_tax_paid_id - } - new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context) - sales_tax_temp = obj_tax_temp.create(cr, uid, { - 'name': _('Sale TAX %s%%') % (s_tax*100), - 'amount': s_tax, - 'base_code_id': new_tax_code_temp, - 'tax_code_id': new_paid_tax_code_temp, - 'ref_base_code_id': new_tax_code_temp, - 'ref_tax_code_id': new_paid_tax_code_temp, - 'type_tax_use': 'sale', - 'type': 'percent', - 'sequence': 0, - 'account_collected_id': sales_tax_account_id, - 'account_paid_id': sales_tax_account_id, - 'chart_template_id': chart_temp_id, - }, context=context) - if p_tax * 100 > 0.0: - tax_account_ids = obj_acc_temp.search(cr, uid, [('name', '=', 'Tax Paid')], context=context) - purchase_tax_account_id = tax_account_ids and tax_account_ids[0] or False - vals_tax_code_temp = { - 'name': _('TAX %s%%') % (p_tax*100), - 'code': _('TAX %s%%') % (p_tax*100), - 'parent_id': pur_temp_tax_id - } - new_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_tax_code_temp, context=context) - vals_paid_tax_code_temp = { - 'name': _('TAX Paid %s%%') % (p_tax*100), - 'code': _('TAX Paid %s%%') % (p_tax*100), - 'parent_id': pur_temp_tax_paid_id - } - new_paid_tax_code_temp = obj_tax_code_temp.create(cr, uid, vals_paid_tax_code_temp, context=context) - purchase_tax_temp = obj_tax_temp.create(cr, uid, { - 'name': _('Purchase TAX %s%%') % (p_tax*100), - 'amount': p_tax, - 'base_code_id': new_tax_code_temp, - 'tax_code_id': new_paid_tax_code_temp, - 'ref_base_code_id': new_tax_code_temp, - 'ref_tax_code_id': new_paid_tax_code_temp, - 'type_tax_use': 'purchase', - 'type': 'percent', - 'sequence': 0, - 'account_collected_id': purchase_tax_account_id, - 'account_paid_id': purchase_tax_account_id, - 'chart_template_id': chart_temp_id, - }, context=context) - if 'date_start' in res and 'date_stop' in res: f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'][0])], context=context) if not f_ids: diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 88ae17f3c7b..d82eff62142 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -66,7 +66,6 @@ import account_change_currency import account_report_balance_sheet import account_report_profit_loss - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_accountant/static/src/img/icon.png b/addons/account_accountant/static/src/img/icon.png new file mode 100644 index 00000000000..611053684cc Binary files /dev/null and b/addons/account_accountant/static/src/img/icon.png differ diff --git a/addons/account_analytic_analysis/__openerp__.py b/addons/account_analytic_analysis/__openerp__.py index ee887e1ff6a..01ef6a3cb81 100644 --- a/addons/account_analytic_analysis/__openerp__.py +++ b/addons/account_analytic_analysis/__openerp__.py @@ -46,7 +46,6 @@ user-wise as well as month wise. ], 'demo_xml' : [], 'installable': True, - 'application': True, 'active' : False, 'certificate': '0042927202589', } diff --git a/addons/account_asset/i18n/pt.po b/addons/account_asset/i18n/pt.po index 126515e07a9..6683b7227db 100755 --- a/addons/account_asset/i18n/pt.po +++ b/addons/account_asset/i18n/pt.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-11-24 12:54+0000\n" -"PO-Revision-Date: 2011-07-12 12:04+0000\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-12-10 11:58+0000\n" +"Last-Translator: Paulino Ascenção \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-11-05 05:57+0000\n" -"X-Generator: Launchpad (build 14231)\n" +"X-Launchpad-Export-Date: 2011-12-11 05:36+0000\n" +"X-Generator: Launchpad (build 14450)\n" #. module: account_asset #: model:ir.actions.act_window,name:account_asset.action_account_asset_asset_list_normal @@ -27,12 +27,12 @@ msgstr "Activos em Aberto" #: field:account.asset.property,method_end:0 #: field:account.asset.property.history,method_end:0 msgid "Ending date" -msgstr "" +msgstr "Data final" #. module: account_asset #: view:account.asset.asset:0 msgid "Depreciation board" -msgstr "" +msgstr "Painel de amortização" #. module: account_asset #: view:account.asset.asset:0 @@ -60,7 +60,7 @@ msgstr "Linear" #. module: account_asset #: view:account.asset.asset:0 msgid "Change duration" -msgstr "" +msgstr "Alterar a duração" #. module: account_asset #: field:account.asset.asset,child_ids:0 @@ -70,12 +70,12 @@ msgstr "Activos filho" #. module: account_asset #: field:account.asset.board,value_asset:0 msgid "Asset Value" -msgstr "Valor do Imobilizado" +msgstr "Valor do Ativo" #. module: account_asset #: wizard_field:account.asset.modify,init,name:0 msgid "Reason" -msgstr "" +msgstr "Motivo" #. module: account_asset #: view:account.asset.asset:0 @@ -94,7 +94,7 @@ msgstr "Movimentos gerados" #: field:account.asset.property,method_delay:0 #: field:account.asset.property.history,method_delay:0 msgid "Number of interval" -msgstr "" +msgstr "Número de intervalo" #. module: account_asset #: wizard_button:account.asset.compute,asset_compute,asset_open:0 @@ -136,7 +136,7 @@ msgstr "Histórico de alterações" #. module: account_asset #: view:account.asset.asset:0 msgid "Depreciation entries" -msgstr "" +msgstr "Lançamentos de amortização" #. module: account_asset #: view:account.asset.asset:0 @@ -158,12 +158,12 @@ msgstr "Terceiro" #: field:account.asset.property,method_period:0 #: field:account.asset.property.history,method_period:0 msgid "Period per interval" -msgstr "" +msgstr "Período por intervalo" #. module: account_asset #: view:account.asset.asset:0 msgid "Depreciation duration" -msgstr "" +msgstr "Duração da amortização" #. module: account_asset #: field:account.asset.property,account_analytic_id:0 @@ -178,7 +178,7 @@ msgstr "Estado" #. module: account_asset #: view:account.asset.asset:0 msgid "Depreciation methods" -msgstr "" +msgstr "Métodos de amortização" #. module: account_asset #: view:account.asset.asset:0 @@ -188,12 +188,12 @@ msgstr "Outra informação" #. module: account_asset #: field:account.asset.board,value_asset_cumul:0 msgid "Cumul. value" -msgstr "" +msgstr "Valor acumulado" #. module: account_asset #: view:account.asset.property:0 msgid "Assets methods" -msgstr "" +msgstr "Métodos de imobilizado" #. module: account_asset #: constraint:ir.ui.view:0 @@ -203,7 +203,7 @@ msgstr "XML Inválido para a Arquitectura de Vista!" #. module: account_asset #: model:ir.model,name:account_asset.model_account_asset_property msgid "Asset property" -msgstr "" +msgstr "Propriedade do ativo" #. module: account_asset #: wizard_view:account.asset.compute,asset_compute:0 @@ -273,7 +273,7 @@ msgstr "Nome do activo" #. module: account_asset #: view:account.asset.asset:0 msgid "Accounts information" -msgstr "" +msgstr "Informação das contas" #. module: account_asset #: field:account.asset.asset,note:0 @@ -291,7 +291,7 @@ msgstr "Rascunho" #. module: account_asset #: field:account.asset.property,type:0 msgid "Depr. method type" -msgstr "" +msgstr "Tipo de método de amotiz." #. module: account_asset #: field:account.asset.property,account_asset_id:0 @@ -311,7 +311,7 @@ msgstr "Normal" #. module: account_asset #: field:account.asset.property,method_progress_factor:0 msgid "Progressif factor" -msgstr "" +msgstr "Fator de progressividade" #. module: account_asset #: field:account.asset.asset,localisation:0 @@ -326,7 +326,7 @@ msgstr "Método de cálculo" #. module: account_asset #: field:account.asset.property,method_time:0 msgid "Time method" -msgstr "" +msgstr "Método temporal" #. module: account_asset #: field:account.asset.asset,active:0 @@ -341,7 +341,7 @@ msgstr "Utilizador" #. module: account_asset #: field:account.asset.asset,property_ids:0 msgid "Asset method name" -msgstr "" +msgstr "Nome do método de ativo" #. module: account_asset #: field:account.asset.asset,date:0 @@ -368,7 +368,7 @@ msgstr "Histórico" #. module: account_asset #: field:account.asset.property,account_actif_id:0 msgid "Depreciation account" -msgstr "" +msgstr "Conta de amortização" #. module: account_asset #: field:account.asset.asset,period_id:0 @@ -412,24 +412,24 @@ msgstr "" #. module: account_asset #: model:ir.module.module,shortdesc:account_asset.module_meta_information msgid "Asset management" -msgstr "Gestão de Activo" +msgstr "Gestão do Imobilizado" #. module: account_asset #: view:account.asset.board:0 #: field:account.asset.property,board_ids:0 #: model:ir.model,name:account_asset.model_account_asset_board msgid "Asset board" -msgstr "" +msgstr "Painel do imobilizado" #. module: account_asset #: field:account.asset.asset,state:0 msgid "Global state" -msgstr "" +msgstr "Estado global" #. module: account_asset #: selection:account.asset.property,method_time:0 msgid "Delay" -msgstr "" +msgstr "Demora" #. module: account_asset #: wizard_view:account.asset.close,init:0 @@ -439,7 +439,7 @@ msgstr "Informação geral" #. module: account_asset #: field:account.asset.property,journal_analytic_id:0 msgid "Analytic journal" -msgstr "" +msgstr "Diário analítico" #. module: account_asset #: field:account.asset.property,name:0 @@ -454,7 +454,7 @@ msgstr "Diário" #. module: account_asset #: field:account.asset.property.history,name:0 msgid "History name" -msgstr "Nome de História" +msgstr "Nome de histórico" #. module: account_asset #: view:account.asset.asset:0 @@ -477,13 +477,13 @@ msgstr "Categoria de activos" #. module: account_asset #: view:account.asset.asset:0 msgid "Depreciation" -msgstr "" +msgstr "Amortização" #. module: account_asset #: field:account.asset.asset,code:0 #: field:account.asset.category,code:0 msgid "Asset code" -msgstr "Código de imobilizado" +msgstr "Código do ativo" #. module: account_asset #: field:account.asset.asset,value_total:0 diff --git a/addons/account_sequence/i18n/pt.po b/addons/account_sequence/i18n/pt.po index 84c22715b25..e2e827d4e57 100644 --- a/addons/account_sequence/i18n/pt.po +++ b/addons/account_sequence/i18n/pt.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-01-11 11:14+0000\n" -"PO-Revision-Date: 2011-04-24 03:28+0000\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-12-09 10:09+0000\n" +"Last-Translator: Paulino Ascenção \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-11-05 05:56+0000\n" -"X-Generator: Launchpad (build 14231)\n" +"X-Launchpad-Export-Date: 2011-12-10 04:56+0000\n" +"X-Generator: Launchpad (build 14450)\n" #. module: account_sequence #: view:account.sequence.installer:0 @@ -28,12 +28,13 @@ msgstr "" msgid "" "You cannot create entries on different periods/journals in the same move" msgstr "" +"Não pode criar registos em períodos ou diários diferentes no mesmo movimento" #. module: account_sequence #: help:account.move,internal_sequence_number:0 #: help:account.move.line,internal_sequence_number:0 msgid "Internal Sequence Number" -msgstr "" +msgstr "Número interno de sequência" #. module: account_sequence #: help:account.sequence.installer,number_next:0 @@ -43,12 +44,12 @@ msgstr "" #. module: account_sequence #: field:account.sequence.installer,number_next:0 msgid "Next Number" -msgstr "" +msgstr "Próximo número" #. module: account_sequence #: field:account.sequence.installer,number_increment:0 msgid "Increment Number" -msgstr "" +msgstr "Incremento" #. module: account_sequence #: model:ir.module.module,description:account_sequence.module_meta_information @@ -57,6 +58,10 @@ msgid "" " This module maintains internal sequence number for accounting entries.\n" " " msgstr "" +"\n" +" Esse módulo gere os números de sequência internos dos lançamentos " +"contabilísticos.\n" +" " #. module: account_sequence #: model:ir.module.module,shortdesc:account_sequence.module_meta_information diff --git a/addons/account_voucher/static/src/img/icon.png b/addons/account_voucher/static/src/img/icon.png new file mode 100644 index 00000000000..afad1331e2e Binary files /dev/null and b/addons/account_voucher/static/src/img/icon.png differ diff --git a/addons/association/__openerp__.py b/addons/association/__openerp__.py index 8aad18575ff..36622a5750d 100644 --- a/addons/association/__openerp__.py +++ b/addons/association/__openerp__.py @@ -37,7 +37,6 @@ It installs the profile for associations to manage events, registrations, member 'demo_xml': [], 'installable': True, 'active': False, - 'application': True, 'certificate': '0078696047261', 'images': ['images/association1.jpeg'], } diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 45624a280f1..9ce32429e5b 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1009,10 +1009,19 @@ class calendar_event(osv.osv): else: result[event] = "" return result - - - - + + def _rrule_write(self, obj, cr, uid, ids, field_name, field_value, args, context=None): + data = self._get_empty_rrule_data() + if field_value: + data['recurrency'] = True + for event in self.browse(cr, uid, ids, context=context): + rdate = rule_date or event.date + update_data = self._parse_rrule(field_value, dict(data), rdate) + data.update(update_data) + super(calendar_event, obj).write(cr, uid, ids, data, context=context) + return True + + _columns = { 'id': fields.integer('ID', readonly=True), 'sequence': fields.integer('Sequence'), @@ -1023,7 +1032,7 @@ class calendar_event(osv.osv): 'duration': fields.float('Duration', states={'done': [('readonly', True)]}), 'description': fields.text('Description', states={'done': [('readonly', True)]}), 'class': fields.selection([('public', 'Public'), ('private', 'Private'), \ - ('confidential', 'Confidential')], 'Mark as', states={'done': [('readonly', True)]}), + ('confidential', 'Public for Employees')], 'Mark as', states={'done': [('readonly', True)]}), 'location': fields.char('Location', size=264, help="Location of Event", states={'done': [('readonly', True)]}), 'show_as': fields.selection([('free', 'Free'), ('busy', 'Busy')], \ 'Show as', states={'done': [('readonly', True)]}), @@ -1036,7 +1045,7 @@ defines the list of date/time exceptions for a recurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="Defines a \ rule or repeating pattern of time to exclude from the recurring rule."), 'rrule': fields.function(_get_rulestring, type='char', size=124, \ - store=True, string='Recurrent Rule'), + fnct_inv=_rrule_write, store=True, string='Recurrent Rule'), 'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \ ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ ('yearly', 'Yearly'),], @@ -1079,7 +1088,6 @@ rule or repeating pattern of time to exclude from the recurring rule."), 'active': fields.boolean('Active', help="If the active field is set to \ true, it will allow you to hide the event alarm information without removing it."), 'recurrency': fields.boolean('Recurrent', help="Recurrent Meeting"), - 'edit_all': fields.boolean('Edit All', help="Edit all Occurrences of recurrent Meeting."), } def default_organizer(self, cr, uid, context=None): @@ -1102,83 +1110,68 @@ rule or repeating pattern of time to exclude from the recurring rule."), 'active': 1, 'user_id': lambda self, cr, uid, ctx: uid, 'organizer': default_organizer, - 'edit_all' : False, } - def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100, context=None): + def get_recurrent_ids(self, cr, uid, select, domain, limit=100, context=None): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param base_start_date: Get Start Date - @param base_until_date: Get End Date @param limit: The Number of Results to Return """ if not context: context = {} - virtual_id = context and context.get('virtual_id', False) or False - - if isinstance(select, (str, int, long)): - ids = [select] - else: - ids = select result = [] - if ids and virtual_id: - for data in super(calendar_event, self).read(cr, uid, ids, context=context): - start_date = base_start_date and datetime.strptime(base_start_date[:10]+ ' 00:00:00' , "%Y-%m-%d %H:%M:%S") or False - until_date = base_until_date and datetime.strptime(base_until_date[:10]+ ' 23:59:59', "%Y-%m-%d %H:%M:%S") or False - event_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") + for data in super(calendar_event, self).read(cr, uid, select, context=context): + if not data['rrule']: + result.append(data['id']) + continue + event_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") # To check: If the start date is replace by event date .. the event date will be changed by that of calendar code - - if not data['rrule']: - if start_date and (event_date < start_date): - continue - if until_date and (event_date > until_date): - continue - idval = data['id'] - result.append(idval) - else: - start_date = event_date - exdate = data['exdate'] and data['exdate'].split(',') or [] - rrule_str = data['rrule'] - new_rrule_str = [] - rrule_until_date = False - is_until = False - for rule in rrule_str.split(';'): - name, value = rule.split('=') - if name == "UNTIL": - is_until = True - value = parser.parse(value) - rrule_until_date = parser.parse(value.strftime("%Y-%m-%d %H:%M:%S")) - if until_date and until_date >= rrule_until_date: - until_date = rrule_until_date - if until_date: - value = until_date.strftime("%Y%m%d%H%M%S") - else: - value = value.strftime("%Y%m%d%H%M%S") - new_rule = '%s=%s' % (name, value) - new_rrule_str.append(new_rule) - if not is_until and until_date: - value = until_date.strftime("%Y%m%d%H%M%S") - name = "UNTIL" - new_rule = '%s=%s' % (name, value) - new_rrule_str.append(new_rule) - new_rrule_str = ';'.join(new_rrule_str) - rdates = get_recurrent_dates(str(new_rrule_str), exdate, start_date, data['exrule']) - - for r_date in rdates: - if start_date and r_date < start_date: - continue - if until_date and r_date > until_date: - continue - idval = real_id2base_calendar_id(data['id'], r_date.strftime("%Y-%m-%d %H:%M:%S")) - result.append(idval) - if result: - ids = list(set(result)) + if not data['rrule']: + continue + + exdate = data['exdate'] and data['exdate'].split(',') or [] + rrule_str = data['rrule'] + new_rrule_str = [] + rrule_until_date = False + is_until = False + for rule in rrule_str.split(';'): + name, value = rule.split('=') + if name == "UNTIL": + is_until = True + value = parser.parse(value) + rrule_until_date = parser.parse(value.strftime("%Y-%m-%d %H:%M:%S")) + value = value.strftime("%Y%m%d%H%M%S") + new_rule = '%s=%s' % (name, value) + new_rrule_str.append(new_rule) + new_rrule_str = ';'.join(new_rrule_str) + rdates = get_recurrent_dates(str(new_rrule_str), exdate, event_date, data['exrule']) + for r_date in rdates: + ok = True + for arg in domain: + if arg[0] in ('date', 'date_deadline'): + if (arg[1]=='='): + ok = ok and r_date.strftime('%Y-%m-%d')==arg[2] + if (arg[1]=='>'): + ok = ok and r_date.strftime('%Y-%m-%d')>arg[2] + if (arg[1]=='<'): + ok = ok and r_date.strftime('%Y-%m-%d')='): + ok = ok and r_date.strftime('%Y-%m-%d')>=arg[2] + if (arg[1]=='<='): + ok = ok and r_date.strftime('%Y-%m-%d')<=arg[2] + if not ok: + continue + idval = real_id2base_calendar_id(data['id'], r_date.strftime("%Y-%m-%d %H:%M:%S")) + result.append(idval) + if isinstance(select, (str, int, long)): return ids and ids[0] or False + else: + ids = list(set(result)) return ids def compute_rule_string(self, datas): @@ -1243,17 +1236,17 @@ rule or repeating pattern of time to exclude from the recurring rule."), 'week_list' : False } - def _write_rrule(self, cr, uid, ids, field_value, rule_date=False, context=None): - data = self._get_empty_rrule_data() - - if field_value: - data['recurrency'] = True - for event in self.browse(cr, uid, ids, context=context): - rdate = rule_date or event.date - update_data = self._parse_rrule(field_value, dict(data), rdate) - data.update(update_data) - #parse_rrule - self.write(cr, uid, event.id, data, context=context) + #def _write_rrule(self, cr, uid, ids, field_value, rule_date=False, context=None): + # data = self._get_empty_rrule_data() + # + # if field_value: + # data['recurrency'] = True + # for event in self.browse(cr, uid, ids, context=context): + # rdate = rule_date or event.date + # update_data = self._parse_rrule(field_value, dict(data), rdate) + # data.update(update_data) + # #parse_rrule + # self.write(cr, uid, event.id, data, context=context) def _parse_rrule(self, rule, data, date_start): @@ -1311,9 +1304,9 @@ rule or repeating pattern of time to exclude from the recurring rule."), return res def search(self, cr, uid, args, offset=0, limit=0, order=None, context=None, count=False): + context = context or {} args_without_date = [] - start_date = False - until_date = False + filter_date = [] for arg in args: if arg[0] == "id": @@ -1323,17 +1316,18 @@ rule or repeating pattern of time to exclude from the recurring rule."), elif arg[0] not in ('date', unicode('date'), 'date_deadline', unicode('date_deadline')): args_without_date.append(arg) else: - if arg[1] in ('>', '>='): - if start_date: - continue - start_date = arg[2] - elif arg[1] in ('<', '<='): - if until_date: - continue - until_date = arg[2] + if context.get('virtual_id', True): + args_without_date.append('|') + args_without_date.append(arg) + if context.get('virtual_id', True): + args_without_date.append(('recurrency','=',1)) + filter_date.append(arg) + res = super(calendar_event, self).search(cr, uid, args_without_date, \ 0, 0, order, context, count=False) - res = self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit, context=context) + if context.get('virtual_id', True): + res = self.get_recurrent_ids(cr, uid, res, args, limit, context=context) + if count: return len(res) elif limit: @@ -1341,17 +1335,6 @@ rule or repeating pattern of time to exclude from the recurring rule."), else: return res - def get_edit_all(self, cr, uid, id, vals=None): - """ - return true if we have to edit all meeting from the same recurrent - or only on occurency - """ - meeting = self.read(cr,uid, id, ['edit_all', 'recurrency'] ) - if(vals and 'edit_all' in vals): #we jsut check edit_all - return vals['edit_all'] - else: #it's a recurrent event and edit_all is already check - return meeting['recurrency'] and meeting['edit_all'] - def _get_data(self, cr, uid, id, context=None): res = self.read(cr, uid, [id],['date', 'date_deadline']) return res[0] @@ -1370,101 +1353,63 @@ rule or repeating pattern of time to exclude from the recurring rule."), def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): - if context is None: - context = {} + context = context or {} if isinstance(ids, (str, int, long)): - select = [ids] - else: - select = ids - - - - new_ids = [] + ids = [ids] res = False - for event_id in select: + + # Special write of complex IDS + for event_id in ids[:]: + if len(str(event_id).split('-')) == 1: + continue + ids.remove(event_id) real_event_id = base_calendar_id2real_id(event_id) - edit_all = self.get_edit_all(cr, uid, event_id, vals=vals) - if edit_all: - if self.need_to_update(event_id, vals): - res = self._get_data(cr, uid, real_event_id, context=context) - vals.update(res) - event_id = real_event_id + if not vals.get('recurrency', True): + ids.append(real_event_id) + continue #if edit one instance of a reccurrent id - if len(str(event_id).split('-')) > 1 and not edit_all: - data = self.read(cr, uid, event_id, ['date', 'date_deadline', \ - 'rrule', 'duration', 'exdate']) - if data.get('rrule'): - data.update(vals) - data.update({ - 'recurrent_uid': real_event_id, - 'recurrent_id': data.get('date'), - 'rrule_type': 'none', - 'rrule': '', - 'edit_all': False, - 'recurrency' : False, - }) + data = self.read(cr, uid, event_id, ['date', 'date_deadline', \ + 'rrule', 'duration', 'exdate']) + if data.get('rrule'): + data.update(vals) + data.update({ + 'recurrent_uid': real_event_id, + 'recurrent_id': data.get('date'), + 'rrule_type': 'none', + 'rrule': '', + 'recurrency' : False, + }) - new_id = self.copy(cr, uid, real_event_id, default=data, context=context) + new_id = self.copy(cr, uid, real_event_id, default=data, context=context) - date_new = event_id.split('-')[1] - date_new = time.strftime("%Y%m%dT%H%M%S", \ - time.strptime(date_new, "%Y%m%d%H%M%S")) - exdate = (data['exdate'] and (data['exdate'] + ',') or '') + date_new - res = self.write(cr, uid, [real_event_id], {'exdate': exdate}) + date_new = event_id.split('-')[1] + date_new = time.strftime("%Y%m%dT%H%M%S", \ + time.strptime(date_new, "%Y%m%d%H%M%S")) + exdate = (data['exdate'] and (data['exdate'] + ',') or '') + date_new + res = self.write(cr, uid, [real_event_id], {'exdate': exdate}) - context.update({'active_id': new_id, 'active_ids': [new_id]}) - continue - if not real_event_id in new_ids: - new_ids.append(real_event_id) + context.update({'active_id': new_id, 'active_ids': [new_id]}) + continue if vals.get('vtimezone', '') and vals.get('vtimezone', '').startswith('/freeassociation.sourceforge.net/tzfile/'): vals['vtimezone'] = vals['vtimezone'][40:] - updated_vals = self.onchange_dates(cr, uid, new_ids, - vals.get('date', False), - vals.get('duration', False), - vals.get('date_deadline', False), - vals.get('allday', False), - context=context) - vals.update(updated_vals.get('value', {})) - if new_ids: - if 'rrule' in vals.keys(): - if 'date' in vals.keys(): - date_to_write = vals['date'] - else: - date_to_write = False - self._write_rrule(cr, uid, new_ids, vals['rrule'], date_to_write, context) - - res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context) + res = super(calendar_event, self).write(cr, uid, ids, vals, context=context) if ('alarm_id' in vals or 'base_calendar_alarm_id' in vals)\ or ('date' in vals or 'duration' in vals or 'date_deadline' in vals): - # change alarm details alarm_obj = self.pool.get('res.alarm') - alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date', context=context) + alarm_obj.do_alarm_create(cr, uid, ids, self._name, 'date', context=context) return res or True and False - def browse(self, cr, uid, ids, context=None, list_class=None, fields_process=None): - if isinstance(ids, (str, int, long)): - select = [ids] - else: - select = ids - select = map(lambda x: base_calendar_id2real_id(x), select) - res = super(calendar_event, self).browse(cr, uid, select, context, \ - list_class, fields_process) - if isinstance(ids, (str, int, long)): - return res and res[0] or False - - return res - def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): if not context: context = {} if 'date' in groupby: raise osv.except_osv(_('Warning !'), _('Group by date not supported, use the calendar view instead')) - virtual_id = context.get('virtual_id', False) + virtual_id = context.get('virtual_id', True) context.update({'virtual_id': False}) res = super(calendar_event, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby) for re in res: @@ -1479,8 +1424,12 @@ rule or repeating pattern of time to exclude from the recurring rule."), # FIXME This whole id mangling has to go! if context is None: context = {} - + fields2 = fields and fields[:] or None + EXTRAFIELDS = ('class','user_id','date','duration') + for f in EXTRAFIELDS: + if fields and (f not in fields): + fields2.append(f) if isinstance(ids, (str, int, long)): select = [ids] @@ -1488,17 +1437,13 @@ rule or repeating pattern of time to exclude from the recurring rule."), select = ids select = map(lambda x: (x, base_calendar_id2real_id(x)), select) result = [] - if fields and 'date' not in fields: - fields.append('date') - if fields and 'duration' not in fields: - fields.append('duration') real_data = super(calendar_event, self).read(cr, uid, [real_id for base_calendar_id, real_id in select], - fields=fields, context=context, load=load) + fields=fields2, context=context, load=load) real_data = dict(zip([x['id'] for x in real_data], real_data)) - for base_calendar_id, real_id in select: + for base_calendar_id, real_id in select: res = real_data[real_id].copy() ls = base_calendar_id2real_id(base_calendar_id, with_date=res and res.get('duration', 0) or 0) if not isinstance(ls, (str, int, long)) and len(ls) >= 2: @@ -1507,9 +1452,25 @@ rule or repeating pattern of time to exclude from the recurring rule."), res['id'] = base_calendar_id result.append(res) + + for r in result: + if r['user_id']: + user_id = type(r['user_id']) in (tuple,list) and r['user_id'][0] or r['user_id'] + if user_id==uid: + continue + if r['class']=='private': + for f in r.keys(): + if f not in ('id','date','date_deadline','duration','user_id','state'): + r[f] = False + if f=='name': + r[f] = _('Busy') + + for r in result: + for k in EXTRAFIELDS: + if (k in r) and ((not fields) or (k not in fields)): + del r[k] if isinstance(ids, (str, int, long)): return result and result[0] or False - return result def copy(self, cr, uid, id, default=None, context=None): @@ -1520,68 +1481,49 @@ rule or repeating pattern of time to exclude from the recurring rule."), alarm_obj = self.pool.get('res.alarm') alarm_obj.do_alarm_create(cr, uid, [res], self._name, 'date', context=context) return res - - + def unlink(self, cr, uid, ids, context=None): if not isinstance(ids, list): ids = [ids] - res = False - for id in ids: - data_list = self.read(cr, uid, [id], ['date', 'rrule', 'exdate'], context=context) - if len(data_list) < 1: + for event_id in ids[:]: + if len(str(event_id).split('-')) == 1: continue - event_data = data_list[0] - event_id = event_data['id'] - if self.get_edit_all(cr, uid, event_id, vals=None): - event_id = base_calendar_id2real_id(event_id) + real_event_id = base_calendar_id2real_id(event_id) + data = self.read(cr, uid, real_event_id, ['exdate'], context=context) + date_new = event_id.split('-')[1] + date_new = time.strftime("%Y%m%dT%H%M%S", \ + time.strptime(date_new, "%Y%m%d%H%M%S")) + exdate = (data['exdate'] and (data['exdate'] + ',') or '') + date_new + self.write(cr, uid, [real_event_id], {'exdate': exdate}) + ids.remove(event_id) - if isinstance(event_id, (int, long)): - res = super(calendar_event, self).unlink(cr, uid, event_id, context=context) - self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name) - self.unlink_events(cr, uid, [event_id], context=context) - else: - str_event, date_new = event_id.split('-') - event_id = int(str_event) - if event_data['rrule']: - # Remove one of the recurrent event - date_new = time.strftime("%Y%m%dT%H%M%S", \ - time.strptime(date_new, "%Y%m%d%H%M%S")) - exdate = (event_data['exdate'] and (event_data['exdate'] + ',') or '') + date_new - res = self.write(cr, uid, [event_id], {'exdate': exdate}) - else: - res = super(calendar_event, self).unlink(cr, uid, [event_id], context=context) - self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name) - self.unlink_events(cr, uid, [event_id], context=context) + res = super(calendar_event, self).unlink(cr, uid, ids, context=context) + self.pool.get('res.alarm').do_alarm_unlink(cr, uid, ids, self._name) + self.unlink_events(cr, uid, ids, context=context) return res + def create(self, cr, uid, vals, context=None): if context is None: context = {} if vals.get('vtimezone', '') and vals.get('vtimezone', '').startswith('/freeassociation.sourceforge.net/tzfile/'): vals['vtimezone'] = vals['vtimezone'][40:] - - if 'date' in vals and 'rrule' in vals and vals['rrule']: - update_datas = self._parse_rrule(vals['rrule'], self._get_empty_rrule_data(), vals['date']) - update_datas['recurrency'] = True - vals.update(update_datas) - updated_vals = self.onchange_dates(cr, uid, [], - vals.get('date', False), - vals.get('duration', False), - vals.get('date_deadline', False), - vals.get('allday', False), - context=context) - vals.update(updated_vals.get('value', {})) + #updated_vals = self.onchange_dates(cr, uid, [], + # vals.get('date', False), + # vals.get('duration', False), + # vals.get('date_deadline', False), + # vals.get('allday', False), + # context=context) + #vals.update(updated_vals.get('value', {})) + res = super(calendar_event, self).create(cr, uid, vals, context) alarm_obj = self.pool.get('res.alarm') alarm_obj.do_alarm_create(cr, uid, [res], self._name, 'date', context=context) - return res - - def do_tentative(self, cr, uid, ids, context=None, *args): """ Makes event invitation as Tentative diff --git a/addons/base_calendar/base_calendar_view.xml b/addons/base_calendar/base_calendar_view.xml index 3ce934b4ded..16064762f9b 100644 --- a/addons/base_calendar/base_calendar_view.xml +++ b/addons/base_calendar/base_calendar_view.xml @@ -242,8 +242,7 @@ - - + diff --git a/addons/base_calendar/test/test_crm_recurrent_meeting_case2.yml b/addons/base_calendar/test/test_crm_recurrent_meeting_case2.yml index b6afeb6906e..693f0d81c6b 100644 --- a/addons/base_calendar/test/test_crm_recurrent_meeting_case2.yml +++ b/addons/base_calendar/test/test_crm_recurrent_meeting_case2.yml @@ -72,7 +72,7 @@ !python {model: crm.meeting}: | from base_calendar import base_calendar base_cal_id = base_calendar.real_id2base_calendar_id(ref('crm_meeting_sprintreview0'), '2011-09-01 13:01:00') - self.write(cr, uid, [base_cal_id], {'name': 'Sprint Review for google modules', 'edit_all': True}) + self.write(cr, uid, [base_cal_id], {'name': 'Sprint Review for google modules'}) - I check whether all the records are edited or not. - diff --git a/addons/base_module_quality/i18n/pt.po b/addons/base_module_quality/i18n/pt.po index 67eebfb18bb..cd1f263dc5d 100644 --- a/addons/base_module_quality/i18n/pt.po +++ b/addons/base_module_quality/i18n/pt.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-01-11 11:14+0000\n" -"PO-Revision-Date: 2010-12-15 10:44+0000\n" -"Last-Translator: OpenERP Administrators \n" +"PO-Revision-Date: 2011-12-10 12:08+0000\n" +"Last-Translator: Paulino Ascenção \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-11-05 05:39+0000\n" -"X-Generator: Launchpad (build 14231)\n" +"X-Launchpad-Export-Date: 2011-12-11 05:36+0000\n" +"X-Generator: Launchpad (build 14450)\n" #. module: base_module_quality #: code:addons/base_module_quality/object_test/object_test.py:187 @@ -152,7 +152,7 @@ msgstr "Objecto de Teste" #. module: base_module_quality #: view:module.quality.detail:0 msgid "Save Report" -msgstr "Gravar Relatório" +msgstr "Guardar relatório" #. module: base_module_quality #: code:addons/base_module_quality/wizard/module_quality_check.py:46 diff --git a/addons/base_tools/i18n/pt.po b/addons/base_tools/i18n/pt.po index 69b6b9c4459..badfa6acc16 100644 --- a/addons/base_tools/i18n/pt.po +++ b/addons/base_tools/i18n/pt.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-01-11 11:14+0000\n" -"PO-Revision-Date: 2011-05-17 12:07+0000\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-12-10 12:08+0000\n" +"Last-Translator: Paulino Ascenção \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-11-05 05:56+0000\n" -"X-Generator: Launchpad (build 14231)\n" +"X-Launchpad-Export-Date: 2011-12-11 05:36+0000\n" +"X-Generator: Launchpad (build 14450)\n" #. module: base_tools #: model:ir.module.module,shortdesc:base_tools.module_meta_information diff --git a/addons/crm/board_crm_view.xml b/addons/crm/board_crm_view.xml index 3418dc99423..5d64bf20093 100644 --- a/addons/crm/board_crm_view.xml +++ b/addons/crm/board_crm_view.xml @@ -83,54 +83,30 @@ - - My Meetings - crm.meeting - form - tree,form - - [('user_id','=',uid),('state','not in',('cancel','done'))] - {'default_user_id': uid} - - Planned Revenue By Stage crm.lead.report form graph,tree,form - ['&', '&', ('user_id','=',uid), ('type', '=', 'opportunity'), '!' , '&', ('state', '=', 'done'), ('date_closed','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%Y-%m-%d'))] + [('user_id','=',uid), ('type', '=', 'opportunity'), ('state','in',('draft','open','done','pending')), '!', '&', ('state', '=', 'done'), ('date_closed','>=',datetime.date.today().strftime('%Y-%m-01'))] {'search_default_Stage':1} - - My Win/Lost Ratio for The Last Year - crm.lead.report - form - graph,tree,form - - ['&', ('user_id', '=', uid),'&', ('state', '=', 'done') , '&', ('create_date','>',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%Y-%m-%d')), ('type', '=', 'opportunity')] - - Sales Dashboard Form board.board form
- + - - - diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 49272c97576..216a898bc88 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -748,10 +748,11 @@ class crm_lead(crm_case, osv.osv): self.write(cr, uid, [res_id], vals, context) return res_id - def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): + def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): if isinstance(ids, (str, int, long)): ids = [ids] - + if vals == None: + vals = {} super(crm_lead, self).message_update(cr, uid, ids, msg, context=context) if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): diff --git a/addons/crm/crm_lead_menu.xml b/addons/crm/crm_lead_menu.xml index d0197fd82cd..2ec2db18509 100644 --- a/addons/crm/crm_lead_menu.xml +++ b/addons/crm/crm_lead_menu.xml @@ -31,7 +31,6 @@ parent="base.menu_base_partner" sequence="1" /> diff --git a/addons/crm/crm_meeting_menu.xml b/addons/crm/crm_meeting_menu.xml index 19ca9266332..338579af88f 100644 --- a/addons/crm/crm_meeting_menu.xml +++ b/addons/crm/crm_meeting_menu.xml @@ -51,7 +51,7 @@ crm.meeting calendar,tree,form,gantt - {"search_default_user_id":uid, 'search_default_section_id': section_id, 'virtual_id' : True} + {"search_default_user_id":uid, 'search_default_section_id': section_id} The meeting calendar is shared between the sales teams and fully integrated with other applications such as the employee holidays or the business opportunities. You can also synchronize meetings with your mobile phone using the caldav interface. diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index ad2c31f7b12..c04e00e5fcc 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -45,7 +45,6 @@ widget="selection" /> - @@ -67,7 +66,7 @@ - + @@ -231,24 +230,11 @@ - + + - - - - - -