diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 81d09b30ae9..08122f5af30 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -19,11 +19,11 @@ # ############################################################################## { - "name" : "Accounting and Financial Management", + "name" : "eInvoicing", "version" : "1.1", "author" : "OpenERP SA", "category": 'Accounting & Finance', - 'complexity': "normal", + 'complexity': "easy", "description": """ Accounting and Financial Management. ==================================== @@ -125,6 +125,7 @@ module named account_voucher. "wizard/account_report_balance_sheet_view.xml", "edi/invoice_action_data.xml", "account_bank_view.xml", + "account_pre_install.yml" ], 'demo_xml': [ 'demo/account_demo.xml', @@ -140,7 +141,6 @@ module named account_voucher. 'test/account_change_currency.yml', 'test/chart_of_account.yml', 'test/account_period_close.yml', - 'test/account_fiscalyear_close_state.yml', 'test/account_use_model.yml', 'test/account_validate_account_move.yml', 'test/account_fiscalyear_close.yml', @@ -148,6 +148,7 @@ module named account_voucher. 'test/account_cash_statement.yml', 'test/test_edi_invoice.yml', 'test/account_report.yml', + 'test/account_fiscalyear_close_state.yml', #last test, as it will definitively close the demo fiscalyear ], 'installable': True, 'active': False, diff --git a/addons/account/account.py b/addons/account/account.py index 630735c487f..a15a04dcffe 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -461,7 +461,7 @@ class account_account(osv.osv): } _defaults = { - 'type': 'view', + 'type': 'other', 'reconcile': False, 'active': True, 'currency_mode': 'current', @@ -716,6 +716,19 @@ class account_journal(osv.osv): _order = 'code' + def _check_currency(self, cr, uid, ids, context=None): + for journal in self.browse(cr, uid, ids, context=context): + if journal.currency: + if journal.default_credit_account_id and not journal.default_credit_account_id.currency_id.id == journal.currency.id: + return False + if journal.default_debit_account_id and not journal.default_debit_account_id.currency_id.id == journal.currency.id: + return False + return True + + _constraints = [ + (_check_currency, 'Configuration error! The currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']), + ] + def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False): journal = self.browse(cr, uid, id, context=context) if not default: @@ -776,9 +789,11 @@ class account_journal(osv.osv): result = self.browse(cr, user, ids, context=context) res = [] for rs in result: - name = rs.name if rs.currency: - name = "%s (%s)" % (rs.name, rs.currency.name) + currency = rs.currency + else: + currency = rs.company_id.currency_id + name = "%s (%s)" % (rs.name, currency.name) res += [(rs.id, name)] return res @@ -846,21 +861,8 @@ class account_fiscalyear(osv.osv): 'state': 'draft', 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } - _order = "date_start" + _order = "date_start, id" - def _check_fiscal_year(self, cr, uid, ids, context=None): - current_fiscal_yr = self.browse(cr, uid, ids, context=context)[0] - obj_fiscal_ids = self.search(cr, uid, [('company_id', '=', current_fiscal_yr.company_id.id)], context=context) - obj_fiscal_ids.remove(ids[0]) - data_fiscal_yr = self.browse(cr, uid, obj_fiscal_ids, context=context) - - for old_fy in data_fiscal_yr: - if old_fy.company_id.id == current_fiscal_yr['company_id'].id: - # Condition to check if the current fiscal year falls in between any previously defined fiscal year - if old_fy.date_start <= current_fiscal_yr['date_start'] <= old_fy.date_stop or \ - old_fy.date_start <= current_fiscal_yr['date_stop'] <= old_fy.date_stop: - return False - return True def _check_duration(self, cr, uid, ids, context=None): obj_fy = self.browse(cr, uid, ids[0], context=context) @@ -869,8 +871,7 @@ class account_fiscalyear(osv.osv): return True _constraints = [ - (_check_duration, 'Error! The start date of the fiscal year must be before his end date.', ['date_start','date_stop']), - (_check_fiscal_year, 'Error! You can not define overlapping fiscal years for the same company.',['date_start', 'date_stop']) + (_check_duration, 'Error! The start date of the fiscal year must be before his end date.', ['date_start','date_stop']) ] def create_period3(self, cr, uid, ids, context=None): @@ -881,7 +882,7 @@ class account_fiscalyear(osv.osv): for fy in self.browse(cr, uid, ids, context=context): ds = datetime.strptime(fy.date_start, '%Y-%m-%d') period_obj.create(cr, uid, { - 'name': _('Opening Period'), + 'name': "%s %s" % (_('Opening Period'), ds.strftime('%Y')), 'code': ds.strftime('00/%Y'), 'date_start': ds, 'date_stop': ds, @@ -905,6 +906,10 @@ class account_fiscalyear(osv.osv): return True def find(self, cr, uid, dt=None, exception=True, context=None): + res = self.finds(cr, uid, dt, exception, context=context) + return res and res[0] or False + + def finds(self, cr, uid, dt=None, exception=True, context=None): if context is None: context = {} if not dt: dt = time.strftime('%Y-%m-%d') @@ -919,8 +924,8 @@ class account_fiscalyear(osv.osv): if exception: raise osv.except_osv(_('Error !'), _('No fiscal year defined for this date !\nPlease create one.')) else: - return False - return ids[0] + return [] + return ids def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): if args is None: @@ -1220,7 +1225,7 @@ class account_move(osv.osv): 'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}), 'state': fields.selection([('draft','Unposted'), ('posted','Posted')], 'State', required=True, readonly=True, - help='All manually created new journal entry are usually in the state \'Unposted\', but you can set the option to skip that state on the related journal. In that case, they will be behave as journal entries automatically created by the system on document validation (invoices, bank statements...) and will be created in \'Posted\' state.'), + help='All manually created new journal entries are usually in the state \'Unposted\', but you can set the option to skip that state on the related journal. In that case, they will be behave as journal entries automatically created by the system on document validation (invoices, bank statements...) and will be created in \'Posted\' state.'), 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}), 'to_check': fields.boolean('To Review', help='Check this box if you are unsure of that journal entry and if you want to note it as \'to be reviewed\' by an accounting expert.'), 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), @@ -1683,13 +1688,15 @@ class account_tax_code(osv.osv): if context.get('state', 'all') == 'all': move_state = ('draft', 'posted', ) if context.get('fiscalyear_id', False): - fiscalyear_id = context['fiscalyear_id'] + fiscalyear_id = [context['fiscalyear_id']] else: - fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) + fiscalyear_id = self.pool.get('account.fiscalyear').finds(cr, uid, exception=False) where = '' where_params = () if fiscalyear_id: - pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) + pids = [] + for fy in fiscalyear_id: + pids += map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fy).period_ids) if pids: where = ' AND line.period_id IN %s AND move.state IN %s ' where_params = (tuple(pids), move_state) @@ -3149,7 +3156,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'type': line.account_type == 'cash' and 'cash' or 'bank', 'company_id': company_id, 'analytic_journal_id': False, - 'currency_id': False, + 'currency': False, } if line.currency_id: vals_journal['view_id'] = view_id_cur diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py index acf070a3ad7..02270b94186 100644 --- a/addons/account/account_bank.py +++ b/addons/account/account_bank.py @@ -99,7 +99,6 @@ class bank(osv.osv): 'type': 'bank', 'company_id': bank.company_id.id, 'analytic_journal_id': False, - 'currency_id': False, 'default_credit_account_id': acc_bank_id, 'default_debit_account_id': acc_bank_id, 'view_id': view_id_cash @@ -108,3 +107,5 @@ class bank(osv.osv): self.write(cr, uid, [bank.id], {'journal_id': journal_id}, context=context) return True + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 57472e228ef..85d9805eb32 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -30,10 +30,12 @@ class account_bank_statement(osv.osv): def create(self, cr, uid, vals, context=None): seq = 0 if 'line_ids' in vals: + new_line_ids = [] for line in vals['line_ids']: seq += 1 line[2]['sequence'] = seq - vals[seq - 1] = line + 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 230078c4e33..e249f8fa872 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -57,7 +57,7 @@ Accounting 5 - + diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 27881bf1280..39cc471c2f6 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -207,7 +207,7 @@ class account_invoice(osv.osv): help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Invoice. \ \n* The \'Pro-forma\' when invoice is in Pro-forma state,invoice does not have an invoice number. \ \n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \ - \n* The \'Paid\' state is set automatically when invoice is paid.\ + \n* The \'Paid\' state is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled. \ \n* The \'Cancelled\' state is used when user cancel invoice.'), 'date_invoice': fields.date('Invoice Date', readonly=True, states={'draft':[('readonly',False)]}, select=True, help="Keep empty to use the current date"), 'date_due': fields.date('Due Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True, @@ -257,7 +257,7 @@ class account_invoice(osv.osv): 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, None, 50), # Check if we can remove ? 'account.move.line': (_get_invoice_from_line, None, 50), 'account.move.reconcile': (_get_invoice_from_reconcile, None, 50), - }, help="The Journal Entry of the invoice have been totally reconciled with one or several Journal Entries of payment."), + }, help="It indicates that the invoice has been paid and the journal entry of the invoice has been reconciled with one or several journal entries of payment."), 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account', help='Bank Account Number, Company bank account if Invoice is customer or supplier refund, otherwise Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}), 'move_lines':fields.function(_get_lines, type='many2many', relation='account.move.line', string='Entry Lines'), @@ -923,7 +923,6 @@ class account_invoice(osv.osv): 'line_id': line, 'journal_id': journal_id, 'date': date, - 'type': entry_type, 'narration':inv.comment } period_id = inv.period_id and inv.period_id.id or False @@ -1081,7 +1080,8 @@ class account_invoice(osv.osv): del line['invoice_id'] for field in ('company_id', 'partner_id', 'account_id', 'product_id', 'uos_id', 'account_analytic_id', 'tax_code_id', 'base_code_id'): - line[field] = line.get(field, False) and line[field][0] + if line.get(field): + line[field] = line[field][0] if 'invoice_line_tax_id' in line: line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ] return map(lambda x: (0,0,x), lines) @@ -1209,7 +1209,7 @@ class account_invoice(osv.osv): l2['name'] = name lines = [(0, 0, l1), (0, 0, l2)] - move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date, 'type': entry_type} + move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} move_id = self.pool.get('account.move').create(cr, uid, move, context=context) line_ids = [] diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index efc7a24031c..4cc1a63db61 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -153,7 +153,7 @@