|
- [[ move_ids.name ]] - [[ get_ref(voucher.id,move_ids) ]]
+ [[ move_ids.name ]] - [[ voucher.reference or '' ]]
|
diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py
index 65ebe1261c5..757198ab40f 100644
--- a/addons/account_voucher/voucher.py
+++ b/addons/account_voucher/voucher.py
@@ -134,8 +134,7 @@ class account_voucher(osv.osv):
],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}),
'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}),
'pre_line':fields.boolean('Previous Payments ?', required=False),
- 'date_due': fields.date('Due Date'),
-# 'term_id':fields.many2one('account.payment.term', 'Term', required=False),
+ 'date_due': fields.date('Due Date', readonly=True, states={'draft':[('readonly',False)]}),
}
_defaults = {
'period_id': _get_period,
@@ -166,6 +165,7 @@ class account_voucher(osv.osv):
voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount})
if not voucher.tax_id:
+ self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0})
continue
tax = [tax_pool.browse(cr, uid, voucher.tax_id.id)]
@@ -196,7 +196,6 @@ class account_voucher(osv.osv):
self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
return True
- # TODO: review this code.
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}):
tax_pool = self.pool.get('account.tax')
partner_pool = self.pool.get('res.partner')
@@ -215,17 +214,26 @@ class account_voucher(osv.osv):
for line in line_ids:
line_amount = 0.0
- if line[1]:
- line_amount = voucher_line_pool.browse(cr, uid, line[1]).untax_amount
- else:
- line_amount = line[2].get('amount')
+ line_amount = line[2].get('amount')
voucher_line_ids += [line[1]]
voucher_total += line_amount
total = voucher_total
+ total_tax = 0.0
+ if tax_id:
+ tax = [tax_pool.browse(cr, uid, tax_id)]
+ if partner_id:
+ partner = partner_pool.browse(cr, uid, partner_id) or False
+ taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
+ tax = tax_pool.browse(cr, uid, taxes)
+
+ if not tax[0].price_include:
+ for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes'):
+ total_tax += tax_line.get('amount')
+ total += total_tax
res.update({
- 'amount':total,
+ 'amount':total or voucher_total,
'tax_amount':total_tax
})
return {
@@ -246,6 +254,44 @@ class account_voucher(osv.osv):
})
return {'value':default}
+ def onchange_journal_voucher(self, cr, uid, ids, partner_id=False, journal_id=False, context={}):
+ """price
+ Returns a dict that contains new values and context
+
+ @param partner_id: latest value from user input for field partner_id
+ @param args: other arguments
+ @param context: context arguments, like lang, time zone
+
+ @return: Returns a dict which contains new values, and context
+ """
+ default = {
+ 'value':{},
+ }
+
+ if not partner_id or not journal_id:
+ return default
+
+ partner_pool = self.pool.get('res.partner')
+ journal_pool = self.pool.get('account.journal')
+
+ journal = journal_pool.browse(cr, uid, journal_id)
+ partner = partner_pool.browse(cr, uid, partner_id)
+ account_id = False
+ tr_type = False
+ if journal.type in ('sale','sale_refund'):
+ account_id = partner.property_account_receivable.id
+ tr_type = 'sale'
+ elif journal.type in ('purchase', 'purchase_refund','expense'):
+ account_id = partner.property_account_payable.id
+ tr_type = 'purchase'
+ else:
+ account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
+ tr_type = 'receipt'
+
+ default['value']['account_id'] = account_id
+ default['value']['type'] = tr_type
+ return default
+
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}):
"""price
Returns a dict that contains new values and context
@@ -311,17 +357,22 @@ class account_voucher(osv.osv):
total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit)
elif company_currency != currency_id and ttype == 'receipt':
total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit)
-
+
for line in moves:
- if line.credit and line.reconcile_partial_id:
+ if line.credit and line.reconcile_partial_id and ttype == 'receipt':
+ continue
+ if line.debit and line.reconcile_partial_id and ttype == 'payment':
continue
total_credit += line.credit or 0.0
total_debit += line.debit or 0.0
for line in moves:
- if line.credit and line.reconcile_partial_id:
+ if line.credit and line.reconcile_partial_id and ttype == 'receipt':
continue
+ if line.debit and line.reconcile_partial_id and ttype == 'payment':
+ continue
+
rs = {
'name':line.move_id.name,
'type': line.credit and 'dr' or 'cr',
@@ -370,7 +421,7 @@ class account_voucher(osv.osv):
}
}
- def onchange_journal(self, cr, uid, ids, journal_id):
+ def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context={}):
if not journal_id:
return False
journal_pool = self.pool.get('account.journal')
@@ -379,8 +430,10 @@ class account_voucher(osv.osv):
tax_id = False
if account_id and account_id.tax_ids:
tax_id = account_id.tax_ids[0].id
-
- return {'value':{'tax_id':tax_id}}
+
+ vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
+ vals['value'].update({'tax_id':tax_id})
+ return vals
def proforma_voucher(self, cr, uid, ids):
self.action_move_line_create(cr, uid, ids)
@@ -424,7 +477,7 @@ class account_voucher(osv.osv):
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
return super(account_voucher, self).unlink(cr, uid, ids, context=context)
- # TODO
+ # TODO: may be we can remove this method if not used anyware
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
res = {}
if not partner_id:
@@ -496,7 +549,7 @@ class account_voucher(osv.osv):
if credit < 0:
debit = -credit
credit = 0.0
-
+
move_line = {
'name':inv.name or '/',
'debit':debit,
@@ -510,7 +563,9 @@ class account_voucher(osv.osv):
'date':inv.date,
'date_maturity':inv.date_due
}
- master_line = move_line_pool.create(cr, uid, move_line)
+
+ if (debit == 0.0 or credit == 0.0 or debit+credit > 0) and (debit > 0.0 or credit > 0.0):
+ master_line = move_line_pool.create(cr, uid, move_line)
rec_list_ids = []
line_total = debit - credit
@@ -524,6 +579,7 @@ class account_voucher(osv.osv):
if not line.amount:
continue
amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, line.amount)
+
move_line = {
'journal_id':inv.journal_id.id,
'period_id':inv.period_id.id,
@@ -532,6 +588,7 @@ class account_voucher(osv.osv):
'move_id':move_id,
'partner_id':inv.partner_id.id,
'currency_id':inv.currency_id.id,
+ 'amount_currency':line.amount,
'analytic_account_id':line.account_analytic_id and line.account_analytic_id.id or False,
'quantity':1,
'credit':0.0,
@@ -552,11 +609,10 @@ class account_voucher(osv.osv):
line_total -= amount
move_line['credit'] = amount
- if inv.tax_id:
+ if inv.tax_id and inv.type in ('sale', 'purchase'):
move_line.update({
'account_tax_id':inv.tax_id.id,
})
-
master_line = move_line_pool.create(cr, uid, move_line)
if line.move_line_id.id:
rec_ids = [master_line, line.move_line_id.id]
@@ -574,7 +630,8 @@ class account_voucher(osv.osv):
'debit':diff<0 and -diff or 0.0,
}
account_id = False
- if inv.journal_id.type in ('sale','sale_refund', 'cash','bank'):
+ if inv.type in ('sale', 'receipt'):
+# if inv.journal_id.type in ('sale','sale_refund', 'cash', 'bank'):
account_id = inv.partner_id.property_account_receivable.id
else:
account_id = inv.partner_id.property_account_payable.id
@@ -585,7 +642,7 @@ class account_voucher(osv.osv):
'move_id': move_id,
'state':'posted'
})
- move_pool.post(cr, uid, [move_id], context={})
+ #move_pool.post(cr, uid, [move_id], context={})
for rec_ids in rec_list_ids:
if len(rec_ids) >= 2:
move_line_pool.reconcile_partial(cr, uid, rec_ids)
@@ -604,48 +661,33 @@ class account_voucher(osv.osv):
default['date'] = time.strftime('%Y-%m-%d')
return super(account_voucher, self).copy(cr, uid, id, default, context)
- # TODO
- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
- """
- Returns views and fields for current model where view will depend on {view_type}.
- @param view_id: list of fields, which required to read signatures
- @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
- @param context: context arguments, like lang, time zone
- @param toolbar: contains a list of reports, wizards, and links related to current model
-
- @return: Returns a dict that contains definition for fields, views, and toolbars
- """
- data_pool = self.pool.get('ir.model.data')
- journal_pool = self.pool.get('account.journal')
- voucher_type = {
- 'sale':'view_sale_receipt_form',
- 'purchase':'view_purchase_receipt_form',
- 'payment':'view_vendor_payment_form',
- 'receipt':'view_vendor_receipt_form'
- }
- if view_type == 'form':
- tview = voucher_type.get(context.get('type'))
- tview = tview or 'view_voucher_form'
- result = data_pool._get_id(cr, uid, 'account_voucher', tview)
- view_id = data_pool.browse(cr, uid, result, context=context).res_id
-
- res = super(account_voucher, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
-
- #Restrict the list of journal view in search view
- if view_type == 'search':
- type_search = {
- 'bank':[('type','in',['bank','cash'])],
- 'cash':[('type','in',['bank','cash'])],
- 'sale':[('type','in',['sale','purchase_refund'])],
- 'purchase':[('type','in',['purchase','sale_refund'])],
- 'expense':[('type','in',['purchase'])],
- 'sale_refund':[('type','in',['sale','purchase_refund'])],
- 'purchase_refund':[('type','in',['purchase','sale_refund'])]
- }
- domain = type_search.get(context.get('journal_type'))
- journal_list = journal_pool.name_search(cr, uid, '', domain)
- res['fields']['journal_id']['selection'] = journal_list
- return res
+# # TODO: remove this
+# def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+# """
+# Returns views and fields for current model where view will depend on {view_type}.
+# @param view_id: list of fields, which required to read signatures
+# @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
+# @param context: context arguments, like lang, time zone
+# @param toolbar: contains a list of reports, wizards, and links related to current model
+#
+# @return: Returns a dict that contains definition for fields, views, and toolbars
+# """
+# data_pool = self.pool.get('ir.model.data')
+# journal_pool = self.pool.get('account.journal')
+# voucher_type = {
+# 'sale':'view_sale_receipt_form',
+# 'purchase':'view_purchase_receipt_form',
+# 'payment':'view_vendor_payment_form',
+# 'receipt':'view_vendor_receipt_form'
+# }
+# if view_type == 'form':
+# tview = voucher_type.get(context.get('type'))
+# tview = tview or 'view_voucher_form'
+# result = data_pool._get_id(cr, uid, 'account_voucher', tview)
+# view_id = data_pool.browse(cr, uid, result, context=context).res_id
+#
+# res = super(account_voucher, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
+# return res
account_voucher()
@@ -733,9 +775,10 @@ class account_voucher_line(osv.osv):
journal = journal_pool.browse(cr, user, journal_id)
account_id = False
ttype = 'cr'
- if journal.type in ('sale', 'purchase_refund'):
+ if journal.type in ('sale', 'sale_refund'):
account_id = journal.default_credit_account_id and journal.default_credit_account_id.id or False
- elif journal.type in ('purchase', 'expense', 'sale_refund'):
+ ttype = 'cr'
+ elif journal.type in ('purchase', 'expense', 'purchase_refund'):
account_id = journal.default_debit_account_id and journal.default_debit_account_id.id or False
ttype = 'dr'
elif partner_id:
diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml
index 8656e819d6c..a708f42e257 100644
--- a/addons/account_voucher/voucher_payment_receipt_view.xml
+++ b/addons/account_voucher/voucher_payment_receipt_view.xml
@@ -1,6 +1,86 @@
+
+
+ account.voucher.customer.pay.select
+ account.voucher
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ account.voucher.purchase.pay.select
+ account.voucher
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
account.voucher.payment.form
account.voucher
@@ -26,7 +106,7 @@
-
+
Vendor Payment
- account.voucher.open
+ account.voucher
form
[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment')]
- {'journal_type':'bank', 'type':'payment'}
-
- new
+ {'type':'payment'}
+
+
+ current
+
+
+ tree
+
+
+
+
+ form
+
+
+
+
+
@@ -177,13 +271,26 @@
Sales Payment
- account.voucher.open
+ account.voucher
form
[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]
- {'journal_type':'bank', 'type':'receipt'}
-
- new
+ {'type':'receipt'}
+
+
+ current
+
+
+ tree
+
+
+
+
+ form
+
+
+
+
diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml
index 1abf4ec1ea1..7818a157dac 100644
--- a/addons/account_voucher/voucher_sales_purchase_view.xml
+++ b/addons/account_voucher/voucher_sales_purchase_view.xml
@@ -1,16 +1,96 @@
+
+ account.voucher.purchase.select
+ account.voucher
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ account.voucher.sale.select
+ account.voucher
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Sales Payment
account.voucher
form
[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt'), ('partner_id','=',partner_id)]
- {'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id}
+ {'type':'receipt', 'partner_id': partner_id, 'referance':referance}
new
+
account.voucher.sale.form
account.voucher
@@ -19,7 +99,7 @@
@@ -83,23 +164,38 @@
Sales Receipt
- account.voucher.open
+ account.voucher
form
- [('journal_id.type','in',['sale','purchase_refund']), ('type','=','sale')]
- {'journal_type':'sale', 'type':'sale'}
-
- new
+ [('journal_id.type','in',['sale','sale_refund']), ('type','=','sale')]
+ {'type':'sale'}
+
+
+ current
+
+
+ tree
+
+
+
+
+ form
+
+
+
+
-
+ action="action_sale_receipt"
+ parent="account.menu_finance_receivables"
+ sequence="10"/>
+
Bill Payment
account.voucher
form
[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment'), ('partner_id','=',partner_id)]
- {'journal_type':'bank', 'type':'payment', 'partner_id': partner_id}
+ {'type':'payment', 'partner_id': partner_id, 'referance':reference}
new
@@ -111,10 +207,10 @@
@@ -169,13 +264,26 @@
Vendor Bills
- account.voucher.open
+ account.voucher
form
- [('journal_id.type','in',['purchase','sale_refund']), ('type','=','purchase')]
- {'journal_type':'purchase', 'type':'purchase'}
-
- new
+ [('journal_id.type','in',['purchase','purchase_refund']), ('type','=','purchase')]
+ {'type':'purchase'}
+
+
+ current
+
+
+ tree
+
+
+
+
+ form
+
+
+
+
diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml
index 6e8e4ffe690..f51dd29d140 100644
--- a/addons/account_voucher/voucher_view.xml
+++ b/addons/account_voucher/voucher_view.xml
@@ -20,7 +20,7 @@
-
+
account.voucher.form
account.voucher
@@ -28,39 +28,57 @@
@@ -83,48 +101,7 @@
account.voucher.select
account.voucher
search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.voucher.select
- account.voucher
- search
+ 1
@@ -133,9 +110,9 @@
-
-
-
+
+
+
@@ -143,18 +120,19 @@
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
@@ -199,7 +177,7 @@
[('state','=','posted')]
{'state':'posted'}
-
+
diff --git a/addons/account_voucher/wizard/__init__.py b/addons/account_voucher/wizard/__init__.py
index a5c9a5e4f59..b7a7e00111a 100644
--- a/addons/account_voucher/wizard/__init__.py
+++ b/addons/account_voucher/wizard/__init__.py
@@ -19,5 +19,4 @@
#
##############################################################################
-import account_voucher_open
import account_voucher_unreconcile
diff --git a/addons/account_voucher/wizard/account_voucher_open.py b/addons/account_voucher/wizard/account_voucher_open.py
deleted file mode 100644
index 88a52c3145c..00000000000
--- a/addons/account_voucher/wizard/account_voucher_open.py
+++ /dev/null
@@ -1,147 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from osv import fields, osv
-from tools.translate import _
-import tools
-
-class account_voucher_open(osv.osv_memory):
- _name = "account.voucher.open"
- _description = "Account Voucher"
-
- def _get_period(self, cr, uid, context={}):
- """
- Return default account period value
- """
- ids = self.pool.get('account.period').find(cr, uid, context=context)
- period_id = False
- if len(ids):
- period_id = ids[0]
- return period_id
-
- def _get_journal(self, cr, uid, context={}):
- """
- Return journal based on the journal type
- """
- journal_id = False
-
- journal_pool = self.pool.get('account.journal')
- if context.get('journal_type', False):
- jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))])
- journal_id = jids[0]
- return journal_id
-
- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
- """
- Returns views and fields for current model where view will depend on {view_type}.
- @param cr: A database cursor
- @param user: ID of the user currently logged in
- @param view_id: list of fields, which required to read signatures
- @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
- @param context: context arguments, like lang, time zone
- @param toolbar: contains a list of reports, wizards, and links related to current model
-
- @return: Returns a dict that contains definition for fields, views, and toolbars
- """
- res = super(account_voucher_open, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
-
- if not view_id:
- return res
-
- period_pool = self.pool.get('account.period')
- journal_pool = self.pool.get('account.journal')
-
- journal_id = self._get_journal(cr, uid, context)
- period_id = self._get_period(cr, uid, context)
-
- journal = False
- if journal_id:
- journal = journal_pool.read(cr, uid, [journal_id], ['name'])[0]['name']
- else:
- journal = "All"
-
- period = False
- if period_id:
- period = period_pool.browse(cr, uid, [period_id], ['name'])[0]['name']
-
- menu = self.pool.get('ir.ui.menu').browse(cr, uid, context.get('active_id'))
- name = menu.name
-
- view = """
- """ % (str(name), str(journal), str(period))
-
- res.update({
- 'arch':view
- })
- return res
-
- def action_open_window(self, cr, uid, ids, context=None):
- """
- This function Open action move line window on given period and Journal/Payment Mode
- @param cr: the current row, from the database cursor,
- @param uid: the current user’s ID for security checks,
- @param ids: account move journal’s ID or list of IDs
- @return: dictionary of Open action move line window on given period and Journal/Payment Mode
- """
-
- period_pool = self.pool.get('account.journal.period')
- data_pool = self.pool.get('ir.model.data')
- journal_pool = self.pool.get('account.journal')
-
- if context is None:
- context = {}
-
- journal_id = self._get_journal(cr, uid, context)
- period_id = self._get_period(cr, uid, context)
-
- menu = self.pool.get('ir.ui.menu').browse(cr, uid, context.get('active_id'))
- name = context.get('title', menu.name)
-
- result = data_pool._get_id(cr, uid, 'account_voucher', 'view_voucher_filter_new')
- res_id = data_pool.browse(cr, uid, result, context=context).res_id
-
- res = {
- 'domain':menu.action.domain,
- 'name': name,
- 'view_type': 'form',
- 'view_mode': 'tree,graph,form',
- 'res_model': 'account.voucher',
- 'view_id': False,
- 'context': "{'search_default_journal_id':%d, 'search_default_period_id':%d, 'partner_id':%s}" % (journal_id, period_id, context.get('partner_id',False)),
- 'type': 'ir.actions.act_window',
- 'search_view_id': res_id
- }
- return res
-
-account_voucher_open()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_voucher/wizard/account_voucher_open_view.xml b/addons/account_voucher/wizard/account_voucher_open_view.xml
deleted file mode 100644
index 6168866b85c..00000000000
--- a/addons/account_voucher/wizard/account_voucher_open_view.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
- Open Vouchers
- account.voucher.open
- form
-
-
-
-
-
-
-
diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py
index 26f57c984c0..eef25f665d8 100644
--- a/addons/analytic/analytic.py
+++ b/addons/analytic/analytic.py
@@ -70,7 +70,7 @@ class account_analytic_account(osv.osv):
where_date += " AND l.date >= '" + context['from_date'] + "'"
if context.get('to_date', False):
where_date += " AND l.date <= '" + context['to_date'] + "'"
- cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
+ cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
r = dict(cr.fetchall())
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context)
@@ -90,7 +90,7 @@ class account_analytic_account(osv.osv):
where_date += " AND l.date >= '" + context['from_date'] + "'"
if context.get('to_date',False):
where_date += " AND l.date <= '" + context['to_date'] + "'"
- cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),))
+ cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),))
r = dict(cr.fetchall())
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context=context)
@@ -111,11 +111,10 @@ class account_analytic_account(osv.osv):
where_date += " AND l.date >= '" + context['from_date'] + "'"
if context.get('to_date',False):
where_date += " AND l.date <= '" + context['to_date'] + "'"
- cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
+ cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
for account_id, sum in cr.fetchall():
res[account_id] = sum
-
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _quantity_calc(self, cr, uid, ids, name, arg, context=None):
@@ -182,10 +181,10 @@ class account_analytic_account(osv.osv):
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'),
- 'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance',store=True),
- 'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit',store=True),
- 'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit',store=True),
- 'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity',store=True),
+ 'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'),
+ 'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit'),
+ 'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit'),
+ 'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'),
'partner_id' : fields.many2one('res.partner', 'Associated Partner'),
'contact_id' : fields.many2one('res.partner.address', 'Contact'),
@@ -216,7 +215,7 @@ class account_analytic_account(osv.osv):
'user_id' : lambda self, cr, uid, ctx : uid,
'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False),
'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False),
- 'date_start': time.strftime('%Y-%m-%d')
+ 'date_start': time.strftime('%Y-%m-%d')
}
def check_recursion(self, cr, uid, ids, parent=None):
diff --git a/addons/analytic/security/ir.model.access.csv b/addons/analytic/security/ir.model.access.csv
index 73dba08900c..6be5774177c 100644
--- a/addons/analytic/security/ir.model.access.csv
+++ b/addons/analytic/security/ir.model.access.csv
@@ -1,8 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_account_analytic_line_analytic_accounting","account.analytic.line","analytic.model_account_analytic_line","analytic.group_analytic_accounting",1,1,1,1
"access_account_analytic_account_analytic_accounting","account.analytic.account","analytic.model_account_analytic_account","analytic.group_analytic_accounting",1,1,1,1
-"access_account_analytic_journal_analytic_accounting","account.analytic.journal","account.model_account_analytic_journal","analytic.group_analytic_accounting",1,1,1,1
-"access_account_account_analytic_accounting","account.account","account.model_account_account","analytic.group_analytic_accounting",1,0,0,0
-"access_product_template_analytic_accounting","product.template","product.model_product_template","analytic.group_analytic_accounting",1,0,0,0
-"access_product_product_analytic_accounting","product.product","product.model_product_product","analytic.group_analytic_accounting",1,0,0,0
-"access_product_category_analytic_accounting","product.category","product.model_product_category","analytic.group_analytic_accounting",1,0,0,0
+
diff --git a/addons/project/project.py b/addons/project/project.py
index 16d85ce1bd4..0b9584655a8 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -27,6 +27,8 @@ from tools.translate import _
from osv import fields, osv
from tools import email_send as email
+from operator import itemgetter
+
class project_task_type(osv.osv):
_name = 'project.task.type'
_description = 'Task Stage'
@@ -395,7 +397,7 @@ class task(osv.osv):
if task['date_start'] > task['date_end']:
return False
return True
-
+
def _is_template(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for task in self.browse(cr, uid, ids, context=context):
@@ -451,9 +453,34 @@ class task(osv.osv):
}
_order = "sequence, priority, date_start, id"
+
+ def _check_recursion(self, cr, uid, ids):
+ obj_task = self.browse(cr, uid, ids[0])
+ parent_ids = [x.id for x in obj_task.parent_ids]
+ children_ids = [x.id for x in obj_task.child_ids]
+
+ if (obj_task.id in children_ids) or (obj_task.id in parent_ids):
+ return False
+
+ while(ids):
+ cr.execute('SELECT DISTINCT task_id '\
+ 'FROM project_task_parent_rel '\
+ 'WHERE parent_id IN %s', (tuple(ids),))
+ child_ids = map(itemgetter(0), cr.fetchall())
+ c_ids = child_ids
+ if (list(set(parent_ids).intersection(set(c_ids)))) or (obj_task.id in c_ids):
+ return False
+ while len(c_ids):
+ s_ids = self.search(cr, uid, [('parent_ids', 'in', c_ids)])
+ if (list(set(parent_ids).intersection(set(s_ids)))):
+ return False
+ c_ids = s_ids
+ ids = child_ids
+ return True
_constraints = [
- (_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end'])
+ (_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end']),
+ (_check_recursion, _('Error ! You cannot create recursive tasks.'), ['parent_ids'])
]
#
# Override view according to the company definition
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py
index 04fde75342e..79baff679cc 100644
--- a/addons/project_long_term/project_long_term.py
+++ b/addons/project_long_term/project_long_term.py
@@ -116,7 +116,7 @@ class project_phase(osv.osv):
'sequence': 10,
'product_uom': lambda self,cr,uid,c: self.pool.get('product.uom').search(cr, uid, [('name', '=', _('Day'))], context=c)[0]
}
- _order = "name"
+ _order = "project_id, date_start, sequence, name"
_constraints = [
(_check_recursion,'Loops in phases not allowed',['next_phase_ids', 'previous_phase_ids']),
(_check_dates, 'Phase start-date must be lower than phase end-date.', ['date_start', 'date_end']),
diff --git a/addons/project_messages/project_messages_view.xml b/addons/project_messages/project_messages_view.xml
index 9ef33c2643d..7c292f10a7e 100644
--- a/addons/project_messages/project_messages_view.xml
+++ b/addons/project_messages/project_messages_view.xml
@@ -10,7 +10,7 @@
-
+
|