diff --git a/addons/account/account.py b/addons/account/account.py
index ae506290ff3..0c1bfa62409 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -1701,6 +1701,11 @@ class account_tax(osv.osv):
ids = self.search(cr, user, args, limit=limit, context=context)
return self.name_get(cr, user, ids, context=context)
+ def write(self, cr, uid, ids, vals, context=None):
+ if vals.get('type', False) and vals['type'] in ('none', 'code'):
+ vals.update({'amount': 0.0})
+ return super(account_tax, self).write(cr, uid, ids, vals, context=context)
+
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
journal_pool = self.pool.get('account.journal')
@@ -1996,26 +2001,28 @@ class account_model(osv.osv):
_columns = {
'name': fields.char('Model Name', size=64, required=True, help="This is a model for recurring accounting entries"),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
- 'company_id': fields.many2one('res.company', 'Company', required=True),
+ 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
'legend' :fields.text('Legend', readonly=True, size=100),
}
_defaults = {
'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s : To Specify Year \n%(month)s : To Specify Month \n%(date)s : Current Date\n\ne.g. My model on %(date)s'),
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
- def generate(self, cr, uid, ids, datas={}, context={}):
+ def generate(self, cr, uid, ids, datas={}, context=None):
move_ids = []
entry = {}
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
pt_obj = self.pool.get('account.payment.term')
- if datas.get('date', False):
- context.update({'date':datas['date']})
- period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
+ if context is None:
+ context = {}
+ if datas.get('date', False):
+ context.update({'date': datas['date']})
+
+ period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
if not period_id:
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
period_id = period_id[0]
@@ -2069,7 +2076,9 @@ class account_model(osv.osv):
c = context.copy()
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
account_move_line_obj.create(cr, uid, val, context=c)
+
return move_ids
+
account_model()
class account_model_line(osv.osv):
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index be26005f997..3a7b259ab0f 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -176,15 +176,15 @@ class account_bank_statement(osv.osv):
}
_defaults = {
- 'name': lambda *a: "/",
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
- 'state': lambda *a: 'draft',
+ 'name': "/",
+ 'date': time.strftime('%Y-%m-%d'),
+ 'state': 'draft',
'balance_start': _default_balance_start,
'journal_id': _default_journal_id,
'period_id': _get_period,
}
- def onchange_date(self, cr, user, ids, date, context={}):
+ def onchange_date(self, cr, user, ids, date, context=None):
"""
Returns a dict that contains new values and context
@param cr: A database cursor
@@ -196,6 +196,10 @@ class account_bank_statement(osv.osv):
"""
res = {}
period_pool = self.pool.get('account.period')
+
+ if context is None:
+ context = {}
+
pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
if pids:
res.update({
@@ -210,10 +214,8 @@ class account_bank_statement(osv.osv):
'context':context,
}
- def button_dummy(self, cr, uid, ids, context={}):
- self.write(cr, uid, ids, {}, context)
- return True
-
+ def button_dummy(self, cr, uid, ids, context=None):
+ return self.write(cr, uid, ids, {}, context=context)
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
res_currency_obj = self.pool.get('res.currency')
@@ -348,7 +350,7 @@ class account_bank_statement(osv.osv):
company_currency_id = st.journal_id.company_id.currency_id.id
if not self.check_status_condition(cr, uid, st.state, journal_type=j_type):
continue
-
+
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
@@ -382,7 +384,7 @@ class account_bank_statement(osv.osv):
done.append(st.id)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
- def button_cancel(self, cr, uid, ids, context={}):
+ def button_cancel(self, cr, uid, ids, context=None):
done = []
for st in self.browse(cr, uid, ids, context):
if st.state=='draft':
@@ -392,8 +394,7 @@ class account_bank_statement(osv.osv):
ids += [x.id for x in line.move_ids]
self.pool.get('account.move').unlink(cr, uid, ids, context)
done.append(st.id)
- self.write(cr, uid, done, {'state':'draft'}, context=context)
- return True
+ return self.write(cr, uid, done, {'state':'draft'}, context=context)
def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None):
account_journal_obj = self.pool.get('account.journal')
@@ -424,7 +425,7 @@ class account_bank_statement(osv.osv):
context = {}
default = default.copy()
default['move_line_ids'] = []
- return super(account_bank_statement, self).copy(cr, uid, id, default, context)
+ return super(account_bank_statement, self).copy(cr, uid, id, default, context=context)
account_bank_statement()
@@ -496,8 +497,8 @@ class account_bank_statement_line(osv.osv):
}
_defaults = {
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
- 'type': lambda *a: 'general',
+ 'date': time.strftime('%Y-%m-%d'),
+ 'type': 'general',
}
account_bank_statement_line()
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 89bdcf0bffe..6d3f63118e1 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -95,8 +95,8 @@
-
-
+
+
@@ -528,7 +528,7 @@
-
+
-
+
Sales Receipt
@@ -205,7 +205,7 @@
-
-
+
+
diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml
index d785350b876..4b09fdc70e9 100644
--- a/addons/account_voucher/voucher_view.xml
+++ b/addons/account_voucher/voucher_view.xml
@@ -107,13 +107,6 @@
-
-
-
-
-
-
-
@@ -121,6 +114,13 @@
+
+
+
+
+
+
+
diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py
index eef25f665d8..b97edb9a546 100644
--- a/addons/analytic/analytic.py
+++ b/addons/analytic/analytic.py
@@ -35,16 +35,16 @@ class account_analytic_account(osv.osv):
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),))
currency = dict(cr.fetchall())
res_currency= self.pool.get('res.currency')
- for id in ids:
- if id not in ids2:
+ for account in self.browse(cr, uid, ids, context=context):
+ if account.id not in ids2:
continue
- for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
- if child != id:
- res.setdefault(id, 0.0)
- if currency[child]!=currency[id]:
- res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context)
+ for child in account.child_ids:
+ if child.id != account.id:
+ res.setdefault(account.id, 0.0)
+ if currency[child.id] != currency[account.id]:
+ res[account.id] += res_currency.compute(cr, uid, currency[child.id], currency[account.id], res.get(child.id, 0.0), context=context)
else:
- res[id] += res.get(child, 0.0)
+ res[account.id] += res.get(child.id, 0.0)
cur_obj = res_currency.browse(cr, uid, currency.values(), context=context)
cur_obj = dict([(o.id, o) for o in cur_obj])
@@ -145,13 +145,13 @@ class account_analytic_account(osv.osv):
for account_id, sum in cr.fetchall():
res[account_id] = sum
- for id in ids:
- if id not in parent_ids:
+ for account in self.browse(cr, uid, ids, context=context):
+ if account.id not in parent_ids:
continue
- for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
- if child != id:
- res.setdefault(id, 0.0)
- res[id] += res.get(child, 0.0)
+ for child in account.child_ids:
+ if child.id != account.id:
+ res.setdefault(account.id, 0.0)
+ res[account.id] += res.get(child.id, 0.0)
return dict([(i, res[i]) for i in ids])
def name_get(self, cr, uid, ids, context=None):
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index aaf344043d7..e816e3f0b1d 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -220,7 +220,6 @@
-
-
diff --git a/addons/hr/hr_department.py b/addons/hr/hr_department.py
index 21946469ce4..ec6f276e670 100644
--- a/addons/hr/hr_department.py
+++ b/addons/hr/hr_department.py
@@ -113,87 +113,10 @@ class res_users(osv.osv):
_inherit = 'res.users'
_description = 'User'
- def _parent_compute(self, cr, uid, ids, name, args, context=None):
- if context is None:
- context = {}
- result = {}
- obj_dept = self.pool.get('hr.department')
- for user_id in ids:
- emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)], context=context)
- cr.execute('SELECT emp.department_id FROM hr_employee AS emp \
- JOIN resource_resource AS res ON res.id = emp.resource_id \
- JOIN hr_department as dept ON dept.id = emp.department_id \
- WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,))
- ids_dept = [x[0] for x in cr.fetchall()]
- parent_ids = []
- if ids_dept:
- data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'], context=context)
- parent_ids = map(lambda x: x['manager_id'][0], data_dept)
- cr.execute('SELECT res.user_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id=emp.resource_id \
- WHERE emp.id IN %s AND res.user_id IS NOT NULL', (tuple(parent_ids),))
- parent_ids = [x[0] for x in cr.fetchall()]
- result[user_id] = parent_ids
- return result
-
- def _parent_search(self, cr, uid, obj, name, args, context=None):
- if context is None:
- context = {}
- parent = []
- for arg in args:
- if arg[0] == 'parent_id':
- parent = arg[2]
- child_ids = self._child_compute(cr, uid, parent, name, args, context=context)
- if not child_ids:
- return [('id', 'in', [0])]
- return [('id', 'in', child_ids.get(uid, []))]
-
- def _child_compute(self, cr, uid, ids, name, args, context=None):
- if context is None:
- context = {}
- obj_dept = self.pool.get('hr.department')
- obj_user = self.pool.get('res.users')
- result = {}
- for user_id in ids:
- child_ids = []
- cr.execute('SELECT dept.id FROM hr_department AS dept \
- LEFT JOIN hr_employee AS emp ON dept.manager_id = emp.id \
- WHERE emp.id IN \
- (SELECT emp.id FROM hr_employee \
- JOIN resource_resource r ON r.id = emp.resource_id WHERE r.user_id=' + str(user_id) + ') ')
- mgnt_dept_ids = [x[0] for x in cr.fetchall()]
- ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context)
- if ids_dept:
- data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context)
- childs = map(lambda x: x['member_ids'], data_dept)
- childs = tools.flatten(childs)
- childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context)
- if user_id in childs:
- childs.remove(user_id)
- child_ids.extend(tools.flatten(childs))
- set = {}
- map(set.__setitem__, child_ids, [])
- child_ids = set.keys()
- result[user_id] = child_ids
- return result
-
- def _child_search(self, cr, uid, obj, name, args, context=None):
- if context is None:
- context = {}
- parent = []
- for arg in args:
- if arg[0] == 'child_ids':
- parent = arg[2]
- child_ids = self._child_compute(cr, uid, parent, name, args, context=context)
- if not child_ids:
- return [('id', 'in', [0])]
- return [('id', 'in', child_ids.get(uid, []))]
-
_columns = {
- 'parent_id': fields.function(_parent_compute, relation='res.users', fnct_search=_parent_search, method=True, string="Managers", type='many2many'),
- 'child_ids': fields.function(_child_compute, relation='res.users', fnct_search=_child_search, method=True, string="Subordinates", type='many2many'),
'context_department_id': fields.many2one('hr.department', 'Departments'),
}
res_users()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr/hr_department_view.xml b/addons/hr/hr_department_view.xml
index c2bb6ac7390..7626c501167 100644
--- a/addons/hr/hr_department_view.xml
+++ b/addons/hr/hr_department_view.xml
@@ -87,10 +87,6 @@
-
-
-
-
diff --git a/addons/hr_expense/report/expense.rml b/addons/hr_expense/report/expense.rml
index bb9a1ba0b1c..4ae45ad0aa2 100644
--- a/addons/hr_expense/report/expense.rml
+++ b/addons/hr_expense/report/expense.rml
@@ -259,7 +259,7 @@
- [[ o.note or '' ]] [[ setTag('para','xpre') ]]
+ [[ setTag('para','xpre') ]] [[ o.note or '' ]]
diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py
index 7a6eaf14b58..48ffc1f6b20 100644
--- a/addons/hr_payroll/hr_payroll.py
+++ b/addons/hr_payroll/hr_payroll.py
@@ -784,6 +784,7 @@ class hr_payslip(osv.osv):
'contract_id':fields.many2one('hr.contract', 'Contract', required=False),
'igross': fields.float('Calculaton Field', readonly=True, digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
'inet': fields.float('Calculaton Field', readonly=True, digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
+ 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(Payslip) date."),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml
index fbfa2d1aad5..d833612e383 100644
--- a/addons/hr_payroll/hr_payroll_view.xml
+++ b/addons/hr_payroll/hr_payroll_view.xml
@@ -500,12 +500,12 @@
+
-
diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py
index ddcd2ccb501..527ef5c1e55 100644
--- a/addons/mrp_repair/mrp_repair.py
+++ b/addons/mrp_repair/mrp_repair.py
@@ -45,6 +45,7 @@ class mrp_repair(osv.osv):
"""
res = {}
cur_obj = self.pool.get('res.currency')
+
for repair in self.browse(cr, uid, ids):
res[repair.id] = 0.0
for line in repair.operations:
@@ -62,6 +63,7 @@ class mrp_repair(osv.osv):
@return: Dictionary of values.
"""
res = {}
+ #return {}.fromkeys(ids, 0)
cur_obj = self.pool.get('res.currency')
tax_obj = self.pool.get('account.tax')
for repair in self.browse(cr, uid, ids):
@@ -94,6 +96,14 @@ class mrp_repair(osv.osv):
res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
return res
+ def _get_lines(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+ result = {}
+ for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):
+ result[line.repair_id.id] = True
+ return result.keys()
+
_columns = {
'name': fields.char('Repair Reference',size=24, required=True),
'product_id': fields.many2one('product.product', string='Product to Repair', required=True, readonly=True, states={'draft':[('readonly',False)]}),
@@ -137,9 +147,21 @@ class mrp_repair(osv.osv):
'deliver_bool': fields.boolean('Deliver', help="Check this box if you want to manage the delivery once the product is repaired. If cheked, it will create a picking with selected product. Note that you can select the locations in the Info tab, if you have the extended view."),
'invoiced': fields.boolean('Invoiced', readonly=True),
'repaired': fields.boolean('Repaired', readonly=True),
- 'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'),
- 'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
- 'amount_total': fields.function(_amount_total, method=True, string='Total'),
+ 'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount',
+ store={
+ 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
+ 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
+ }),
+ 'amount_tax': fields.function(_amount_tax, method=True, string='Taxes',
+ store={
+ 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
+ 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
+ }),
+ 'amount_total': fields.function(_amount_total, method=True, string='Total',
+ store={
+ 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
+ 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
+ }),
}
_defaults = {
@@ -163,7 +185,6 @@ class mrp_repair(osv.osv):
})
return super(mrp_repair, self).copy(cr, uid, id, default, context)
-
def onchange_product_id(self, cr, uid, ids, product_id=None):
""" On change of product sets some values.
@param product_id: Changed product
diff --git a/addons/product/product.py b/addons/product/product.py
index eaa1df9ebf2..1b74bef87f9 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -377,23 +377,23 @@ class product_product(osv.osv):
res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra
return res
- def _get_partner_code_name(self, cr, uid, ids, product_id, partner_id, context={}):
- product = self.browse(cr, uid, [product_id], context)[0]
+ def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context={}):
for supinfo in product.seller_ids:
if supinfo.name.id == partner_id:
return {'code': supinfo.product_code, 'name': supinfo.product_name, 'variants': ''}
- return {'code' : product.default_code, 'name' : product.name, 'variants': product.variants}
+ res = {'code': product.default_code, 'name': product.name, 'variants': product.variants}
+ return res
def _product_code(self, cr, uid, ids, name, arg, context={}):
res = {}
for p in self.browse(cr, uid, ids, context):
- res[p.id] = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)['code']
+ res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)['code']
return res
def _product_partner_ref(self, cr, uid, ids, name, arg, context={}):
res = {}
for p in self.browse(cr, uid, ids, context):
- data = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)
+ data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)
if not data['variants']:
data['variants'] = p.variants
if not data['code']:
diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml
index 0ad753b0004..1c7f5c73c77 100644
--- a/addons/project_issue/project_issue_data.xml
+++ b/addons/project_issue/project_issue_data.xml
@@ -31,7 +31,7 @@
-
+
Version 6.0
diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py
index 4f78b2f7c85..c0d3cebdcca 100644
--- a/addons/wiki/wiki.py
+++ b/addons/wiki/wiki.py
@@ -164,7 +164,7 @@ class wiki_wiki2(osv.osv):
@param uid: the current user’s ID for security checks,
@param id: Give wiki page's ID """
- return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
+ return super(wiki_wiki2, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
def create_history(self, cr, uid, ids, vals, context=None):
history_id = False