parent
08758c950e
commit
6a41299d79
|
@ -52,17 +52,17 @@ class account_payment_term(osv.osv):
|
||||||
amount = value
|
amount = value
|
||||||
result = []
|
result = []
|
||||||
for line in pt.line_ids:
|
for line in pt.line_ids:
|
||||||
if line.value=='fixed':
|
if line.value == 'fixed':
|
||||||
amt = round(line.value_amount, 2)
|
amt = round(line.value_amount, 2)
|
||||||
elif line.value=='procent':
|
elif line.value == 'procent':
|
||||||
amt = round(value * line.value_amount, 2)
|
amt = round(value * line.value_amount, 2)
|
||||||
elif line.value=='balance':
|
elif line.value == 'balance':
|
||||||
amt = round(amount, 2)
|
amt = round(amount, 2)
|
||||||
if amt:
|
if amt:
|
||||||
next_date = mx.DateTime.strptime(date_ref, '%Y-%m-%d') + RelativeDateTime(days=line.days)
|
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)
|
next_date += RelativeDateTime(day=line.days2)
|
||||||
if line.days2>0:
|
if line.days2 > 0:
|
||||||
next_date += RelativeDateTime(day=line.days2, months=1)
|
next_date += RelativeDateTime(day=line.days2, months=1)
|
||||||
result.append( (next_date.strftime('%Y-%m-%d'), amt) )
|
result.append( (next_date.strftime('%Y-%m-%d'), amt) )
|
||||||
amount -= amt
|
amount -= amt
|
||||||
|
@ -74,14 +74,14 @@ class account_payment_term_line(osv.osv):
|
||||||
_name = "account.payment.term.line"
|
_name = "account.payment.term.line"
|
||||||
_description = "Payment Term Line"
|
_description = "Payment Term Line"
|
||||||
_columns = {
|
_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"),
|
'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'),
|
'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."),
|
"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)."),
|
'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),
|
'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=True, select=True),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'value': lambda *a: 'balance',
|
'value': lambda *a: 'balance',
|
||||||
|
@ -100,7 +100,7 @@ class account_account_type(osv.osv):
|
||||||
'code': fields.char('Code', size=32, required=True),
|
'code': fields.char('Code', size=32, required=True),
|
||||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of account types."),
|
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of account types."),
|
||||||
'partner_account': fields.boolean('Partner account'),
|
'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.'),
|
'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 = {
|
_defaults = {
|
||||||
|
@ -139,11 +139,11 @@ class account_account(osv.osv):
|
||||||
context = {}
|
context = {}
|
||||||
pos = 0
|
pos = 0
|
||||||
|
|
||||||
while pos<len(args):
|
while pos < len(args):
|
||||||
|
|
||||||
if args[pos][0]=='code' and args[pos][1] in ('like','ilike') and args[pos][2]:
|
if args[pos][0] == 'code' and args[pos][1] in ('like', 'ilike') and args[pos][2]:
|
||||||
args[pos] = ('code', '=like', str(args[pos][2].replace('%',''))+'%')
|
args[pos] = ('code', '=like', str(args[pos][2].replace('%', ''))+'%')
|
||||||
if args[pos][0]=='journal_id':
|
if args[pos][0] == 'journal_id':
|
||||||
if not args[pos][2]:
|
if not args[pos][2]:
|
||||||
del args[pos]
|
del args[pos]
|
||||||
continue
|
continue
|
||||||
|
@ -152,19 +152,19 @@ class account_account(osv.osv):
|
||||||
del args[pos]
|
del args[pos]
|
||||||
continue
|
continue
|
||||||
ids3 = map(lambda x: x.code, jour.type_control_ids)
|
ids3 = map(lambda x: x.code, jour.type_control_ids)
|
||||||
ids1 = super(account_account,self).search(cr, uid, [('type','in',ids3)])
|
ids1 = super(account_account, self).search(cr, uid, [('type', 'in', ids3)])
|
||||||
ids1 += map(lambda x: x.id, jour.account_control_ids)
|
ids1 += map(lambda x: x.id, jour.account_control_ids)
|
||||||
args[pos] = ('id','in',ids1)
|
args[pos] = ('id', 'in', ids1)
|
||||||
pos+=1
|
pos += 1
|
||||||
|
|
||||||
if context and context.has_key('consolidate_childs'): #add consolidated childs of accounts
|
if context and context.has_key('consolidate_childs'): #add consolidated childs of accounts
|
||||||
ids = super(account_account,self).search(cr, uid, args, offset, limit,
|
ids = super(account_account, self).search(cr, uid, args, offset, limit,
|
||||||
order, context=context, count=count)
|
order, context=context, count=count)
|
||||||
for consolidate_child in self.browse(cr, uid, context['account_id']).child_consol_ids:
|
for consolidate_child in self.browse(cr, uid, context['account_id']).child_consol_ids:
|
||||||
ids.append(consolidate_child.id)
|
ids.append(consolidate_child.id)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
return super(account_account,self).search(cr, uid, args, offset, limit,
|
return super(account_account, self).search(cr, uid, args, offset, limit,
|
||||||
order, context=context, count=count)
|
order, context=context, count=count)
|
||||||
|
|
||||||
def _get_children_and_consol(self, cr, uid, ids, context={}):
|
def _get_children_and_consol(self, cr, uid, ids, context={}):
|
||||||
|
@ -176,7 +176,7 @@ class account_account(osv.osv):
|
||||||
ids3.append(child.id)
|
ids3.append(child.id)
|
||||||
if ids3:
|
if ids3:
|
||||||
ids3 = self._get_children_and_consol(cr, uid, ids3, context)
|
ids3 = self._get_children_and_consol(cr, uid, ids3, context)
|
||||||
return ids2+ids3
|
return ids2 + ids3
|
||||||
|
|
||||||
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
|
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
|
||||||
#compute the balance/debit/credit accordingly to the value of field_name for the given account ids
|
#compute the balance/debit/credit accordingly to the value of field_name for the given account ids
|
||||||
|
@ -237,12 +237,12 @@ class account_account(osv.osv):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _get_child_ids(self, cr, uid, ids, field_name, arg, context={}):
|
def _get_child_ids(self, cr, uid, ids, field_name, arg, context={}):
|
||||||
result={}
|
result = {}
|
||||||
for record in self.browse(cr, uid, ids, context):
|
for record in self.browse(cr, uid, ids, context):
|
||||||
if record.child_parent_ids:
|
if record.child_parent_ids:
|
||||||
result[record.id]=[x.id for x in record.child_parent_ids]
|
result[record.id] = [x.id for x in record.child_parent_ids]
|
||||||
else:
|
else:
|
||||||
result[record.id]=[]
|
result[record.id] = []
|
||||||
|
|
||||||
if record.child_consol_ids:
|
if record.child_consol_ids:
|
||||||
for acc in record.child_consol_ids:
|
for acc in record.child_consol_ids:
|
||||||
|
@ -255,26 +255,26 @@ class account_account(osv.osv):
|
||||||
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."),
|
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."),
|
||||||
'code': fields.char('Code', size=64, required=True),
|
'code': fields.char('Code', size=64, required=True),
|
||||||
'type': fields.selection([
|
'type': fields.selection([
|
||||||
('receivable','Receivable'),
|
('receivable', 'Receivable'),
|
||||||
('payable','Payable'),
|
('payable', 'Payable'),
|
||||||
('view','View'),
|
('view', 'View'),
|
||||||
('consolidation','Consolidation'),
|
('consolidation', 'Consolidation'),
|
||||||
('other','Others'),
|
('other', 'Others'),
|
||||||
('closed','Closed'),
|
('closed', 'Closed'),
|
||||||
], 'Internal Type', required=True,),
|
], 'Internal Type', required=True,),
|
||||||
|
|
||||||
'user_type': fields.many2one('account.account.type', 'Account Type', required=True),
|
'user_type': fields.many2one('account.account.type', 'Account Type', required=True),
|
||||||
'parent_id': fields.many2one('account.account','Parent', ondelete='cascade'),
|
'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade'),
|
||||||
'child_parent_ids':fields.one2many('account.account','parent_id','Children'),
|
'child_parent_ids': fields.one2many('account.account','parent_id','Children'),
|
||||||
'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'),
|
'child_consol_ids': fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'),
|
||||||
'child_id': fields.function(_get_child_ids, method=True, type='many2many',relation="account.account",string="Child Accounts"),
|
'child_id': fields.function(_get_child_ids, method=True, type='many2many', relation="account.account", string="Child Accounts"),
|
||||||
'balance': fields.function(__compute, digits=(16,2), method=True, string='Balance', multi='balance'),
|
'balance': fields.function(__compute, digits=(16, 2), method=True, string='Balance', multi='balance'),
|
||||||
'credit': fields.function(__compute, digits=(16,2), method=True, string='Credit', multi='balance'),
|
'credit': fields.function(__compute, digits=(16, 2), method=True, string='Credit', multi='balance'),
|
||||||
'debit': fields.function(__compute, digits=(16,2), method=True, string='Debit', multi='balance'),
|
'debit': fields.function(__compute, digits=(16, 2), method=True, string='Debit', multi='balance'),
|
||||||
'reconcile': fields.boolean('Reconcile', help="Check this if the user is allowed to reconcile entries in this account."),
|
'reconcile': fields.boolean('Reconcile', help="Check this if the user is allowed to reconcile entries in this account."),
|
||||||
'shortcut': fields.char('Shortcut', size=12),
|
'shortcut': fields.char('Shortcut', size=12),
|
||||||
'tax_ids': fields.many2many('account.tax', 'account_account_tax_default_rel',
|
'tax_ids': fields.many2many('account.tax', 'account_account_tax_default_rel',
|
||||||
'account_id','tax_id', 'Default Taxes'),
|
'account_id', 'tax_id', 'Default Taxes'),
|
||||||
'note': fields.text('Note'),
|
'note': fields.text('Note'),
|
||||||
'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Company Currency'),
|
'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Company Currency'),
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||||
|
@ -282,7 +282,7 @@ class account_account(osv.osv):
|
||||||
|
|
||||||
'parent_left': fields.integer('Parent Left', select=1),
|
'parent_left': fields.integer('Parent Left', select=1),
|
||||||
'parent_right': fields.integer('Parent Right', select=1),
|
'parent_right': fields.integer('Parent Right', select=1),
|
||||||
'currency_mode': fields.selection([('current','At Date'),('average','Average Rate')], 'Outgoing Currencies Rate',
|
'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate',
|
||||||
help=
|
help=
|
||||||
'This will select how the current currency rate for outgoing transactions is computed. '\
|
'This will select how the current currency rate for outgoing transactions is computed. '\
|
||||||
'In most countries the legal method is "average" but only a few software systems are able to '\
|
'In most countries the legal method is "average" but only a few software systems are able to '\
|
||||||
|
@ -301,7 +301,7 @@ class account_account(osv.osv):
|
||||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'type' : lambda *a :'view',
|
'type': lambda *a : 'view',
|
||||||
'reconcile': lambda *a: False,
|
'reconcile': lambda *a: False,
|
||||||
'company_id': _default_company,
|
'company_id': _default_company,
|
||||||
'active': lambda *a: True,
|
'active': lambda *a: True,
|
||||||
|
@ -310,22 +310,22 @@ class account_account(osv.osv):
|
||||||
}
|
}
|
||||||
|
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
obj_self=self.browse(cr,uid,ids[0])
|
obj_self = self.browse(cr, uid, ids[0])
|
||||||
p_id=obj_self.parent_id and obj_self.parent_id.id
|
p_id = obj_self.parent_id and obj_self.parent_id.id
|
||||||
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
|
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
|
||||||
return False
|
return False
|
||||||
while(ids):
|
while(ids):
|
||||||
cr.execute('select distinct child_id from account_account_consol_rel where parent_id in ('+','.join(map(str,ids))+')')
|
cr.execute('select distinct child_id from account_account_consol_rel where parent_id in ('+','.join(map(str, ids))+')')
|
||||||
child_ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
child_ids = filter(None, map(lambda x: x[0], cr.fetchall()))
|
||||||
c_ids=child_ids
|
c_ids = child_ids
|
||||||
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
|
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
|
||||||
return False
|
return False
|
||||||
while len(c_ids):
|
while len(c_ids):
|
||||||
s_ids=self.search(cr,uid,[('parent_id','in',c_ids)])
|
s_ids = self.search(cr, uid, [('parent_id', 'in', c_ids)])
|
||||||
if p_id and (p_id in s_ids):
|
if p_id and (p_id in s_ids):
|
||||||
return False
|
return False
|
||||||
c_ids=s_ids
|
c_ids = s_ids
|
||||||
ids=child_ids
|
ids = child_ids
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
|
@ -333,7 +333,7 @@ class account_account(osv.osv):
|
||||||
]
|
]
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
if not args:
|
if not args:
|
||||||
args=[]
|
args = []
|
||||||
if not context:
|
if not context:
|
||||||
context = {}
|
context = {}
|
||||||
args = args[:]
|
args = args[:]
|
||||||
|
@ -342,20 +342,20 @@ class account_account(osv.osv):
|
||||||
if name and str(name).startswith('partner:'):
|
if name and str(name).startswith('partner:'):
|
||||||
part_id = int(name.split(':')[1])
|
part_id = int(name.split(':')[1])
|
||||||
part = self.pool.get('res.partner').browse(cr, user, part_id, context)
|
part = self.pool.get('res.partner').browse(cr, user, part_id, context)
|
||||||
args += [('id','in', (part.property_account_payable.id, part.property_account_receivable.id))]
|
args += [('id', 'in', (part.property_account_payable.id, part.property_account_receivable.id))]
|
||||||
name = False
|
name = False
|
||||||
if name and str(name).startswith('type:'):
|
if name and str(name).startswith('type:'):
|
||||||
type = name.split(':')[1]
|
type = name.split(':')[1]
|
||||||
args += [('type','=', type)]
|
args += [('type', '=', type)]
|
||||||
name = False
|
name = False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if name:
|
if name:
|
||||||
ids = self.search(cr, user, [('code','=like',name+"%")]+ args, limit=limit)
|
ids = self.search(cr, user, [('code', '=like', name+"%")]+args, limit=limit)
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.search(cr, user, [('shortcut','=',name)]+ args, limit=limit)
|
ids = self.search(cr, user, [('shortcut', '=', name)]+ args, limit=limit)
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit)
|
ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit)
|
||||||
else:
|
else:
|
||||||
ids = self.search(cr, user, args, context=context, limit=limit)
|
ids = self.search(cr, user, args, context=context, limit=limit)
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
@ -363,28 +363,28 @@ class account_account(osv.osv):
|
||||||
def name_get(self, cr, uid, ids, context={}):
|
def name_get(self, cr, uid, ids, context={}):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return []
|
return []
|
||||||
reads = self.read(cr, uid, ids, ['name','code'], context)
|
reads = self.read(cr, uid, ids, ['name', 'code'], context)
|
||||||
res = []
|
res = []
|
||||||
for record in reads:
|
for record in reads:
|
||||||
name = record['name']
|
name = record['name']
|
||||||
if record['code']:
|
if record['code']:
|
||||||
name = record['code']+' '+name
|
name = record['code'] + ' '+name
|
||||||
res.append((record['id'],name ))
|
res.append((record['id'], name))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default={}, context={},done_list=[]):
|
def copy(self, cr, uid, id, default={}, context={}, done_list=[]):
|
||||||
account = self.browse(cr, uid, id, context=context)
|
account = self.browse(cr, uid, id, context=context)
|
||||||
new_child_ids = []
|
new_child_ids = []
|
||||||
if not default:
|
if not default:
|
||||||
default={}
|
default = {}
|
||||||
default=default.copy()
|
default = default.copy()
|
||||||
default['parent_id'] = False
|
default['parent_id'] = False
|
||||||
if account.id in done_list:
|
if account.id in done_list:
|
||||||
return False
|
return False
|
||||||
done_list.append(account.id)
|
done_list.append(account.id)
|
||||||
if account:
|
if account:
|
||||||
for child in account.child_id:
|
for child in account.child_id:
|
||||||
child_ids=self.copy(cr, uid, child.id, default, context=context,done_list=done_list)
|
child_ids = self.copy(cr, uid, child.id, default, context=context, done_list=done_list)
|
||||||
if child_ids:
|
if child_ids:
|
||||||
new_child_ids.append(child_ids)
|
new_child_ids.append(child_ids)
|
||||||
default['child_parent_ids'] = [(6, 0, new_child_ids)]
|
default['child_parent_ids'] = [(6, 0, new_child_ids)]
|
||||||
|
@ -394,7 +394,7 @@ class account_account(osv.osv):
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context = {}
|
||||||
if 'active' in vals and not vals['active']:
|
if 'active' in vals and not vals['active']:
|
||||||
line_obj = self.pool.get('account.move.line')
|
line_obj = self.pool.get('account.move.line')
|
||||||
account_ids = self.search(cr, uid, [('id', 'child_of', ids)])
|
account_ids = self.search(cr, uid, [('id', 'child_of', ids)])
|
||||||
|
@ -441,7 +441,7 @@ class account_journal(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Journal Name', size=64, required=True, translate=True),
|
'name': fields.char('Journal Name', size=64, required=True, translate=True),
|
||||||
'code': fields.char('Code', size=16),
|
'code': fields.char('Code', size=16),
|
||||||
'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True),
|
'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('cash', 'Cash'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True),
|
||||||
'refund_journal': fields.boolean('Refund Journal'),
|
'refund_journal': fields.boolean('Refund Journal'),
|
||||||
|
|
||||||
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
|
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
|
||||||
|
@ -527,7 +527,6 @@ class account_fiscalyear(osv.osv):
|
||||||
|
|
||||||
def create_period(self,cr, uid, ids, context={}, interval=1):
|
def create_period(self,cr, uid, ids, context={}, interval=1):
|
||||||
for fy in self.browse(cr, uid, ids, context):
|
for fy in self.browse(cr, uid, ids, context):
|
||||||
dt = fy.date_start
|
|
||||||
ds = mx.DateTime.strptime(fy.date_start, '%Y-%m-%d')
|
ds = mx.DateTime.strptime(fy.date_start, '%Y-%m-%d')
|
||||||
while ds.strftime('%Y-%m-%d')<fy.date_stop:
|
while ds.strftime('%Y-%m-%d')<fy.date_stop:
|
||||||
de = ds + RelativeDateTime(months=interval, days=-1)
|
de = ds + RelativeDateTime(months=interval, days=-1)
|
||||||
|
@ -585,7 +584,11 @@ class account_period(osv.osv):
|
||||||
for obj_period in self.browse(cr,uid,ids):
|
for obj_period in self.browse(cr,uid,ids):
|
||||||
if obj_period.special:
|
if obj_period.special:
|
||||||
continue
|
continue
|
||||||
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:
|
|
||||||
|
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
|
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)])
|
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):
|
def unlink(self, cr, uid, ids, context={}, check=True):
|
||||||
toremove = []
|
toremove = []
|
||||||
for move in self.browse(cr, uid, ids, context):
|
for move in self.browse(cr, uid, ids, context):
|
||||||
if move['state'] <> 'draft':
|
if move['state'] != 'draft':
|
||||||
raise osv.except_osv(_('UserError'),
|
raise osv.except_osv(_('UserError'),
|
||||||
_('You can not delete posted movement: "%s"!') % \
|
_('You can not delete posted movement: "%s"!') % \
|
||||||
move['name'])
|
move['name'])
|
||||||
|
@ -962,7 +965,7 @@ class account_move(osv.osv):
|
||||||
|
|
||||||
if line.account_id.currency_id:
|
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):
|
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 abs(amount) < 0.0001:
|
||||||
if not len(line_draft_ids):
|
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)
|
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False)
|
||||||
where = ''
|
where = ''
|
||||||
if fiscalyear_id:
|
if fiscalyear_id:
|
||||||
pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids)
|
pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids)
|
||||||
if pids:
|
if pids:
|
||||||
where = ' and period_id in (' + (','.join(pids))+')'
|
where = ' and period_id in (' + (','.join(pids))+')'
|
||||||
return self._sum(cr, uid, ids, name, args, context,
|
return self._sum(cr, uid, ids, name, args, context,
|
||||||
where=where)
|
where=where)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue