diff --git a/addons/account/account.py b/addons/account/account.py index 85dc85fd2d8..9dc9e5ac2aa 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -77,7 +77,10 @@ class account_payment_term_line(osv.osv): _columns = { 'name': fields.char('Line Name', size=32, required=True), 'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the payment term lines from the lowest sequences to the higher ones"), - 'value': fields.selection([('procent', 'Percent'), ('balance', 'Balance'), ('fixed', 'Fixed Amount')], 'Value',required=True), + 'value': fields.selection([('procent', 'Percent'), ('balance', 'Balance'), ('fixed', 'Fixed Amount')], 'Value', required=True, help="""Example: 14 days 2%, 30 days net +1. Line 1: percent 0.02 14 days +2. Line 2: balance 30 days"""), + 'value_amount': fields.float('Value Amount', help="For Value percent enter % ratio between 0-1."), 'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \ "If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."), @@ -90,6 +93,17 @@ class account_payment_term_line(osv.osv): 'days2': lambda *a: 0, } _order = "sequence" + + def _check_percent(self, cr, uid, ids, context={}): + obj = self.browse(cr, uid, ids[0]) + if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0): + return False + return True + + _constraints = [ + (_check_percent, _('Percentages for Payment Term Line must be between 0 and 1, Example: 0.02 for 2% '), ['value_amount']), + ] + account_payment_term_line() @@ -892,7 +906,10 @@ class account_move(osv.osv): amount+= (line.debit - line.credit) return amount - def _centralise(self, cr, uid, move, mode): + def _centralise(self, cr, uid, move, mode, context=None): + if context is None: + context = {} + if mode=='credit': account_id = move.journal_id.default_debit_account_id.id mode2 = 'debit' @@ -915,8 +932,9 @@ class account_move(osv.osv): if res: line_id = res[0] else: + context.update({'journal_id': move.journal_id.id, 'period_id': move.period_id.id}) line_id = self.pool.get('account.move.line').create(cr, uid, { - 'name': 'Centralisation '+mode, + 'name': _t(cr, None, 'selection', context.get('lang'), source=(mode.capitalize()+' Centralisation')) or (mode.capitalize()+' Centralisation'), 'centralisation': mode, 'account_id': account_id, 'move_id': move.id, @@ -925,7 +943,7 @@ class account_move(osv.osv): 'date': move.period_id.date_stop, 'debit': 0.0, 'credit': 0.0, - }, {'journal_id': move.journal_id.id, 'period_id': move.period_id.id}) + }, context) # find the first line of this move with the other mode # so that we can exclude it from our calculation @@ -1007,8 +1025,8 @@ class account_move(osv.osv): # continue if journal.centralisation: - self._centralise(cr, uid, move, 'debit') - self._centralise(cr, uid, move, 'credit') + self._centralise(cr, uid, move, 'debit', context=context) + self._centralise(cr, uid, move, 'credit', context=context) self.pool.get('account.move.line').write(cr, uid, line_draft_ids, { 'state': 'valid' }, context, check=False) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 56c4ddba96e..d1cf95604bf 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -170,7 +170,9 @@ class account_bank_statement(osv.osv): if line.state <> 'valid': raise osv.except_osv(_('Error !'), _('The account entries lines are not in valid state.')) - + # for bank.statement.lines + # In line we get reconcile_id on bank.ste.rec. + # in bank stat.rec we get line_new_ids on bank.stat.rec.line for move in st.line_ids: move_id = account_move_obj.create(cr, uid, { 'journal_id': st.journal_id.id, @@ -209,7 +211,7 @@ class account_bank_statement(osv.osv): 'period_id': st.period_id.id, 'currency_id': st.currency.id, } - + amount = res_currency_obj.compute(cr, uid, st.currency.id, company_currency_id, move.amount, context=context, account=acc_cur) @@ -245,6 +247,7 @@ class account_bank_statement(osv.osv): 'statement_id': st.id, 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, + }, context=context) # Fill the secondary amount/currency @@ -491,11 +494,14 @@ class account_bank_statement_reconcile_line(osv.osv): _name = "account.bank.statement.reconcile.line" _description = "Statement reconcile line" _columns = { - 'name': fields.char('Description', size=64), + 'name': fields.char('Description', size=64, required=True), 'account_id': fields.many2one('account.account', 'Account', required=True), 'line_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile'), 'amount': fields.float('Amount', required=True), } + _defaults = { + 'name': lambda *a: 'Write-Off', + } account_bank_statement_reconcile_line() @@ -568,7 +574,7 @@ class account_bank_statement_line(osv.osv): 'account_id': fields.many2one('account.account','Account', required=True), 'statement_id': fields.many2one('account.bank.statement', 'Statement', - select=True, required=True), + select=True, required=True, ondelete='cascade'), 'reconcile_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile', states={'confirm':[('readonly',True)]}), 'move_ids': fields.many2many('account.move', diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 8822568ef00..77ffbb6f61e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -209,7 +209,7 @@