diff --git a/addons/account/account_financial_report.py b/addons/account/account_financial_report.py index 28b5e08dc99..1d9a4a794eb 100644 --- a/addons/account/account_financial_report.py +++ b/addons/account/account_financial_report.py @@ -39,6 +39,8 @@ class account_financial_report(osv.osv): _description = "Account Report" def _get_level(self, cr, uid, ids, field_name, arg, context=None): + '''Returns a dictionary with key=the ID of a record and value = the level of this + record in the tree structure.''' res = {} for report in self.browse(cr, uid, ids, context=context): level = 0 @@ -48,6 +50,8 @@ class account_financial_report(osv.osv): return res def _get_children_by_order(self, cr, uid, ids, context=None): + '''returns a dictionary with the key= the ID of a record and value = all its children, + computed recursively, and sorted by sequence. Ready for the printing''' res = [] for id in ids: res.append(id) @@ -56,6 +60,12 @@ class account_financial_report(osv.osv): return res def _get_balance(self, cr, uid, ids, field_names, args, context=None): + '''returns a dictionary with key=the ID of a record and value=the balance amount + computed for this record. If the record is of type : + 'accounts' : it's the sum of the linked accounts + 'account_type' : it's the sum of leaf accoutns with such an account_type + 'account_report' : it's the amount of the related report + 'sum' : it's the sum of the children of this record (aka a 'view' record)''' account_obj = self.pool.get('account.account') res = {} for report in self.browse(cr, uid, ids, context=context): diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 833ed59e15b..7bccef6fb9c 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -23,7 +23,6 @@ import time from lxml import etree import openerp.addons.decimal_precision as dp -from openerp import netsvc from openerp import pooler from openerp.osv import fields, osv, orm from openerp.tools.translate import _ @@ -80,11 +79,10 @@ class account_invoice(osv.osv): def _reconciled(self, cr, uid, ids, name, args, context=None): res = {} - wf_service = netsvc.LocalService("workflow") for inv in self.browse(cr, uid, ids, context=context): res[inv.id] = self.test_paid(cr, uid, [inv.id]) if not res[inv.id] and inv.state == 'paid': - wf_service.trg_validate(uid, 'account.invoice', inv.id, 'open_test', cr) + self.signal_open_test(cr, uid, [inv.id]) return res def _get_reference_type(self, cr, uid, context=None): @@ -638,10 +636,8 @@ class account_invoice(osv.osv): # go from canceled state to draft state def action_cancel_draft(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'draft'}) - wf_service = netsvc.LocalService("workflow") - for inv_id in ids: - wf_service.trg_delete(uid, 'account.invoice', inv_id, cr) - wf_service.trg_create(uid, 'account.invoice', inv_id, cr) + self.delete_workflow(cr, uid, ids) + self.create_workflow(cr, uid, ids) return True # Workflow stuff @@ -1394,7 +1390,12 @@ class account_invoice_line(osv.osv): # XXX this gets the default account for the user's company, # it should get the default account for the invoice's company # however, the invoice's company does not reach this point - prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) + if context is None: + context = {} + if context.get('type') in ('out_invoice','out_refund'): + prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) + else: + prop = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category', context=context) return prop and prop.id or False _defaults = { diff --git a/addons/account/res_config.py b/addons/account/res_config.py index 72d30c11cfd..53c604161ea 100644 --- a/addons/account/res_config.py +++ b/addons/account/res_config.py @@ -151,12 +151,12 @@ class account_config_settings(osv.osv_memory): self.write(cr, uid, [id], vals, context) return id - def onchange_company_id(self, cr, uid, ids, company_id): + def onchange_company_id(self, cr, uid, ids, company_id, context=None): # update related fields values = {} values['currency_id'] = False if company_id: - company = self.pool.get('res.company').browse(cr, uid, company_id) + company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) has_chart_of_accounts = company_id not in self.pool.get('account.installer').get_unconfigured_cmp(cr, uid) fiscalyear_count = self.pool.get('account.fiscalyear').search_count(cr, uid, [('date_start', '<=', time.strftime('%Y-%m-%d')), ('date_stop', '>=', time.strftime('%Y-%m-%d')), diff --git a/addons/account/res_config_view.xml b/addons/account/res_config_view.xml index 4bfd3697d89..7977c0fc505 100644 --- a/addons/account/res_config_view.xml +++ b/addons/account/res_config_view.xml @@ -33,7 +33,7 @@