diff --git a/addons/account/account.py b/addons/account/account.py index 81da55dd7d5..661d13b5cdf 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -52,17 +52,17 @@ class account_payment_term(osv.osv): amount = value result = [] for line in pt.line_ids: - if line.value=='fixed': + if line.value == 'fixed': amt = round(line.value_amount, 2) - elif line.value=='procent': + elif line.value == 'procent': amt = round(value * line.value_amount, 2) - elif line.value=='balance': + elif line.value == 'balance': amt = round(amount, 2) if amt: next_date = mx.DateTime.strptime(date_ref, '%Y-%m-%d') + RelativeDateTime(days=line.days) - if line.days2<0: + if line.days2 < 0: next_date += RelativeDateTime(day=line.days2) - if line.days2>0: + if line.days2 > 0: next_date += RelativeDateTime(day=line.days2, months=1) result.append( (next_date.strftime('%Y-%m-%d'), amt) ) amount -= amt @@ -74,14 +74,14 @@ class account_payment_term_line(osv.osv): _name = "account.payment.term.line" _description = "Payment Term Line" _columns = { - 'name': fields.char('Line Name', size=32,required=True), + '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), 'value_amount': fields.float('Value Amount'), - 'days': fields.integer('Number of Days',required=True, help="Number of days to add before computation of the day of month." \ + '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."), - 'days2': fields.integer('Day of the Month',required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."), - 'payment_id': fields.many2one('account.payment.term','Payment Term', required=True, select=True), + 'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."), + 'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=True, select=True), } _defaults = { 'value': lambda *a: 'balance', @@ -100,7 +100,7 @@ class account_account_type(osv.osv): 'code': fields.char('Code', size=32, required=True), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of account types."), 'partner_account': fields.boolean('Partner account'), - 'close_method': fields.selection([('none','None'), ('balance','Balance'), ('detail','Detail'),('unreconciled','Unreconciled')], 'Deferral Method', required=True), + 'close_method': fields.selection([('none', 'None'), ('balance', 'Balance'), ('detail', 'Detail'), ('unreconciled', 'Unreconciled')], 'Deferral Method', required=True), 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows you to change the sign of the balance amount displayed in the reports, so that you can see positive figures instead of negative ones in expenses accounts.'), } _defaults = { @@ -139,11 +139,11 @@ class account_account(osv.osv): context = {} pos = 0 - while pos','view'), ('code', '<>', 'closed')]), @@ -527,7 +527,6 @@ class account_fiscalyear(osv.osv): def create_period(self,cr, uid, ids, context={}, interval=1): for fy in self.browse(cr, uid, ids, context): - dt = fy.date_start ds = mx.DateTime.strptime(fy.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') obj_period.date_start or obj_period.fiscalyear_id.date_start > obj_period.date_stop: + + if obj_period.fiscalyear_id.date_stop < obj_period.date_stop or \ + obj_period.fiscalyear_id.date_stop < obj_period.date_start or \ + obj_period.fiscalyear_id.date_start > obj_period.date_start or \ + obj_period.fiscalyear_id.date_start > obj_period.date_stop: return False pids = self.search(cr, uid, [('date_stop','>=',obj_period.date_start),('date_start','<=',obj_period.date_stop),('special','=',False),('id','<>',obj_period.id)]) @@ -862,7 +865,7 @@ class account_move(osv.osv): def unlink(self, cr, uid, ids, context={}, check=True): toremove = [] for move in self.browse(cr, uid, ids, context): - if move['state'] <> 'draft': + if move['state'] != 'draft': raise osv.except_osv(_('UserError'), _('You can not delete posted movement: "%s"!') % \ move['name']) @@ -962,7 +965,7 @@ class account_move(osv.osv): if line.account_id.currency_id: if line.account_id.currency_id.id != line.currency_id.id and (line.account_id.currency_id.id != line.account_id.company_id.currency_id.id or line.currency_id): - raise osv.except_osv(_('Error'), _("""Couldn't create move with currency different from the secondary currency of the account "%s - %s". Clear the secondary currency field of the account definition if you want to accept all currencies.""" % (line.account_id.code, line.account_id.name))) + raise osv.except_osv(_('Error'), _("""Couldn't create move with currency different from the secondary currency of the account "%s - %s". Clear the secondary currency field of the account definition if you want to accept all currencies.""" % (line.account_id.code, line.account_id.name))) if abs(amount) < 0.0001: if not len(line_draft_ids): @@ -1110,9 +1113,9 @@ class account_tax_code(osv.osv): fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) where = '' if fiscalyear_id: - pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) - if pids: - where = ' and period_id in (' + (','.join(pids))+')' + pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) + if pids: + where = ' and period_id in (' + (','.join(pids))+')' return self._sum(cr, uid, ids, name, args, context, where=where)