diff --git a/addons/account/account.py b/addons/account/account.py index 0631bbfff7d..8c7f058acc6 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1150,6 +1150,29 @@ class account_move(osv.osv): _description = "Account Entry" _order = 'id desc' + def account_move_prepare(self, cr, uid, journal_id, date=False, ref='', company_id=False, context=None): + ''' + Prepares and returns a dictionary of values, ready to be passed to create() based on the parameters received. + ''' + if not date: + date = fields.date.today() + period_obj = self.pool.get('account.period') + if not company_id: + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + company_id = user.company_id.id + if context is None: + context = {} + #put the company in context to find the good period + ctx = context.copy() + ctx.update({'company_id': company_id}) + return { + 'journal_id': journal_id, + 'date': date, + 'period_id': period_obj.find(cr, uid, date, context=ctx)[0], + 'ref': ref, + 'company_id': company_id, + } + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): """ Returns a list of tupples containing id, name, as internally it is called {def name_get} @@ -1858,7 +1881,6 @@ class account_tax(osv.osv): default.update({'name': name + _(' (Copy)')}) return super(account_tax, self).copy_data(cr, uid, id, default=default, context=context) - def get_precision_tax(): def change_digit_tax(cr): res = pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, SUPERUSER_ID, 'Account') diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 3d46ee8365a..8c7cec67ac5 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -146,7 +146,6 @@