[IMP]: Added context=None in function argument for rest modules.

bzr revid: uco@tinyerp.com-20101122103753-idv9fdaqc28rvugu
This commit is contained in:
uco (OpenERP) 2010-11-22 16:07:53 +05:30
parent 427cd9af23
commit 8035df3e11
94 changed files with 871 additions and 278 deletions

View File

@ -81,7 +81,7 @@ class job2phonecall(osv.osv_memory):
if id3: if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id id3 = data_obj.browse(cr, uid, id3, context=context).res_id
for job in job_case_obj.browse(cr, uid, context.get('active_id', False), context=context): for job in job_case_obj.browse(cr, uid, context.get('active_ids', []), context=context):
#TODO: Take other info from job #TODO: Take other info from job
new_phonecall_id = phonecall_case_obj.create(cr, uid, { new_phonecall_id = phonecall_case_obj.create(cr, uid, {
'name': job.name, 'name': job.name,

View File

@ -192,6 +192,8 @@ class mrp_repair(osv.osv):
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
default.update({ default.update({
'state':'draft', 'state':'draft',
'repaired':False, 'repaired':False,

View File

@ -30,6 +30,8 @@ class outlook_installer(osv.osv_memory):
_inherit = 'res.config.installer' _inherit = 'res.config.installer'
def default_get(self, cr, uid, fields, context=None): def default_get(self, cr, uid, fields, context=None):
if not context:
context = {}
data = super(outlook_installer, self).default_get(cr, uid, fields, context=context) data = super(outlook_installer, self).default_get(cr, uid, fields, context=context)
data['doc_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_outlook.html' data['doc_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_outlook.html'
file = open(addons.get_module_resource('outlook','plugin','openerp-outlook-addin.exe'), 'r') file = open(addons.get_module_resource('outlook','plugin','openerp-outlook-addin.exe'), 'r')

View File

@ -52,6 +52,8 @@ class account_cash_statement(osv.osv):
return True return True
def _user_allow(self, cr, uid, statement_id, context=None): def _user_allow(self, cr, uid, statement_id, context=None):
if not context:
context = {}
statement = self.browse(cr, uid, statement_id, context=context) statement = self.browse(cr, uid, statement_id, context=context)
if (not statement.journal_id.journal_users) and uid == 1: return True if (not statement.journal_id.journal_users) and uid == 1: return True
for user in statement.journal_id.journal_users: for user in statement.journal_id.journal_users:

View File

@ -60,6 +60,8 @@ class pos_order(osv.osv):
_order = "date_order, create_date desc" _order = "date_order, create_date desc"
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
if not context:
context = {}
for rec in self.browse(cr, uid, ids, context=context): for rec in self.browse(cr, uid, ids, context=context):
for rec_statement in rec.statement_ids: for rec_statement in rec.statement_ids:
if (rec_statement.statement_id and rec_statement.statement_id.state == 'confirm') or rec.state == 'done': if (rec_statement.statement_id and rec_statement.statement_id.state == 'confirm') or rec.state == 'done':
@ -70,6 +72,8 @@ class pos_order(osv.osv):
""" Changed price list on_change of partner_id""" """ Changed price list on_change of partner_id"""
if not part: if not part:
return {'value': {}} return {'value': {}}
if not context:
context = {}
pricelist = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_product_pricelist.id pricelist = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_product_pricelist.id
return {'value': {'pricelist_id': pricelist}} return {'value': {'pricelist_id': pricelist}}
@ -77,6 +81,8 @@ class pos_order(osv.osv):
""" Calculates amount_tax of order line """ Calculates amount_tax of order line
@param field_names: Names of fields. @param field_names: Names of fields.
@return: Dictionary of values """ @return: Dictionary of values """
if not context:
context = {}
cr.execute(""" cr.execute("""
SELECT SELECT
p.id, p.id,
@ -122,14 +128,12 @@ class pos_order(osv.osv):
res[order.id] = val res[order.id] = val
return res return res
def _get_date_payment(self, cr, uid, ids, context=None, *a): def _get_date_payment(self, cr, uid, ids, context, *a):
""" Find Validation Date """ Find Validation Date
@return: Dictionary of values """ @return: Dictionary of values """
res = {} res = {}
val = None val = None
if not context: for order in self.browse(cr, uid, ids):
context = {}
for order in self.browse(cr, uid, ids, context=context):
cr.execute("SELECT date_validation FROM pos_order WHERE id = %s", (order.id,)) cr.execute("SELECT date_validation FROM pos_order WHERE id = %s", (order.id,))
date_p = cr.fetchone() date_p = cr.fetchone()
date_p = date_p and date_p[0] or None date_p = date_p and date_p[0] or None
@ -199,6 +203,8 @@ class pos_order(osv.osv):
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
default.update({ default.update({
'state': 'draft', 'state': 'draft',
'partner_id': False, 'partner_id': False,
@ -293,6 +299,8 @@ class pos_order(osv.osv):
@param name: Names of fields. @param name: Names of fields.
@return: pricelist ID @return: pricelist ID
""" """
if not context:
context = {}
pricelist = self.pool.get('product.pricelist').search(cr, uid, [('name', '=', 'Public Pricelist')], context=context) pricelist = self.pool.get('product.pricelist').search(cr, uid, [('name', '=', 'Public Pricelist')], context=context)
return pricelist and pricelist[0] or False return pricelist and pricelist[0] or False
@ -341,6 +349,8 @@ class pos_order(osv.osv):
""" Test all amount is paid for this order """ Test all amount is paid for this order
@return: True @return: True
""" """
if not context:
context = {}
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
if order.lines and not order.amount_total: if order.lines and not order.amount_total:
return True return True
@ -506,6 +516,8 @@ class pos_order(osv.osv):
""" Changes order state to cancel """ Changes order state to cancel
@return: True @return: True
""" """
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'cancel'}, context=context) self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
self.cancel_picking(cr, uid, ids, context=context) self.cancel_picking(cr, uid, ids, context=context)
return True return True
@ -516,6 +528,8 @@ class pos_order(osv.osv):
statement_line_obj = self.pool.get('account.bank.statement.line') statement_line_obj = self.pool.get('account.bank.statement.line')
prod_obj = self.pool.get('product.product') prod_obj = self.pool.get('product.product')
property_obj = self.pool.get('ir.property') property_obj = self.pool.get('ir.property')
if not context:
context = {}
curr_c = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id curr_c = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
curr_company = curr_c.id curr_company = curr_c.id
order = self.browse(cr, uid, order_id, context=context) order = self.browse(cr, uid, order_id, context=context)
@ -678,6 +692,8 @@ class pos_order(osv.osv):
account_tax_obj = self.pool.get('account.tax') account_tax_obj = self.pool.get('account.tax')
res_obj=self.pool.get('res.users') res_obj=self.pool.get('res.users')
property_obj=self.pool.get('ir.property') property_obj=self.pool.get('ir.property')
if not context:
context = {}
period = account_period_obj.find(cr, uid, context=context)[0] period = account_period_obj.find(cr, uid, context=context)[0]
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
@ -904,10 +920,14 @@ class pos_order(osv.osv):
return True return True
def action_cancel(self, cr, uid, ids, context=None): def action_cancel(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'cancel'}, context=context) self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
return True return True
def action_done(self, cr, uid, ids, context=None): def action_done(self, cr, uid, ids, context=None):
if not context:
context = {}
for order in self.browse(cr, uid, ids, context=context): for order in self.browse(cr, uid, ids, context=context):
if not order.journal_entry: if not order.journal_entry:
self.create_account_move(cr, uid, ids, context=None) self.create_account_move(cr, uid, ids, context=None)
@ -936,11 +956,9 @@ account_bank_statement()
class account_bank_statement_line(osv.osv): class account_bank_statement_line(osv.osv):
_inherit = 'account.bank.statement.line' _inherit = 'account.bank.statement.line'
def _get_statement_journal(self, cr, uid, ids, context=None, *a): def _get_statement_journal(self, cr, uid, ids, context, *a):
res = {} res = {}
if not context: for line in self.browse(cr, uid, ids):
context = {}
for line in self.browse(cr, uid, ids, context=context):
res[line.id] = line.statement_id and line.statement_id.journal_id and line.statement_id.journal_id.name or None res[line.id] = line.statement_id and line.statement_id.journal_id and line.statement_id.journal_id.name or None
return res return res
_columns= { _columns= {
@ -1137,6 +1155,8 @@ class pos_order_line(osv.osv):
return {'value': {'notice': 'No Discount', 'price_ded': price * discount * 0.01 or 0.0}} return {'value': {'notice': 'No Discount', 'price_ded': price * discount * 0.01 or 0.0}}
def onchange_qty(self, cr, uid, ids, discount, qty, price, context=None): def onchange_qty(self, cr, uid, ids, discount, qty, price, context=None):
if not context:
context = {}
subtotal = qty * price subtotal = qty * price
if discount: if discount:
subtotal = subtotal - (subtotal * discount / 100) subtotal = subtotal - (subtotal * discount / 100)

View File

@ -34,6 +34,8 @@ class all_closed_cashbox_of_the_day(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : retrun report @return : retrun report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
return { return {
'type': 'ir.actions.report.xml', 'type': 'ir.actions.report.xml',

View File

@ -61,6 +61,8 @@ class pos_box_entries(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return :Return of operation of product @return :Return of operation of product
""" """
if not context:
context = {}
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
ids = product_obj.search(cr, uid, [('income_pdt', '=', True)], context=context) ids = product_obj.search(cr, uid, [('income_pdt', '=', True)], context=context)
res = product_obj.read(cr, uid, ids, ['id', 'name'], context=context) res = product_obj.read(cr, uid, ids, ['id', 'name'], context=context)
@ -95,6 +97,8 @@ class pos_box_entries(osv.osv_memory):
res_obj = self.pool.get('res.users') res_obj = self.pool.get('res.users')
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
bank_statement = self.pool.get('account.bank.statement.line') bank_statement = self.pool.get('account.bank.statement.line')
if not context:
context = {}
for data in self.read(cr, uid, ids, context=context): for data in self.read(cr, uid, ids, context=context):
vals = {} vals = {}
curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id

View File

@ -41,6 +41,8 @@ class pos_box_out(osv.osv_memory):
@return :Return of operation of product @return :Return of operation of product
""" """
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
if not context:
context = {}
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
ids = product_obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)], context=context) ids = product_obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)], context=context)
res = product_obj.read(cr, uid, ids, ['id', 'name'], context=context) res = product_obj.read(cr, uid, ids, ['id', 'name'], context=context)
@ -75,6 +77,8 @@ class pos_box_out(osv.osv_memory):
product_obj = self.pool.get('product.template') product_obj = self.pool.get('product.template')
productp_obj = self.pool.get('product.product') productp_obj = self.pool.get('product.product')
res_obj = self.pool.get('res.users') res_obj = self.pool.get('res.users')
if not context:
context = {}
for data in self.read(cr, uid, ids, context=context): for data in self.read(cr, uid, ids, context=context):
curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id curr_company = res_obj.browse(cr, uid, uid, context=context).company_id.id
statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')], context=context) statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')], context=context)

View File

@ -43,6 +43,8 @@ class pos_close_statement(osv.osv_memory):
j_ids = map(lambda x1: x1[0], cr.fetchall()) j_ids = map(lambda x1: x1[0], cr.fetchall())
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)], context=context) journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)], context=context) ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)], context=context)
if not context:
context = {}
for journal in journal_obj.browse(cr, uid, journal_ids, context=context): for journal in journal_obj.browse(cr, uid, journal_ids, context=context):
if not ids: if not ids:
raise osv.except_osv(_('Message'), _('Cash registers are already closed.')) raise osv.except_osv(_('Message'), _('Cash registers are already closed.'))

View File

@ -43,6 +43,8 @@ class pos_discount(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: New arch of view with new columns. @return: New arch of view with new columns.
""" """
if not context:
context = {}
super(pos_discount, self).view_init(cr, uid, fields_list, context=context) super(pos_discount, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
order = self.pool.get('pos.order').browse(cr, uid, record_id, context=context) order = self.pool.get('pos.order').browse(cr, uid, record_id, context=context)

View File

@ -40,6 +40,8 @@ class pos_open_statement(osv.osv_memory):
statement_obj = self.pool.get('account.bank.statement') statement_obj = self.pool.get('account.bank.statement')
sequence_obj = self.pool.get('ir.sequence') sequence_obj = self.pool.get('ir.sequence')
journal_obj = self.pool.get('account.journal') journal_obj = self.pool.get('account.journal')
if not context:
context = {}
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users " cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
"WHERE user_id = %s ORDER BY journal_id"% (uid, )) "WHERE user_id = %s ORDER BY journal_id"% (uid, ))

View File

@ -81,6 +81,8 @@ class pos_make_payment(osv.osv_memory):
return res return res
def view_init(self, cr, uid, fields_list, context=None): def view_init(self, cr, uid, fields_list, context=None):
if not context:
context = {}
super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context) super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
active_id = context and context.get('active_id', False) or False active_id = context and context.get('active_id', False) or False
if active_id: if active_id:
@ -140,13 +142,15 @@ class pos_make_payment(osv.osv_memory):
if the order is paid print invoice (if wanted) or ticket. if the order is paid print invoice (if wanted) or ticket.
""" """
order_obj = self.pool.get('pos.order') order_obj = self.pool.get('pos.order')
if not context:
context = {}
active_id = context and context.get('active_id', False) active_id = context and context.get('active_id', False)
order = order_obj.browse(cr, uid, active_id, context=context) order = order_obj.browse(cr, uid, active_id, context=context)
amount = order.amount_total - order.amount_paid amount = order.amount_total - order.amount_paid
data = self.read(cr, uid, ids, context=context)[0] data = self.read(cr, uid, ids, context=context)[0]
# Todo need to check ... # Todo need to check ...
if data['is_acc']: if data['is_acc']:
line_id, price = order_obj.add_product(cr, uid, order.id, data['product_id'], -1.0, context) line_id, price = order_obj.add_product(cr, uid, order.id, data['product_id'], -1.0, context=context)
amount = order.amount_total - order.amount_paid - price amount = order.amount_total - order.amount_paid - price
if amount != 0.0: if amount != 0.0:
@ -155,28 +159,28 @@ class pos_make_payment(osv.osv_memory):
if order_obj.test_paid(cr, uid, [active_id]): if order_obj.test_paid(cr, uid, [active_id]):
if data['partner_id'] and data['invoice_wanted']: if data['partner_id'] and data['invoice_wanted']:
order_obj.action_invoice(cr, uid, [active_id], context) order_obj.action_invoice(cr, uid, [active_id], context=context)
order_obj.create_picking(cr, uid, [active_id], context) order_obj.create_picking(cr, uid, [active_id], context=context)
if context.get('return', False): if context.get('return', False):
order_obj.write(cr, uid, [active_id], {'state':'done'}, context=context) order_obj.write(cr, uid, [active_id], {'state':'done'}, context=context)
else: else:
order_obj.write(cr, uid, [active_id],{'state':'paid'}, context=context) order_obj.write(cr, uid, [active_id],{'state':'paid'}, context=context)
return self.create_invoice(cr, uid, ids, context) return self.create_invoice(cr, uid, ids, context=context)
else: else:
context.update({'flag': True}) context.update({'flag': True})
order_obj.action_paid(cr, uid, [active_id], context) order_obj.action_paid(cr, uid, [active_id], context=context)
if context.get('return', False): if context.get('return', False):
order_obj.write(cr, uid, [active_id], {'state':'done'}, context=context) order_obj.write(cr, uid, [active_id], {'state':'done'}, context=context)
else: else:
order_obj.write(cr, uid, [active_id], {'state':'paid'}, context=context) order_obj.write(cr, uid, [active_id], {'state':'paid'}, context=context)
return self.print_report(cr, uid, ids, context) return self.print_report(cr, uid, ids, context=context)
if order.amount_paid > 0.0: if order.amount_paid > 0.0:
context.update({'flag': True}) context.update({'flag': True})
# Todo need to check # Todo need to check
order_obj.action_paid(cr, uid, [active_id], context) order_obj.action_paid(cr, uid, [active_id], context=context)
order_obj.write(cr, uid, [active_id], {'state': 'advance'}, context=context) order_obj.write(cr, uid, [active_id], {'state': 'advance'}, context=context)
return self.print_report(cr, uid, ids, context) return self.print_report(cr, uid, ids, context=context)
return {} return {}
@ -184,6 +188,8 @@ class pos_make_payment(osv.osv_memory):
""" """
Create a invoice Create a invoice
""" """
if not context:
context = {}
active_ids = [context and context.get('active_id', False)] active_ids = [context and context.get('active_id', False)]
datas = {'ids': active_ids} datas = {'ids': active_ids}
return { return {

View File

@ -35,6 +35,8 @@ class pos_receipt(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: New arch of view with new columns. @return: New arch of view with new columns.
""" """
if not context:
context = {}
order_lst = self. pool.get('pos.order').browse(cr, uid, context['active_id'], context=context) order_lst = self. pool.get('pos.order').browse(cr, uid, context['active_id'], context=context)
def print_report(self, cr, uid, ids, context=None): def print_report(self, cr, uid, ids, context=None):
@ -46,6 +48,8 @@ class pos_receipt(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : retrun report @return : retrun report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
return { return {
'type': 'ir.actions.report.xml', 'type': 'ir.actions.report.xml',

View File

@ -47,7 +47,7 @@ class pos_return(osv.osv_memory):
active_ids = context.get('active_ids') active_ids = context.get('active_ids')
if not context: if not context:
context={} context={}
for order in order_obj.browse(cr, uid, active_ids): for order in order_obj.browse(cr, uid, active_ids, context=context):
for line in order.lines: for line in order.lines:
if 'return%s'%(line.id) in fields: if 'return%s'%(line.id) in fields:
res['return%s'%(line.id)] = line.qty res['return%s'%(line.id)] = line.qty
@ -68,7 +68,7 @@ class pos_return(osv.osv_memory):
context={} context={}
active_ids=context.get('active_ids') active_ids=context.get('active_ids')
for order in order_obj.browse(cr, uid, active_ids): for order in order_obj.browse(cr, uid, active_ids, context=context):
for line in order.lines: for line in order.lines:
if 'return%s'%(line.id) not in self._columns: if 'return%s'%(line.id) not in self._columns:
self._columns['return%s'%(line.id)] = fields.float("Quantity") self._columns['return%s'%(line.id)] = fields.float("Quantity")
@ -101,7 +101,7 @@ class pos_return(osv.osv_memory):
<form string="Return lines"> <form string="Return lines">
<label string="Quantities you enter, match to products that will return to the stock." colspan="4"/>""" <label string="Quantities you enter, match to products that will return to the stock." colspan="4"/>"""
_line_fields = result['fields'] _line_fields = result['fields']
order=order_obj.browse(cr, uid, active_id) order=order_obj.browse(cr, uid, active_id, context=context)
for line in order.lines: for line in order.lines:
quantity=line.qty quantity=line.qty
_line_fields.update({ _line_fields.update({
@ -133,7 +133,7 @@ class pos_return(osv.osv_memory):
return result return result
def create_returns(self, cr, uid, data, context): def create_returns(self, cr, uid, data, context=None):
""" """
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -143,10 +143,12 @@ class pos_return(osv.osv_memory):
@return: Return the add product form again for adding more product @return: Return the add product form again for adding more product
""" """
if not context:
context = {}
current_rec = self.read(cr, uid, data[0], context=context) current_rec = self.read(cr, uid, data[0], context=context)
order_obj =self.pool.get('pos.order') order_obj =self.pool.get('pos.order')
line_obj = self.pool.get('pos.order.line') line_obj = self.pool.get('pos.order.line')
pos_current = order_obj.browse(cr, uid, context.get('active_id')) pos_current = order_obj.browse(cr, uid, context.get('active_id'), context=context)
pos_line_ids = pos_current.lines pos_line_ids = pos_current.lines
if pos_line_ids: if pos_line_ids:
for pos_line in pos_line_ids: for pos_line in pos_line_ids:
@ -171,7 +173,9 @@ class pos_return(osv.osv_memory):
'context': context, 'context': context,
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
} }
def create_returns2(self, cr, uid, ids, context): def create_returns2(self, cr, uid, ids, context=None):
if not context:
context = {}
active_id = context.get('active_id', False) active_id = context.get('active_id', False)
order_obj =self.pool.get('pos.order') order_obj =self.pool.get('pos.order')
line_obj = self.pool.get('pos.order.line') line_obj = self.pool.get('pos.order.line')
@ -188,7 +192,7 @@ class pos_return(osv.osv_memory):
for order_id in order_obj.browse(cr, uid, [active_id], context=context): for order_id in order_obj.browse(cr, uid, [active_id], context=context):
prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')])
val = property_obj.browse(cr, uid, prop_ids[0]).value_reference val = property_obj.browse(cr, uid, prop_ids[0], context=context).value_reference
cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w " cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
"WHERE w.lot_stock_id=s.id AND w.id=%s ", "WHERE w.lot_stock_id=s.id AND w.id=%s ",
(order_id.shop_id.warehouse_id.id,)) (order_id.shop_id.warehouse_id.id,))
@ -257,7 +261,7 @@ pos_return()
class add_product(osv.osv_memory): class add_product(osv.osv_memory):
_inherit = 'pos.add.product' _inherit = 'pos.add.product'
def select_product(self, cr, uid, ids, context): def select_product(self, cr, uid, ids, context=None):
""" """
To get the product and quantity and add in order . To get the product and quantity and add in order .
@param self: The object pointer. @param self: The object pointer.
@ -266,6 +270,8 @@ class add_product(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : Retrun the add product form again for adding more product @return : Retrun the add product form again for adding more product
""" """
if not context:
context = {}
active_id=context.get('active_id', False) active_id=context.get('active_id', False)
data = self.read(cr, uid, ids) data = self.read(cr, uid, ids)
@ -293,7 +299,7 @@ class add_product(osv.osv_memory):
location_id=res and res[0] or None location_id=res and res[0] or None
stock_dest_id = val.id stock_dest_id = val.id
prod_id=prod_obj.browse(cr, uid, prod) prod_id=prod_obj.browse(cr, uid, prod, context=context)
new_picking=picking_obj.create(cr, uid, { new_picking=picking_obj.create(cr, uid, {
'name':'%s (Added)' %order_id.name, 'name':'%s (Added)' %order_id.name,
'move_lines':[], 'move_lines':[],
@ -329,7 +335,7 @@ class add_product(osv.osv_memory):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
} }
def close_action(self, cr, uid, ids, context): def close_action(self, cr, uid, ids, context=None):
active_ids=context.get('active_ids', False) active_ids=context.get('active_ids', False)
order_obj = self.pool.get('pos.order') order_obj = self.pool.get('pos.order')
lines_obj = self.pool.get('pos.order.line') lines_obj = self.pool.get('pos.order.line')

View File

@ -42,6 +42,8 @@ class pos_sale_user(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : return report @return : return report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_id'], context=context) res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_id'], context=context)

View File

@ -39,6 +39,8 @@ class pos_sales_user_today_current_user(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : retrun report @return : retrun report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, [], context=context) res = self.read(cr, uid, ids, [], context=context)

View File

@ -40,6 +40,8 @@ class pos_sales_user_today(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : retrun report @return : retrun report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['user_id'], context=context) res = self.read(cr, uid, ids, ['user_id'], context=context)

View File

@ -28,7 +28,7 @@ class pos_scan_product(osv.osv_memory):
_columns = { _columns = {
'gencod': fields.char('Barcode',size=13,required= True) 'gencod': fields.char('Barcode',size=13,required= True)
} }
def scan(self, cr, uid, ids, context): def scan(self, cr, uid, ids, context=None):
""" """
To get the gencod and scan product To get the gencod and scan product
@param self: The object pointer. @param self: The object pointer.
@ -37,7 +37,8 @@ class pos_scan_product(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return : retrun gencod @return : retrun gencod
""" """
if not context:
context = {}
data=self.read(cr, uid, ids)[0] data=self.read(cr, uid, ids)[0]
record_id = context and context.get('active_id',False) record_id = context and context.get('active_id',False)
result =self. pool.get('pos.order.line')._scan_product(cr, uid, data['gencod'], 1, record_id) result =self. pool.get('pos.order.line')._scan_product(cr, uid, data['gencod'], 1, record_id)

View File

@ -52,7 +52,9 @@ class process_process(osv.osv):
'active' : lambda *a: True, 'active' : lambda *a: True,
} }
def search_by_model(self, cr, uid, res_model, context): def search_by_model(self, cr, uid, res_model, context=None):
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
model_ids = (res_model or None) and pool.get('ir.model').search(cr, uid, [('model', '=', res_model)]) model_ids = (res_model or None) and pool.get('ir.model').search(cr, uid, [('model', '=', res_model)])
@ -62,7 +64,7 @@ class process_process(osv.osv):
# search all processes # search all processes
res = pool.get('process.process').search(cr, uid, domain) res = pool.get('process.process').search(cr, uid, domain)
if res: if res:
res = pool.get('process.process').browse(cr, uid, res, context) res = pool.get('process.process').browse(cr, uid, res, context=context)
for process in res: for process in res:
result.append((process.id, process.name)) result.append((process.id, process.name))
return result return result
@ -70,18 +72,20 @@ class process_process(osv.osv):
# else search process nodes # else search process nodes
res = pool.get('process.node').search(cr, uid, domain) res = pool.get('process.node').search(cr, uid, domain)
if res: if res:
res = pool.get('process.node').browse(cr, uid, res, context) res = pool.get('process.node').browse(cr, uid, res, context=context)
for node in res: for node in res:
if (node.process_id.id, node.process_id.name) not in result: if (node.process_id.id, node.process_id.name) not in result:
result.append((node.process_id.id, node.process_id.name)) result.append((node.process_id.id, node.process_id.name))
return result return result
def graph_get(self, cr, uid, id, res_model, res_id, scale, context): def graph_get(self, cr, uid, id, res_model, res_id, scale, context=None):
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
process = pool.get('process.process').browse(cr, uid, [id], context)[0] process = pool.get('process.process').browse(cr, uid, [id], context=context)[0]
name = process.name name = process.name
resource = None resource = None
@ -95,13 +99,13 @@ class process_process(osv.osv):
states = dict(pool.get(res_model).fields_get(cr, uid, context=context).get('state', {}).get('selection', {})) states = dict(pool.get(res_model).fields_get(cr, uid, context=context).get('state', {}).get('selection', {}))
if res_id: if res_id:
current_object = pool.get(res_model).browse(cr, uid, [res_id], context)[0] current_object = pool.get(res_model).browse(cr, uid, [res_id], context=context)[0]
current_user = pool.get('res.users').browse(cr, uid, [uid], context)[0] current_user = pool.get('res.users').browse(cr, uid, [uid], context=context)[0]
expr_context = Env(current_object, current_user) expr_context = Env(current_object, current_user)
resource = current_object.name resource = current_object.name
if 'state' in current_object: if 'state' in current_object:
state = states.get(current_object.state, 'N/A') state = states.get(current_object.state, 'N/A')
perm = pool.get(res_model).perm_read(cr, uid, [res_id], context)[0] perm = pool.get(res_model).perm_read(cr, uid, [res_id], context=context)[0]
notes = process.note or "N/A" notes = process.note or "N/A"
nodes = {} nodes = {}
@ -188,7 +192,7 @@ class process_process(osv.osv):
nodes[nid]['res'] = resource = {'id': ref_id, 'model': ref_model} nodes[nid]['res'] = resource = {'id': ref_id, 'model': ref_model}
refobj = pool.get(ref_model).browse(cr, uid, [ref_id], context)[0] refobj = pool.get(ref_model).browse(cr, uid, [ref_id], context=context)[0]
fields = pool.get(ref_model).fields_get(cr, uid, context=context) fields = pool.get(ref_model).fields_get(cr, uid, context=context)
# check for directory_id from inherited from document module # check for directory_id from inherited from document module
@ -251,9 +255,12 @@ class process_process(osv.osv):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
process = pool.get('process.process').browse(cr, uid, [id], context)[0] process = pool.get('process.process').browse(cr, uid, [id], context=context)[0]
nodes = {} nodes = {}
transitions = {} transitions = {}
@ -312,11 +319,13 @@ class process_node(osv.osv):
def copy_data(self, cr, uid, id, default=None, context=None): def copy_data(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
default.update({ default.update({
'transition_in': [], 'transition_in': [],
'transition_out': [] 'transition_out': []
}) })
return super(process_node, self).copy_data(cr, uid, id, default, context) return super(process_node, self).copy_data(cr, uid, id, default, context=context)
process_node() process_node()
@ -369,6 +378,9 @@ class process_transition_action(osv.osv):
def copy_data(self, cr, uid, id, default=None, context=None): def copy_data(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
state = self.pool.get('process.transition.action').browse(cr, uid, [id], context=context)[0].state state = self.pool.get('process.transition.action').browse(cr, uid, [id], context=context)[0].state
if state: if state:

View File

@ -69,8 +69,10 @@ class StockMove(osv.osv):
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
default = default or {} default = default or {}
if not context:
context = {}
default['procurements'] = [] default['procurements'] = []
return super(StockMove, self).copy(cr, uid, id, default, context) return super(StockMove, self).copy(cr, uid, id, default, context=context)
StockMove() StockMove()
@ -130,6 +132,8 @@ class procurement_order(osv.osv):
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
procurements = self.read(cr, uid, ids, ['state']) procurements = self.read(cr, uid, ids, ['state'])
unlink_ids = [] unlink_ids = []
if not context:
context = {}
for s in procurements: for s in procurements:
if s['state'] in ['draft','cancel']: if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id']) unlink_ids.append(s['id'])
@ -144,6 +148,8 @@ class procurement_order(osv.osv):
@param product_id: Changed id of product. @param product_id: Changed id of product.
@return: Dictionary of values. @return: Dictionary of values.
""" """
if not context:
context = {}
if product_id: if product_id:
w = self.pool.get('product.product').browse(cr, uid, product_id, context=context) w = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
v = { v = {
@ -163,12 +169,16 @@ class procurement_order(osv.osv):
""" Checks if move is cancelled or not. """ Checks if move is cancelled or not.
@return: True or False. @return: True or False.
""" """
if not context:
context = {}
return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids, context=context)) return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids, context=context))
def check_move_done(self, cr, uid, ids, context=None): def check_move_done(self, cr, uid, ids, context=None):
""" Checks if move is done or not. """ Checks if move is done or not.
@return: True or False. @return: True or False.
""" """
if not context:
context = {}
return all(procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context)) return all(procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context))
# #
@ -203,6 +213,8 @@ class procurement_order(osv.osv):
""" Finds quantity of product used in procurement. """ Finds quantity of product used in procurement.
@return: Quantity of product. @return: Quantity of product.
""" """
if not context:
context = {}
proc = self.browse(cr, uid, id, context=context) proc = self.browse(cr, uid, id, context=context)
result = self._quantity_compute_get(cr, uid, proc, context=context) result = self._quantity_compute_get(cr, uid, proc, context=context)
if not result: if not result:
@ -213,8 +225,10 @@ class procurement_order(osv.osv):
""" Finds UoM of product used in procurement. """ Finds UoM of product used in procurement.
@return: UoM of product. @return: UoM of product.
""" """
proc = self.browse(cr, uid, id, context) if not context:
result = self._uom_compute_get(cr, uid, proc, context) context = {}
proc = self.browse(cr, uid, id, context=context)
result = self._uom_compute_get(cr, uid, proc, context=context)
if not result: if not result:
result = proc.product_uom.id result = proc.product_uom.id
return result return result
@ -228,14 +242,18 @@ class procurement_order(osv.osv):
return True return True
return False return False
def check_produce_service(self, cr, uid, procurement, context=[]): def check_produce_service(self, cr, uid, procurement, context=None):
if not context:
context = {}
return False return False
def check_produce_product(self, cr, uid, procurement, context=[]): def check_produce_product(self, cr, uid, procurement, context=None):
""" Finds BoM of a product if not found writes exception message. """ Finds BoM of a product if not found writes exception message.
@param procurement: Current procurement. @param procurement: Current procurement.
@return: True or False. @return: True or False.
""" """
if not context:
context = {}
return True return True
def check_make_to_stock(self, cr, uid, ids, context=None): def check_make_to_stock(self, cr, uid, ids, context=None):
@ -243,6 +261,8 @@ class procurement_order(osv.osv):
@return: True or False @return: True or False
""" """
ok = True ok = True
if not context:
context = {}
for procurement in self.browse(cr, uid, ids, context=context): for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.type == 'service': if procurement.product_id.type == 'service':
ok = ok and self._check_make_to_stock_service(cr, uid, procurement, context) ok = ok and self._check_make_to_stock_service(cr, uid, procurement, context)
@ -255,6 +275,8 @@ class procurement_order(osv.osv):
@return: True or Product Id. @return: True or Product Id.
""" """
res = True res = True
if not context:
context = {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
for procurement in self.browse(cr, uid, ids, context=context): for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.product_tmpl_id.supply_method <> 'produce': if procurement.product_id.product_tmpl_id.supply_method <> 'produce':
@ -312,6 +334,8 @@ class procurement_order(osv.osv):
@return: True @return: True
""" """
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
if not context:
context = {}
for procurement in self.browse(cr, uid, ids, context=context): for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_qty <= 0.00: if procurement.product_qty <= 0.00:
raise osv.except_osv(_('Data Insufficient !'), raise osv.except_osv(_('Data Insufficient !'),
@ -359,6 +383,8 @@ class procurement_order(osv.osv):
@return: True or move id. @return: True or move id.
""" """
ok = True ok = True
if not context:
context = {}
if procurement.move_id: if procurement.move_id:
id = procurement.move_id.id id = procurement.move_id.id
if not (procurement.move_id.state in ('done','assigned','cancel')): if not (procurement.move_id.state in ('done','assigned','cancel')):
@ -526,8 +552,10 @@ class stock_warehouse_orderpoint(osv.osv):
@param warehouse_id: Changed id of warehouse. @param warehouse_id: Changed id of warehouse.
@return: Dictionary of values. @return: Dictionary of values.
""" """
if not context:
context = {}
if warehouse_id: if warehouse_id:
w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context) w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context=context)
v = {'location_id': w.lot_stock_id.id} v = {'location_id': w.lot_stock_id.id}
return {'value': v} return {'value': v}
return {} return {}
@ -537,6 +565,8 @@ class stock_warehouse_orderpoint(osv.osv):
@param product_id: Changed id of product. @param product_id: Changed id of product.
@return: Dictionary of values. @return: Dictionary of values.
""" """
if not context:
context = {}
if product_id: if product_id:
prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
v = {'product_uom': prod.uom_id.id} v = {'product_uom': prod.uom_id.id}
@ -546,10 +576,12 @@ class stock_warehouse_orderpoint(osv.osv):
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
default.update({ default.update({
'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint') or '', 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint') or '',
}) })
return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context) return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context=context)
stock_warehouse_orderpoint() stock_warehouse_orderpoint()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -69,13 +69,13 @@ class procurement_order(osv.osv):
while True: while True:
cr.execute("select id from procurement_order where state='confirmed' and procure_method='make_to_order' order by priority,date_planned limit 500 offset %s", (offset,)) cr.execute("select id from procurement_order where state='confirmed' and procure_method='make_to_order' order by priority,date_planned limit 500 offset %s", (offset,))
ids = map(lambda x: x[0], cr.fetchall()) ids = map(lambda x: x[0], cr.fetchall())
for proc in procurement_obj.browse(cr, uid, ids): for proc in procurement_obj.browse(cr, uid, ids, context=context):
if maxdate >= proc.date_planned: if maxdate >= proc.date_planned:
wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr)
else: else:
offset += 1 offset += 1
report_later += 1 report_later += 1
for proc in procurement_obj.browse(cr, uid, ids): for proc in procurement_obj.browse(cr, uid, ids, context=context):
if proc.state == 'exception': if proc.state == 'exception':
report.append('PROC %d: on order - %3.2f %-5s - %s' % \ report.append('PROC %d: on order - %3.2f %-5s - %s' % \
(proc.id, proc.product_qty, proc.product_uom.name, (proc.id, proc.product_qty, proc.product_uom.name,
@ -98,7 +98,7 @@ class procurement_order(osv.osv):
else: else:
report_later += 1 report_later += 1
report_total += 1 report_total += 1
for proc in procurement_obj.browse(cr, uid, report_ids): for proc in procurement_obj.browse(cr, uid, report_ids, context=context):
if proc.state == 'exception': if proc.state == 'exception':
report.append('PROC %d: from stock - %3.2f %-5s - %s' % \ report.append('PROC %d: from stock - %3.2f %-5s - %s' % \
(proc.id, proc.product_qty, proc.product_uom.name, (proc.id, proc.product_qty, proc.product_uom.name,

View File

@ -62,14 +62,16 @@ class make_procurement(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which loads Procurement form view. @return: A dictionary which loads Procurement form view.
""" """
user = self.pool.get('res.users').browse(cr, uid, uid, context).login if not context:
context = {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context).login
wh_obj = self.pool.get('stock.warehouse') wh_obj = self.pool.get('stock.warehouse')
procurement_obj = self.pool.get('procurement.order') procurement_obj = self.pool.get('procurement.order')
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
for proc in self.browse(cr, uid, ids): for proc in self.browse(cr, uid, ids, context=context):
wh = wh_obj.browse(cr, uid, proc.warehouse_id.id, context) wh = wh_obj.browse(cr, uid, proc.warehouse_id.id, context=context)
procure_id = procurement_obj.create(cr, uid, { procure_id = procurement_obj.create(cr, uid, {
'name':'INT: '+str(user), 'name':'INT: '+str(user),
'date_planned': proc.date_planned, 'date_planned': proc.date_planned,
@ -109,6 +111,8 @@ class make_procurement(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
res = super(make_procurement, self).default_get(cr, uid, fields, context=context) res = super(make_procurement, self).default_get(cr, uid, fields, context=context)

View File

@ -26,15 +26,17 @@ class procurement_compute(osv.osv_memory):
_name = 'procurement.order.compute' _name = 'procurement.order.compute'
_description = 'Compute Procurement' _description = 'Compute Procurement'
def _procure_calculation_procure(self, cr, uid, ids, context): def _procure_calculation_procure(self, cr, uid, ids, context=None):
try: try:
if not context:
context = {}
proc_obj = self.pool.get('procurement.order') proc_obj = self.pool.get('procurement.order')
proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context) proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context)
finally: finally:
pass pass
return {} return {}
def procure_calculation(self, cr, uid, ids, context): def procure_calculation(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -42,6 +44,8 @@ class procurement_compute(osv.osv_memory):
@param ids: List of IDs selected @param ids: List of IDs selected
@param context: A standard dictionary @param context: A standard dictionary
""" """
if not context:
context = {}
threaded_calculation = threading.Thread(target=self._procure_calculation_procure, args=(cr, uid, ids, context)) threaded_calculation = threading.Thread(target=self._procure_calculation_procure, args=(cr, uid, ids, context))
threaded_calculation.start() threaded_calculation.start()
return {} return {}

View File

@ -39,7 +39,7 @@ class procurement_compute(osv.osv_memory):
'automatic': False, 'automatic': False,
} }
def _procure_calculation_orderpoint(self, cr, uid, ids, context): def _procure_calculation_orderpoint(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -47,13 +47,15 @@ class procurement_compute(osv.osv_memory):
@param ids: List of IDs selected @param ids: List of IDs selected
@param context: A standard dictionary @param context: A standard dictionary
""" """
if not context:
context = {}
proc_obj = self.pool.get('procurement.order') proc_obj = self.pool.get('procurement.order')
for proc in self.browse(cr, uid, ids): for proc in self.browse(cr, uid, ids, context=context):
proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context) proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
return {} return {}
def procure_calculation(self, cr, uid, ids, context): def procure_calculation(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -61,6 +63,8 @@ class procurement_compute(osv.osv_memory):
@param ids: List of IDs selected @param ids: List of IDs selected
@param context: A standard dictionary @param context: A standard dictionary
""" """
if not context:
context = {}
threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context)) threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
threaded_calculation.start() threaded_calculation.start()
return {} return {}

View File

@ -35,7 +35,7 @@ class procurement_compute_all(osv.osv_memory):
'automatic': lambda *a: False, 'automatic': lambda *a: False,
} }
def _procure_calculation_all(self, cr, uid, ids, context): def _procure_calculation_all(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -44,12 +44,14 @@ class procurement_compute_all(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
""" """
proc_obj = self.pool.get('procurement.order') proc_obj = self.pool.get('procurement.order')
for proc in self.browse(cr, uid, ids): if not context:
context = {}
for proc in self.browse(cr, uid, ids, context=context):
proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\ proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\
context=context) context=context)
return {} return {}
def procure_calculation(self, cr, uid, ids, context): def procure_calculation(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -57,6 +59,8 @@ class procurement_compute_all(osv.osv_memory):
@param ids: List of IDs selected @param ids: List of IDs selected
@param context: A standard dictionary @param context: A standard dictionary
""" """
if not context:
context = {}
threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context)) threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
threaded_calculation.start() threaded_calculation.start()
return {} return {}

View File

@ -40,6 +40,8 @@ class price_type(osv.osv):
mf = self.pool.get('ir.model.fields') mf = self.pool.get('ir.model.fields')
ids = mf.search(cr, uid, [('model','in', (('product.product'),('product.template'))), ('ttype','=','float')], context=context) ids = mf.search(cr, uid, [('model','in', (('product.product'),('product.template'))), ('ttype','=','float')], context=context)
res = [] res = []
if not context:
context = {}
for field in mf.browse(cr, uid, ids, context=context): for field in mf.browse(cr, uid, ids, context=context):
res.append((field.name, field.field_description)) res.append((field.name, field.field_description))
return res return res
@ -82,6 +84,8 @@ product_pricelist_type()
class product_pricelist(osv.osv): class product_pricelist(osv.osv):
def _pricelist_type_get(self, cr, uid, context=None): def _pricelist_type_get(self, cr, uid, context=None):
if not context:
context = {}
pricelist_type_obj = self.pool.get('product.pricelist.type') pricelist_type_obj = self.pool.get('product.pricelist.type')
pricelist_type_ids = pricelist_type_obj.search(cr, uid, [], order='name') pricelist_type_ids = pricelist_type_obj.search(cr, uid, [], order='name')
pricelist_types = pricelist_type_obj.read(cr, uid, pricelist_type_ids, ['key','name'], context=context) pricelist_types = pricelist_type_obj.read(cr, uid, pricelist_type_ids, ['key','name'], context=context)
@ -108,6 +112,8 @@ class product_pricelist(osv.osv):
result= [] result= []
if not all(ids): if not all(ids):
return result return result
if not context:
context = {}
for pl in self.browse(cr, uid, ids, context=context): for pl in self.browse(cr, uid, ids, context=context):
name = pl.name + ' ('+ pl.currency_id.name + ')' name = pl.name + ' ('+ pl.currency_id.name + ')'
result.append((pl.id,name)) result.append((pl.id,name))
@ -292,6 +298,8 @@ class product_pricelist(osv.osv):
return results return results
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None):
if not context:
context = {}
res_multi = self.price_get_multi(cr, uid, pricelist_ids=ids, products_by_qty_by_partner=[(prod_id, qty, partner)], context=context) res_multi = self.price_get_multi(cr, uid, pricelist_ids=ids, products_by_qty_by_partner=[(prod_id, qty, partner)], context=context)
res = res_multi[prod_id] res = res_multi[prod_id]
res.update({'item_id': {ids[-1]: ids[-1]}}) res.update({'item_id': {ids[-1]: ids[-1]}})
@ -470,6 +478,8 @@ class product_pricelist_version(osv.osv):
return super(product_pricelist_version, self).copy(cr, uid, id, default, context) return super(product_pricelist_version, self).copy(cr, uid, id, default, context)
def _check_date(self, cursor, user, ids, context=None): def _check_date(self, cursor, user, ids, context=None):
if not context:
context = {}
for pricelist_version in self.browse(cursor, user, ids, context=context): for pricelist_version in self.browse(cursor, user, ids, context=context):
if not pricelist_version.active: if not pricelist_version.active:
continue continue
@ -500,6 +510,8 @@ product_pricelist_version()
class product_pricelist_item(osv.osv): class product_pricelist_item(osv.osv):
def _price_field_get(self, cr, uid, context=None): def _price_field_get(self, cr, uid, context=None):
if not context:
context = {}
pt = self.pool.get('product.price.type') pt = self.pool.get('product.price.type')
ids = pt.search(cr, uid, [], context=context) ids = pt.search(cr, uid, [], context=context)
result = [] result = []
@ -521,6 +533,8 @@ class product_pricelist_item(osv.osv):
} }
def _check_recursion(self, cr, uid, ids, context=None): def _check_recursion(self, cr, uid, ids, context=None):
if not context:
context = {}
for obj_list in self.browse(cr, uid, ids, context=context): for obj_list in self.browse(cr, uid, ids, context=context):
if obj_list.base == -1: if obj_list.base == -1:
main_pricelist = obj_list.price_version_id.pricelist_id.id main_pricelist = obj_list.price_version_id.pricelist_id.id
@ -565,6 +579,8 @@ class product_pricelist_item(osv.osv):
def product_id_change(self, cr, uid, ids, product_id, context=None): def product_id_change(self, cr, uid, ids, product_id, context=None):
if not product_id: if not product_id:
return {} return {}
if not context:
context = {}
prod = self.pool.get('product.product').read(cr, uid, [product_id], ['code','name']) prod = self.pool.get('product.product').read(cr, uid, [product_id], ['code','name'])
if prod[0]['code']: if prod[0]['code']:
return {'value': {'name': prod[0]['code']}} return {'value': {'name': prod[0]['code']}}

View File

@ -49,16 +49,22 @@ class product_uom(osv.osv):
def _compute_factor_inv(self, factor): def _compute_factor_inv(self, factor):
return factor and round(1.0 / factor, 6) or 0.0 return factor and round(1.0 / factor, 6) or 0.0
def _factor_inv(self, cursor, user, ids, name, arg, context): def _factor_inv(self, cursor, user, ids, name, arg, context=None):
res = {} res = {}
if not context:
context = {}
for uom in self.browse(cursor, user, ids, context=context): for uom in self.browse(cursor, user, ids, context=context):
res[uom.id] = self._compute_factor_inv(uom.factor) res[uom.id] = self._compute_factor_inv(uom.factor)
return res return res
def _factor_inv_write(self, cursor, user, id, name, value, arg, context): def _factor_inv_write(self, cursor, user, id, name, value, arg, context=None):
if not context:
context = {}
return self.write(cursor, user, id, {'factor': self._compute_factor_inv(value)}, context=context) return self.write(cursor, user, id, {'factor': self._compute_factor_inv(value)}, context=context)
def create(self, cr, uid, data, context=None): def create(self, cr, uid, data, context=None):
if not context:
context = {}
if 'factor_inv' in data: if 'factor_inv' in data:
if data['factor_inv'] <> 1: if data['factor_inv'] <> 1:
data['factor'] = self._compute_factor_inv(data['factor_inv']) data['factor'] = self._compute_factor_inv(data['factor_inv'])
@ -155,7 +161,9 @@ class product_category(osv.osv):
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
if not len(ids): if not len(ids):
return [] return []
reads = self.read(cr, uid, ids, ['name','parent_id'], context) if not context:
context = {}
reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)
res = [] res = []
for record in reads: for record in reads:
name = record['name'] name = record['name']
@ -164,8 +172,10 @@ class product_category(osv.osv):
res.append((record['id'], name)) res.append((record['id'], name))
return res return res
def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context): def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
res = self.name_get(cr, uid, ids, context) if not context:
context = {}
res = self.name_get(cr, uid, ids, context=context)
return dict(res) return dict(res)
_name = "product.category" _name = "product.category"
@ -187,6 +197,8 @@ class product_category(osv.osv):
_order = "sequence" _order = "sequence"
def _check_recursion(self, cr, uid, ids, context=None): def _check_recursion(self, cr, uid, ids, context=None):
level = 100 level = 100
if not context:
context = {}
while len(ids): while len(ids):
cr.execute('select distinct parent_id from product_category where id IN %s',(tuple(ids),)) cr.execute('select distinct parent_id from product_category where id IN %s',(tuple(ids),))
ids = filter(None, map(lambda x:x[0], cr.fetchall())) ids = filter(None, map(lambda x:x[0], cr.fetchall()))
@ -212,6 +224,8 @@ class product_template(osv.osv):
_description = "Product Template" _description = "Product Template"
def _calc_seller(self, cr, uid, ids, fields, arg, context=None): def _calc_seller(self, cr, uid, ids, fields, arg, context=None):
result = {} result = {}
if not context:
context = {}
for product in self.browse(cr, uid, ids, context=context): for product in self.browse(cr, uid, ids, context=context):
for field in fields: for field in fields:
result[product.id] = {field:False} result[product.id] = {field:False}
@ -276,6 +290,8 @@ class product_template(osv.osv):
return res and res[0] or False return res and res[0] or False
def _default_category(self, cr, uid, context=None): def _default_category(self, cr, uid, context=None):
if not context:
context = {}
if 'categ_id' in context and context['categ_id']: if 'categ_id' in context and context['categ_id']:
return context['categ_id'] return context['categ_id']
md = self.pool.get('ir.model.data') md = self.pool.get('ir.model.data')
@ -308,12 +324,16 @@ class product_template(osv.osv):
} }
def _check_uom(self, cursor, user, ids, context=None): def _check_uom(self, cursor, user, ids, context=None):
if not context:
context = {}
for product in self.browse(cursor, user, ids, context=context): for product in self.browse(cursor, user, ids, context=context):
if product.uom_id.category_id.id <> product.uom_po_id.category_id.id: if product.uom_id.category_id.id <> product.uom_po_id.category_id.id:
return False return False
return True return True
def _check_uos(self, cursor, user, ids, context=None): def _check_uos(self, cursor, user, ids, context=None):
if not context:
context = {}
for product in self.browse(cursor, user, ids, context=context): for product in self.browse(cursor, user, ids, context=context):
if product.uos_id \ if product.uos_id \
and product.uos_id.category_id.id \ and product.uos_id.category_id.id \
@ -327,6 +347,8 @@ class product_template(osv.osv):
] ]
def name_get(self, cr, user, ids, context=None): def name_get(self, cr, user, ids, context=None):
if not context:
context = {}
if 'partner_id' in context: if 'partner_id' in context:
pass pass
return super(product_template, self).name_get(cr, user, ids, context) return super(product_template, self).name_get(cr, user, ids, context)
@ -334,14 +356,18 @@ class product_template(osv.osv):
product_template() product_template()
class product_product(osv.osv): class product_product(osv.osv):
def view_header_get(self, cr, uid, view_id, view_type, context): def view_header_get(self, cr, uid, view_id, view_type, context=None):
if not context:
context = {}
res = super(product_product, self).view_header_get(cr, uid, view_id, view_type, context) res = super(product_product, self).view_header_get(cr, uid, view_id, view_type, context)
if (context.get('categ_id', False)): if (context.get('categ_id', False)):
return _('Products: ')+self.pool.get('product.category').browse(cr, uid, context['categ_id'], context).name return _('Products: ')+self.pool.get('product.category').browse(cr, uid, context['categ_id'], context=context).name
return res return res
def _product_price(self, cr, uid, ids, name, arg, context=None): def _product_price(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if not context:
context = {}
quantity = context.get('quantity', 1) quantity = context.get('quantity', 1)
pricelist = context.get('pricelist', False) pricelist = context.get('pricelist', False)
if pricelist: if pricelist:
@ -367,6 +393,8 @@ class product_product(osv.osv):
def _product_lst_price(self, cr, uid, ids, name, arg, context=None): def _product_lst_price(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if not context:
context = {}
product_uom_obj = self.pool.get('product.uom') product_uom_obj = self.pool.get('product.uom')
for id in ids: for id in ids:
res.setdefault(id, 0.0) res.setdefault(id, 0.0)
@ -381,6 +409,8 @@ class product_product(osv.osv):
return res return res
def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context=None): def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context=None):
if not context:
context = {}
for supinfo in product.seller_ids: for supinfo in product.seller_ids:
if supinfo.name.id == partner_id: if supinfo.name.id == partner_id:
return {'code': supinfo.product_code or product.default_code, 'name': supinfo.product_name or product.name, 'variants': ''} return {'code': supinfo.product_code or product.default_code, 'name': supinfo.product_name or product.name, 'variants': ''}
@ -389,14 +419,18 @@ class product_product(osv.osv):
def _product_code(self, cr, uid, ids, name, arg, context=None): def _product_code(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if not context:
context = {}
for p in self.browse(cr, uid, ids, context=context): for p in self.browse(cr, uid, ids, context=context):
res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)['code'] res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context=context)['code']
return res return res
def _product_partner_ref(self, cr, uid, ids, name, arg, context=None): def _product_partner_ref(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if not context:
context = {}
for p in self.browse(cr, uid, ids, context=context): for p in self.browse(cr, uid, ids, context=context):
data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context) data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context=context)
if not data['variants']: if not data['variants']:
data['variants'] = p.variants data['variants'] = p.variants
if not data['code']: if not data['code']:
@ -447,6 +481,8 @@ class product_product(osv.osv):
return False return False
def _check_ean_key(self, cr, uid, ids, context=None): def _check_ean_key(self, cr, uid, ids, context=None):
if not context:
context = {}
for partner in self.browse(cr, uid, ids, context=context): for partner in self.browse(cr, uid, ids, context=context):
if not partner.ean13: if not partner.ean13:
continue continue
@ -475,6 +511,8 @@ class product_product(osv.osv):
def name_get(self, cr, user, ids, context=None): def name_get(self, cr, user, ids, context=None):
if not len(ids): if not len(ids):
return [] return []
if not context:
context = {}
def _name_get(d): def _name_get(d):
name = d.get('name','') name = d.get('name','')
code = d.get('default_code',False) code = d.get('default_code',False)
@ -483,7 +521,7 @@ class product_product(osv.osv):
if d['variants']: if d['variants']:
name = name + ' - %s' % (d['variants'],) name = name + ' - %s' % (d['variants'],)
return (d['id'], name) return (d['id'], name)
result = map(_name_get, self.read(cr, user, ids, ['variants','name','default_code'], context)) result = map(_name_get, self.read(cr, user, ids, ['variants','name','default_code'], context=context))
return result return result
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
@ -505,7 +543,7 @@ class product_product(osv.osv):
ids = self.search(cr, user, [('default_code','ilike',res.group(2))]+ args, limit=limit, context=context) ids = self.search(cr, user, [('default_code','ilike',res.group(2))]+ args, limit=limit, context=context)
else: else:
ids = self.search(cr, user, args, limit=limit, context=context) ids = self.search(cr, user, args, limit=limit, context=context)
result = self.name_get(cr, user, ids, context) result = self.name_get(cr, user, ids, context=context)
return result return result
# #
@ -599,6 +637,8 @@ class product_packaging(osv.osv):
if not len(ids): if not len(ids):
return [] return []
res = [] res = []
if not context:
context = {}
for pckg in self.browse(cr, uid, ids,context=context): for pckg in self.browse(cr, uid, ids,context=context):
p_name = pckg.ean and '[' + pckg.ean + '] ' or '' p_name = pckg.ean and '[' + pckg.ean + '] ' or ''
p_name += pckg.ul.name p_name += pckg.ul.name
@ -632,6 +672,8 @@ class product_supplierinfo(osv.osv):
_description = "Information about a product supplier" _description = "Information about a product supplier"
def _calc_qty(self, cr, uid, ids, fields, arg, context=None): def _calc_qty(self, cr, uid, ids, fields, arg, context=None):
result = {} result = {}
if not context:
context = {}
product_uom_pool = self.pool.get('product.uom') product_uom_pool = self.pool.get('product.uom')
for supplier_info in self.browse(cr, uid, ids, context=context): for supplier_info in self.browse(cr, uid, ids, context=context):
for field in fields: for field in fields:
@ -668,6 +710,8 @@ class product_supplierinfo(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'product.supplierinfo', context=c) 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'product.supplierinfo', context=c)
} }
def _check_uom(self, cr, uid, ids, context=None): def _check_uom(self, cr, uid, ids, context=None):
if not context:
context = {}
for supplier_info in self.browse(cr, uid, ids, context=context): for supplier_info in self.browse(cr, uid, ids, context=context):
if supplier_info.product_uom and supplier_info.product_uom.category_id.id <> supplier_info.product_id.uom_id.category_id.id: if supplier_info.product_uom and supplier_info.product_uom.category_id.id <> supplier_info.product_id.uom_id.category_id.id:
return False return False
@ -692,7 +736,7 @@ class product_supplierinfo(osv.osv):
partner_pool = self.pool.get('res.partner') partner_pool = self.pool.get('res.partner')
pricelist_pool = self.pool.get('product.pricelist') pricelist_pool = self.pool.get('product.pricelist')
currency_pool = self.pool.get('res.currency') currency_pool = self.pool.get('res.currency')
currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
for supplier in partner_pool.browse(cr, uid, supplier_ids, context=context): for supplier in partner_pool.browse(cr, uid, supplier_ids, context=context):
# Compute price from standard price of product # Compute price from standard price of product
price = product_pool.price_get(cr, uid, [product_id], 'standard_price')[product_id] price = product_pool.price_get(cr, uid, [product_id], 'standard_price')[product_id]
@ -734,8 +778,10 @@ pricelist_partnerinfo()
class res_users(osv.osv): class res_users(osv.osv):
_inherit = 'res.users' _inherit = 'res.users'
def _get_group(self, cr, uid, context): def _get_group(self, cr, uid, context=None):
result = super(res_users, self)._get_group(cr, uid, context) if not context:
context = {}
result = super(res_users, self)._get_group(cr, uid, context=context)
dataobj = self.pool.get('ir.model.data') dataobj = self.pool.get('ir.model.data')
try: try:
dummy,group_id = dataobj.get_object_reference(cr, 1, 'product', 'group_product_manager') dummy,group_id = dataobj.get_object_reference(cr, 1, 'product', 'group_product_manager')

View File

@ -48,8 +48,10 @@ class product_price_list(osv.osv_memory):
To get the date and print the report To get the date and print the report
@return : return report @return : return report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['price_list','qty1', 'qty2','qty3','qty4','qty5'], context) res = self.read(cr, uid, ids, ['price_list','qty1', 'qty2','qty3','qty4','qty5'], context=context)
res = res and res[0] or {} res = res and res[0] or {}
datas['form'] = res datas['form'] = res
return { return {

View File

@ -54,6 +54,8 @@ class stock_production_lot(osv.osv):
} }
# Assign dates according to products data # Assign dates according to products data
def create(self, cr, uid, vals, context=None): def create(self, cr, uid, vals, context=None):
if not context:
context = {}
newid = super(stock_production_lot, self).create(cr, uid, vals, context=context) newid = super(stock_production_lot, self).create(cr, uid, vals, context=context)
obj = self.browse(cr, uid, newid, context=context) obj = self.browse(cr, uid, newid, context=context)
towrite = [] towrite = []

View File

@ -49,6 +49,8 @@ class product_margin(osv.osv_memory):
@return: @return:
""" """
if not context:
context = {}
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
id = mod_obj.read(cr, uid, result, ['res_id']) id = mod_obj.read(cr, uid, result, ['res_id'])
@ -60,7 +62,7 @@ class product_margin(osv.osv_memory):
view_res = cr.fetchone()[0] view_res = cr.fetchone()[0]
#get the current product.margin object to obtain the values from it #get the current product.margin object to obtain the values from it
product_margin_obj = self.browse(cr,uid,ids)[0] product_margin_obj = self.browse(cr, uid, ids, context=context)[0]
return { return {
'name': _('Product Margins'), 'name': _('Product Margins'),

View File

@ -52,6 +52,8 @@ class project(osv.osv):
_inherits = {'account.analytic.account': "analytic_account_id"} _inherits = {'account.analytic.account': "analytic_account_id"}
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
if not context:
context = {}
if user == 1: if user == 1:
return super(project, self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) return super(project, self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
if context and context.has_key('user_prefence') and context['user_prefence']: if context and context.has_key('user_prefence') and context['user_prefence']:
@ -65,6 +67,8 @@ class project(osv.osv):
def _complete_name(self, cr, uid, ids, name, args, context=None): def _complete_name(self, cr, uid, ids, name, args, context=None):
res = {} res = {}
if not context:
context = {}
for m in self.browse(cr, uid, ids, context=context): for m in self.browse(cr, uid, ids, context=context):
res[m.id] = (m.parent_id and (m.parent_id.name + '/') or '') + m.name res[m.id] = (m.parent_id and (m.parent_id.name + '/') or '') + m.name
return res return res
@ -73,6 +77,8 @@ class project(osv.osv):
partner_obj = self.pool.get('res.partner') partner_obj = self.pool.get('res.partner')
if not part: if not part:
return {'value':{'contact_id': False, 'pricelist_id': False}} return {'value':{'contact_id': False, 'pricelist_id': False}}
if not context:
context = {}
addr = partner_obj.address_get(cr, uid, [part], ['contact']) addr = partner_obj.address_get(cr, uid, [part], ['contact'])
pricelist = partner_obj.read(cr, uid, part, ['property_product_pricelist'], context=context) pricelist = partner_obj.read(cr, uid, part, ['property_product_pricelist'], context=context)
pricelist_id = pricelist.get('property_product_pricelist', False) and pricelist.get('property_product_pricelist')[0] or False pricelist_id = pricelist.get('property_product_pricelist', False) and pricelist.get('property_product_pricelist')[0] or False
@ -83,6 +89,8 @@ class project(osv.osv):
progress = {} progress = {}
if not ids: if not ids:
return res return res
if not context:
context = {}
cr.execute('''SELECT cr.execute('''SELECT
project_id, sum(planned_hours), sum(total_hours), sum(effective_hours), SUM(remaining_hours) project_id, sum(planned_hours), sum(total_hours), sum(effective_hours), SUM(remaining_hours)
FROM FROM
@ -167,22 +175,28 @@ class project(osv.osv):
} }
# TODO: Why not using a SQL contraints ? # TODO: Why not using a SQL contraints ?
def _check_dates(self, cr, uid, ids): def _check_dates(self, cr, uid, ids, context=None):
for leave in self.read(cr, uid, ids, ['date_start', 'date']): if not context:
context = {}
for leave in self.read(cr, uid, ids, ['date_start', 'date'], context=context):
if leave['date_start'] and leave['date']: if leave['date_start'] and leave['date']:
if leave['date_start'] > leave['date']: if leave['date_start'] > leave['date']:
return False return False
return True return True
_constraints = [ _constraints = [
(_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date']) (_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date'])
] ]
def set_template(self, cr, uid, ids, context=None): def set_template(self, cr, uid, ids, context=None):
if not context:
context = {}
res = self.setActive(cr, uid, ids, value=False, context=context) res = self.setActive(cr, uid, ids, value=False, context=context)
return res return res
def set_done(self, cr, uid, ids, context=None): def set_done(self, cr, uid, ids, context=None):
if not context:
context = {}
task_obj = self.pool.get('project.task') task_obj = self.pool.get('project.task')
task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', 'not in', ('cancelled', 'done'))]) task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', 'not in', ('cancelled', 'done'))])
task_obj.write(cr, uid, task_ids, {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0}) task_obj.write(cr, uid, task_ids, {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
@ -193,6 +207,8 @@ class project(osv.osv):
return True return True
def set_cancel(self, cr, uid, ids, context=None): def set_cancel(self, cr, uid, ids, context=None):
if not context:
context = {}
task_obj = self.pool.get('project.task') task_obj = self.pool.get('project.task')
task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', '!=', 'done')]) task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', '!=', 'done')])
task_obj.write(cr, uid, task_ids, {'state': 'cancelled', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0}) task_obj.write(cr, uid, task_ids, {'state': 'cancelled', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
@ -200,14 +216,20 @@ class project(osv.osv):
return True return True
def set_pending(self, cr, uid, ids, context=None): def set_pending(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state':'pending'}, context=context) self.write(cr, uid, ids, {'state':'pending'}, context=context)
return True return True
def set_open(self, cr, uid, ids, context=None): def set_open(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state':'open'}, context=context) self.write(cr, uid, ids, {'state':'open'}, context=context)
return True return True
def reset_project(self, cr, uid, ids, context=None): def reset_project(self, cr, uid, ids, context=None):
if not context:
context = {}
res = self.setActive(cr, uid, ids, value=True, context=context) res = self.setActive(cr, uid, ids, value=True, context=context)
for (id, name) in self.name_get(cr, uid, ids): for (id, name) in self.name_get(cr, uid, ids):
message = _("The project '%s' has been opened.") % name message = _("The project '%s' has been opened.") % name
@ -307,6 +329,8 @@ class task(osv.osv):
_date_name = "date_start" _date_name = "date_start"
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
if not context:
context = {}
obj_project = self.pool.get('project.project') obj_project = self.pool.get('project.project')
for domain in args: for domain in args:
if domain[0] == 'project_id' and (not isinstance(domain[2], str)): if domain[0] == 'project_id' and (not isinstance(domain[2], str)):
@ -325,6 +349,8 @@ class task(osv.osv):
def _hours_get(self, cr, uid, ids, field_names, args, context=None): def _hours_get(self, cr, uid, ids, field_names, args, context=None):
project_obj = self.pool.get('project.project') project_obj = self.pool.get('project.project')
res = {} res = {}
if not context:
context = {}
cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id IN %s GROUP BY task_id",(tuple(ids),)) cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id IN %s GROUP BY task_id",(tuple(ids),))
hours = dict(cr.fetchall()) hours = dict(cr.fetchall())
for task in self.browse(cr, uid, ids, context=context): for task in self.browse(cr, uid, ids, context=context):
@ -355,6 +381,8 @@ class task(osv.osv):
def copy_data(self, cr, uid, id, default={}, context=None): def copy_data(self, cr, uid, id, default={}, context=None):
default = default or {} default = default or {}
if not context:
context = {}
default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False}) default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False})
if not default.get('remaining_hours', False): if not default.get('remaining_hours', False):
default['remaining_hours'] = float(self.read(cr, uid, id, ['planned_hours'])['planned_hours']) default['remaining_hours'] = float(self.read(cr, uid, id, ['planned_hours'])['planned_hours'])
@ -365,6 +393,8 @@ class task(osv.osv):
return super(task, self).copy_data(cr, uid, id, default, context) return super(task, self).copy_data(cr, uid, id, default, context)
def _check_dates(self, cr, uid, ids, context=None): def _check_dates(self, cr, uid, ids, context=None):
if not context:
context = {}
task = self.read(cr, uid, ids[0], ['date_start', 'date_end']) task = self.read(cr, uid, ids[0], ['date_start', 'date_end'])
if task['date_start'] and task['date_end']: if task['date_start'] and task['date_end']:
if task['date_start'] > task['date_end']: if task['date_start'] > task['date_end']:
@ -373,6 +403,8 @@ class task(osv.osv):
def _is_template(self, cr, uid, ids, field_name, arg, context=None): def _is_template(self, cr, uid, ids, field_name, arg, context=None):
res = {} res = {}
if not context:
context = {}
for task in self.browse(cr, uid, ids, context=context): for task in self.browse(cr, uid, ids, context=context):
res[task.id] = True res[task.id] = True
if task.project_id: if task.project_id:
@ -450,8 +482,10 @@ class task(osv.osv):
_order = "sequence, priority, date_start, id" _order = "sequence, priority, date_start, id"
def _check_recursion(self, cr, uid, ids): def _check_recursion(self, cr, uid, ids, context=None):
obj_task = self.browse(cr, uid, ids[0]) if not context:
context = {}
obj_task = self.browse(cr, uid, ids[0], context=context)
parent_ids = [x.id for x in obj_task.parent_ids] parent_ids = [x.id for x in obj_task.parent_ids]
children_ids = [x.id for x in obj_task.child_ids] children_ids = [x.id for x in obj_task.child_ids]
@ -483,10 +517,12 @@ class task(osv.osv):
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
users_obj = self.pool.get('res.users') users_obj = self.pool.get('res.users')
if not context:
context = {}
# read uom as admin to avoid access rights issues, e.g. for portal/share users, # read uom as admin to avoid access rights issues, e.g. for portal/share users,
# this should be safe (no context passed to avoid side-effects) # this should be safe (no context passed to avoid side-effects)
obj_tm = users_obj.browse(cr, 1, uid).company_id.project_time_mode_id obj_tm = users_obj.browse(cr, 1, uid, context=context).company_id.project_time_mode_id
tm = obj_tm and obj_tm.name or 'Hours' tm = obj_tm and obj_tm.name or 'Hours'
res = super(task, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu) res = super(task, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu)
@ -516,6 +552,8 @@ class task(osv.osv):
# This action open wizard to send email to partner or project manager after close task. # This action open wizard to send email to partner or project manager after close task.
project_id = len(ids) and ids[0] or False project_id = len(ids) and ids[0] or False
if not project_id: return False if not project_id: return False
if not context:
context = {}
task = self.browse(cr, uid, project_id, context=context) task = self.browse(cr, uid, project_id, context=context)
project = task.project_id project = task.project_id
res = self.do_close(cr, uid, [project_id], context=context) res = self.do_close(cr, uid, [project_id], context=context)
@ -641,17 +679,17 @@ class task(osv.osv):
'description': delegate_data['new_task_description'] or '', 'description': delegate_data['new_task_description'] or '',
'child_ids': [], 'child_ids': [],
'work_ids': [] 'work_ids': []
}, context) }, context=context)
newname = delegate_data['prefix'] or '' newname = delegate_data['prefix'] or ''
self.write(cr, uid, [task.id], { self.write(cr, uid, [task.id], {
'remaining_hours': delegate_data['planned_hours_me'], 'remaining_hours': delegate_data['planned_hours_me'],
'planned_hours': delegate_data['planned_hours_me'] + (task.effective_hours or 0.0), 'planned_hours': delegate_data['planned_hours_me'] + (task.effective_hours or 0.0),
'name': newname, 'name': newname,
}, context) }, context=context)
if delegate_data['state'] == 'pending': if delegate_data['state'] == 'pending':
self.do_pending(cr, uid, [task.id], context) self.do_pending(cr, uid, [task.id], context)
else: else:
self.do_close(cr, uid, [task.id], context) self.do_close(cr, uid, [task.id], context=context)
user_pool = self.pool.get('res.users') user_pool = self.pool.get('res.users')
delegate_user = user_pool.browse(cr, uid, delegate_data['user_id'], context=context) delegate_user = user_pool.browse(cr, uid, delegate_data['user_id'], context=context)
message = _("The task '%s' has been delegated to %s.") % (delegate_data['name'], delegate_user.name) message = _("The task '%s' has been delegated to %s.") % (delegate_data['name'], delegate_user.name)
@ -714,11 +752,13 @@ class project_work(osv.osv):
cr.execute('update project_task set remaining_hours=remaining_hours - %s where id=%s', (vals.get('hours',0.0), vals['task_id'])) cr.execute('update project_task set remaining_hours=remaining_hours - %s where id=%s', (vals.get('hours',0.0), vals['task_id']))
return super(project_work,self).create(cr, uid, vals, *args, **kwargs) return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def write(self, cr, uid, ids,vals,context={}): def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
if 'hours' in vals and (not vals['hours']): if 'hours' in vals and (not vals['hours']):
vals['hours'] = 0.00 vals['hours'] = 0.00
if 'hours' in vals: if 'hours' in vals:
for work in self.browse(cr, uid, ids, context): for work in self.browse(cr, uid, ids, context=context):
cr.execute('update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s', (vals.get('hours',0.0), work.hours, work.task_id.id)) cr.execute('update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s', (vals.get('hours',0.0), work.hours, work.task_id.id))
return super(project_work,self).write(cr, uid, ids, vals, context) return super(project_work,self).write(cr, uid, ids, vals, context)

View File

@ -82,6 +82,8 @@ class project_task(osv.osv):
def import_cal(self, cr, uid, data, data_id=None, context=None): def import_cal(self, cr, uid, data, data_id=None, context=None):
if not context:
context = {}
todo_obj = self.pool.get('basic.calendar.todo') todo_obj = self.pool.get('basic.calendar.todo')
vals = todo_obj.import_cal(cr, uid, data, context=context) vals = todo_obj.import_cal(cr, uid, data, context=context)
return self.check_import(cr, uid, vals, context=context) return self.check_import(cr, uid, vals, context=context)
@ -91,7 +93,7 @@ class project_task(osv.osv):
context = {} context = {}
ids = [] ids = []
for val in vals: for val in vals:
obj_tm = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.project_time_mode_id obj_tm = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.project_time_mode_id
if not val.get('planned_hours', False): if not val.get('planned_hours', False):
# 'Computes duration' in days # 'Computes duration' in days
plan = 0.0 plan = 0.0

View File

@ -230,7 +230,9 @@ class project_issue(crm.crm_case, osv.osv):
}), }),
} }
def _get_project(self, cr, uid, context): def _get_project(self, cr, uid, context=None):
if not context:
context = {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user.context_project_id: if user.context_project_id:
return user.context_project_id.id return user.context_project_id.id
@ -300,6 +302,8 @@ class project_issue(crm.crm_case, osv.osv):
def _convert(self, cr, uid, ids, xml_id, context=None): def _convert(self, cr, uid, ids, xml_id, context=None):
if not context:
context = {}
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id) id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)
categ_id = False categ_id = False
@ -310,9 +314,13 @@ class project_issue(crm.crm_case, osv.osv):
return True return True
def convert_to_feature(self, cr, uid, ids, context=None): def convert_to_feature(self, cr, uid, ids, context=None):
if not context:
context = {}
return self._convert(cr, uid, ids, 'feature_request_categ', context=context) return self._convert(cr, uid, ids, 'feature_request_categ', context=context)
def convert_to_bug(self, cr, uid, ids, context=None): def convert_to_bug(self, cr, uid, ids, context=None):
if not context:
context = {}
return self._convert(cr, uid, ids, 'bug_categ', context=context) return self._convert(cr, uid, ids, 'bug_categ', context=context)
def next_type(self, cr, uid, ids, *args): def next_type(self, cr, uid, ids, *args):
@ -344,7 +352,7 @@ class project_issue(crm.crm_case, osv.osv):
result = {} result = {}
if not task_id: if not task_id:
return {'value':{}} return {'value':{}}
task = self.pool.get('project.task').browse(cr, uid, task_id, context) task = self.pool.get('project.task').browse(cr, uid, task_id, context=context)
return {'value':{'assigned_to': task.user_id.id,}} return {'value':{'assigned_to': task.user_id.id,}}
def case_escalate(self, cr, uid, ids, *args): def case_escalate(self, cr, uid, ids, *args):
@ -370,7 +378,7 @@ class project_issue(crm.crm_case, osv.osv):
self._history(cr, uid, cases, _('Escalate')) self._history(cr, uid, cases, _('Escalate'))
return True return True
def message_new(self, cr, uid, msg, context): def message_new(self, cr, uid, msg, context=None):
""" """
Automatically calls when new email message arrives Automatically calls when new email message arrives
@ -378,7 +386,8 @@ class project_issue(crm.crm_case, osv.osv):
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks @param uid: the current users ID for security checks
""" """
if not context:
context = {}
mailgate_pool = self.pool.get('email.server.tools') mailgate_pool = self.pool.get('email.server.tools')
subject = msg.get('subject') or _('No Title') subject = msg.get('subject') or _('No Title')
@ -400,7 +409,7 @@ class project_issue(crm.crm_case, osv.osv):
if res: if res:
vals.update(res) vals.update(res)
context.update({'state_to' : 'draft'}) context.update({'state_to' : 'draft'})
res = self.create(cr, uid, vals, context) res = self.create(cr, uid, vals, context=context)
self.convert_to_bug(cr, uid, [res], context=context) self.convert_to_bug(cr, uid, [res], context=context)
attachents = msg.get('attachments', []) attachents = msg.get('attachments', [])
@ -487,6 +496,8 @@ class project(osv.osv):
} }
def _check_escalation(self, cr, uid, ids, context=None): def _check_escalation(self, cr, uid, ids, context=None):
if not context:
context = {}
project_obj = self.browse(cr, uid, ids[0], context=context) project_obj = self.browse(cr, uid, ids[0], context=context)
if project_obj.project_escalation_id: if project_obj.project_escalation_id:
if project_obj.project_escalation_id.id == project_obj.id: if project_obj.project_escalation_id.id == project_obj.id:

View File

@ -70,18 +70,24 @@ class project_phase(osv.osv):
return True return True
def _check_dates(self, cr, uid, ids, context=None): def _check_dates(self, cr, uid, ids, context=None):
if not context:
context = {}
for phase in self.read(cr, uid, ids, ['date_start', 'date_end'], context=context): for phase in self.read(cr, uid, ids, ['date_start', 'date_end'], context=context):
if phase['date_start'] and phase['date_end'] and phase['date_start'] > phase['date_end']: if phase['date_start'] and phase['date_end'] and phase['date_start'] > phase['date_end']:
return False return False
return True return True
def _check_constraint_start(self, cr, uid, ids, context=None): def _check_constraint_start(self, cr, uid, ids, context=None):
if not context:
context = {}
phase = self.read(cr, uid, ids[0], ['date_start', 'constraint_date_start'], context=context) phase = self.read(cr, uid, ids[0], ['date_start', 'constraint_date_start'], context=context)
if phase['date_start'] and phase['constraint_date_start'] and phase['date_start'] < phase['constraint_date_start']: if phase['date_start'] and phase['constraint_date_start'] and phase['date_start'] < phase['constraint_date_start']:
return False return False
return True return True
def _check_constraint_end(self, cr, uid, ids, context=None): def _check_constraint_end(self, cr, uid, ids, context=None):
if not context:
context = {}
phase = self.read(cr, uid, ids[0], ['date_end', 'constraint_date_end'], context=context) phase = self.read(cr, uid, ids[0], ['date_end', 'constraint_date_end'], context=context)
if phase['date_end'] and phase['constraint_date_end'] and phase['date_end'] > phase['constraint_date_end']: if phase['date_end'] and phase['constraint_date_end'] and phase['date_end'] > phase['constraint_date_end']:
return False return False
@ -96,6 +102,8 @@ class project_phase(osv.osv):
res = {} res = {}
if not ids: if not ids:
return res return res
if not context:
context = {}
for phase in self.browse(cr, uid, ids, context=context): for phase in self.browse(cr, uid, ids, context=context):
tot = 0.0 tot = 0.0
for task in phase.task_ids: for task in phase.task_ids:
@ -137,6 +145,8 @@ class project_phase(osv.osv):
def onchange_project(self, cr, uid, ids, project, context=None): def onchange_project(self, cr, uid, ids, project, context=None):
result = {} result = {}
if not context:
context = {}
result['date_start'] = False result['date_start'] = False
project_obj = self.pool.get('project.project') project_obj = self.pool.get('project.project')
if project: if project:
@ -146,6 +156,8 @@ class project_phase(osv.osv):
def onchange_days(self, cr, uid, ids, project, context=None): def onchange_days(self, cr, uid, ids, project, context=None):
result = {} result = {}
if not context:
context = {}
for id in ids: for id in ids:
project_id = self.browse(cr, uid, id, context=context) project_id = self.browse(cr, uid, id, context=context)
newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0) newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0)
@ -398,6 +410,8 @@ class project_resource_allocation(osv.osv):
def get_name(self, cr, uid, ids, field_name, arg, context=None): def get_name(self, cr, uid, ids, field_name, arg, context=None):
res = {} res = {}
if not context:
context = {}
for allocation in self.browse(cr, uid, ids, context=context): for allocation in self.browse(cr, uid, ids, context=context):
name = allocation.phase_id.name name = allocation.phase_id.name
name += ' (%s%%)' %(allocation.useability) name += ' (%s%%)' %(allocation.useability)
@ -507,7 +521,7 @@ class resource_resource(osv.osv):
context = {} context = {}
if context.get('project_id',False): if context.get('project_id',False):
project_pool = self.pool.get('project.project') project_pool = self.pool.get('project.project')
project_rec = project_pool.browse(cr, uid, context['project_id']) project_rec = project_pool.browse(cr, uid, context['project_id'], context=context)
user_ids = [user_id.id for user_id in project_rec.members] user_ids = [user_id.id for user_id in project_rec.members]
args.append(('user_id','in',user_ids)) args.append(('user_id','in',user_ids))
return super(resource_resource, self).search(cr, uid, args, offset, limit, order, context, count) return super(resource_resource, self).search(cr, uid, args, offset, limit, order, context, count)

View File

@ -37,6 +37,8 @@ class project_compute_phases(osv.osv_memory):
} }
def check_selection(self, cr, uid, ids, context=None): def check_selection(self, cr, uid, ids, context=None):
if not context:
context = {}
return self.compute_date(cr, uid, ids, context=context) return self.compute_date(cr, uid, ids, context=context)

View File

@ -38,6 +38,8 @@ class project_tasks(osv.osv):
# @param cr: the current row, from the database cursor, # @param cr: the current row, from the database cursor,
# @param uid: the current users ID for security checks # @param uid: the current users ID for security checks
# """ # """
if not context:
context = {}
mailgate_obj = self.pool.get('email.server.tools') mailgate_obj = self.pool.get('email.server.tools')
subject = msg.get('subject') subject = msg.get('subject')
body = msg.get('body') body = msg.get('body')
@ -95,11 +97,13 @@ class project_tasks(osv.osv):
def message_followers(self, cr, uid, ids, context=None): def message_followers(self, cr, uid, ids, context=None):
res = [] res = []
if not context:
context = {}
if isinstance(ids, (str, int, long)): if isinstance(ids, (str, int, long)):
select = [ids] select = [ids]
else: else:
select = ids select = ids
for task in self.browse(cr, uid, select): for task in self.browse(cr, uid, select, context=context):
user_email = (task.user_id and task.user_id.address_id and task.user_id.address_id.email) or False user_email = (task.user_id and task.user_id.address_id and task.user_id.address_id.email) or False
res += [(user_email, False, False, task.priority)] res += [(user_email, False, False, task.priority)]
if isinstance(ids, (str, int, long)): if isinstance(ids, (str, int, long)):

View File

@ -41,6 +41,8 @@ class messages(osv.osv):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
# return messages by current user, for current user or for all users # return messages by current user, for current user or for all users
# return all messages if current user is administrator # return all messages if current user is administrator
if not context:
context = {}
if uid != 1: if uid != 1:
args.extend(['|',('from_id', 'in', [uid,]),('to_id', 'in', [uid, False])]) args.extend(['|',('from_id', 'in', [uid,]),('to_id', 'in', [uid, False])])
return super(messages, self).search(cr, uid, args, offset, limit, return super(messages, self).search(cr, uid, args, offset, limit,

View File

@ -29,13 +29,15 @@ class procurement_order(osv.osv):
_columns = { _columns = {
'task_id': fields.many2one('project.task', 'Task') 'task_id': fields.many2one('project.task', 'Task')
} }
def check_produce_service(self, cr, uid, procurement, context=[]): def check_produce_service(self, cr, uid, procurement, context=None):
if not context:
context = {}
return True return True
def action_produce_assign_service(self, cr, uid, ids, context=None): def action_produce_assign_service(self, cr, uid, ids, context=None):
if context is None: if context is None:
context = {} context = {}
for procurement in self.browse(cr, uid, ids): for procurement in self.browse(cr, uid, ids, context=context):
self.write(cr, uid, [procurement.id], {'state': 'running'}) self.write(cr, uid, [procurement.id], {'state': 'running'})
planned_hours = procurement.product_qty planned_hours = procurement.product_qty
task_id = self.pool.get('project.task').create(cr, uid, { task_id = self.pool.get('project.task').create(cr, uid, {

View File

@ -82,7 +82,9 @@ class report_account_analytic_planning(osv.osv):
def _get_total_planned(self, cr, uid, ids, name, args, context=None): def _get_total_planned(self, cr, uid, ids, name, args, context=None):
result = {} result = {}
for plan in self.browse(cr, uid, ids, context): if not context:
context = {}
for plan in self.browse(cr, uid, ids, context=context):
plan_hrs=0.0 plan_hrs=0.0
for p in plan.planning_user_ids: for p in plan.planning_user_ids:
if not p.plan_open : p.plan_open = 0.0 if not p.plan_open : p.plan_open = 0.0
@ -93,7 +95,9 @@ class report_account_analytic_planning(osv.osv):
def _get_total_free(self, cr, uid, ids, name, args, context=None): def _get_total_free(self, cr, uid, ids, name, args, context=None):
result = {} result = {}
for plan in self.browse(cr, uid, ids, context): if not context:
context = {}
for plan in self.browse(cr, uid, ids, context=context):
total_free = 0.0 total_free = 0.0
for p in plan.planning_user_ids: for p in plan.planning_user_ids:
if p.free: if p.free:
@ -186,7 +190,7 @@ class report_account_analytic_planning_line(osv.osv):
context = {} context = {}
if not len(ids): if not len(ids):
return [] return []
reads = self.read(cr, uid, ids, ['user_id', 'planning_id', 'note'], context) reads = self.read(cr, uid, ids, ['user_id', 'planning_id', 'note'], context=context)
res = [] res = []
for record in reads: for record in reads:
name = '['+record['planning_id'][1] name = '['+record['planning_id'][1]

View File

@ -352,7 +352,7 @@ class project_scrum_meeting(osv.osv):
if context is None: if context is None:
context = {} context = {}
email_from = tools.config.get('email_from', False) email_from = tools.config.get('email_from', False)
meeting_id = self.browse(cr,uid,ids)[0] meeting_id = self.browse(cr, uid, ids, context=context)[0]
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
user_email = email_from or user.address_id.email or email_from user_email = email_from or user.address_id.email or email_from
body = _('Hello ') + meeting_id.sprint_id.scrum_master_id.name + ",\n" + " \n" +_('I am sending you Daily Meeting Details of date')+ ' %s ' % (meeting_id.date)+ _('for the Sprint')+ ' %s\n' % (meeting_id.sprint_id.name) body = _('Hello ') + meeting_id.sprint_id.scrum_master_id.name + ",\n" + " \n" +_('I am sending you Daily Meeting Details of date')+ ' %s ' % (meeting_id.date)+ _('for the Sprint')+ ' %s\n' % (meeting_id.sprint_id.name)

View File

@ -38,6 +38,8 @@ class project_scrum_email(osv.osv_memory):
@return : default values of fields. @return : default values of fields.
""" """
if not context:
context = {}
meeting_pool = self.pool.get('project.scrum.meeting') meeting_pool = self.pool.get('project.scrum.meeting')
record_ids = context and context.get('active_ids', []) or [] record_ids = context and context.get('active_ids', []) or []
res = super(project_scrum_email, self).default_get(cr, uid, fields, context=context) res = super(project_scrum_email, self).default_get(cr, uid, fields, context=context)
@ -65,7 +67,7 @@ class project_scrum_email(osv.osv_memory):
def button_send_scrum_email(self, cr, uid, ids, context=None): def button_send_scrum_email(self, cr, uid, ids, context=None):
if context is None: if context is None:
context={} context = {}
active_id = context.get('active_id', False) active_id = context.get('active_id', False)
scrum_meeting_pool = self.pool.get('project.scrum.meeting') scrum_meeting_pool = self.pool.get('project.scrum.meeting')

View File

@ -201,9 +201,9 @@ class task(osv.osv):
if vals.get('project_id',False) or vals.get('name',False): if vals.get('project_id',False) or vals.get('name',False):
vals_line = {} vals_line = {}
hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet')
task_obj_l = self.browse(cr, uid, ids, context) task_obj_l = self.browse(cr, uid, ids, context=context)
if vals.get('project_id',False): if vals.get('project_id',False):
project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id'], context=context)
acc_id = project_obj.analytic_account_id.id acc_id = project_obj.analytic_account_id.id
for task_obj in task_obj_l: for task_obj in task_obj_l:

View File

@ -237,6 +237,8 @@ class purchase_order(osv.osv):
_order = "name desc" _order = "name desc"
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
if not context:
context = {}
purchase_orders = self.read(cr, uid, ids, ['state']) purchase_orders = self.read(cr, uid, ids, ['state'])
unlink_ids = [] unlink_ids = []
for s in purchase_orders: for s in purchase_orders:
@ -604,8 +606,10 @@ class purchase_order(osv.osv):
purchase_order() purchase_order()
class purchase_order_line(osv.osv): class purchase_order_line(osv.osv):
def _amount_line(self, cr, uid, ids, prop, arg,context): def _amount_line(self, cr, uid, ids, prop, arg, context=None):
res = {} res = {}
if not context:
context = {}
cur_obj=self.pool.get('res.currency') cur_obj=self.pool.get('res.currency')
tax_obj = self.pool.get('account.tax') tax_obj = self.pool.get('account.tax')
for line in self.browse(cr, uid, ids, context=context): for line in self.browse(cr, uid, ids, context=context):
@ -649,9 +653,11 @@ class purchase_order_line(osv.osv):
_name = 'purchase.order.line' _name = 'purchase.order.line'
_description = 'Purchase Order Line' _description = 'Purchase Order Line'
def copy_data(self, cr, uid, id, default=None,context=None): def copy_data(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
default.update({'state':'draft', 'move_ids':[],'invoiced':0,'invoice_lines':[]}) default.update({'state':'draft', 'move_ids':[],'invoiced':0,'invoice_lines':[]})
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context) return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
@ -729,6 +735,8 @@ class purchase_order_line(osv.osv):
return res return res
def action_confirm(self, cr, uid, ids, context=None): def action_confirm(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'confirmed'}, context=context) self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)
return True return True
@ -744,6 +752,8 @@ class procurement_order(osv.osv):
""" This is action which call from workflow to assign purchase order to procurements """ This is action which call from workflow to assign purchase order to procurements
@return: True @return: True
""" """
if not context:
context = {}
res = self.make_po(cr, uid, ids, context=context) res = self.make_po(cr, uid, ids, context=context)
res = res.values() res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
@ -753,6 +763,8 @@ class procurement_order(osv.osv):
@return: New created Purchase Orders procurement wise @return: New created Purchase Orders procurement wise
""" """
res = {} res = {}
if not context:
context = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
partner_obj = self.pool.get('res.partner') partner_obj = self.pool.get('res.partner')
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
@ -760,7 +772,7 @@ class procurement_order(osv.osv):
prod_obj = self.pool.get('product.product') prod_obj = self.pool.get('product.product')
acc_pos_obj = self.pool.get('account.fiscal.position') acc_pos_obj = self.pool.get('account.fiscal.position')
po_obj = self.pool.get('purchase.order') po_obj = self.pool.get('purchase.order')
for procurement in self.browse(cr, uid, ids): for procurement in self.browse(cr, uid, ids, context=context):
res_id = procurement.move_id.id res_id = procurement.move_id.id
partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement. partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement.
seller_qty = procurement.product_id.seller_qty seller_qty = procurement.product_id.seller_qty

View File

@ -35,6 +35,8 @@ class stock_move(osv.osv):
on the purchase order in case the valuation data was not directly specified during picking on the purchase order in case the valuation data was not directly specified during picking
confirmation. confirmation.
""" """
if not context:
context = {}
reference_amount, reference_currency_id = super(stock_move, self)._get_reference_accounting_values_for_valuation(cr, uid, move, context=context) reference_amount, reference_currency_id = super(stock_move, self)._get_reference_accounting_values_for_valuation(cr, uid, move, context=context)
if move.product_id.cost_method != 'average' or not move.price_unit: if move.product_id.cost_method != 'average' or not move.price_unit:
# no average price costing or cost not specified during picking validation, we will # no average price costing or cost not specified during picking validation, we will
@ -118,9 +120,11 @@ class stock_partial_picking(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context) res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])): for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context=context):
has_product_cost = (pick.type == 'in' and pick.purchase_id) has_product_cost = (pick.type == 'in' and pick.purchase_id)
for m in pick.move_lines: for m in pick.move_lines:
if has_product_cost and m.product_id.cost_method == 'average' and m.purchase_line_id: if has_product_cost and m.product_id.cost_method == 'average' and m.purchase_line_id:
@ -142,9 +146,11 @@ class stock_partial_move(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
res = super(stock_partial_move, self).default_get(cr, uid, fields, context=context) res = super(stock_partial_move, self).default_get(cr, uid, fields, context=context)
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
for m in move_obj.browse(cr, uid, context.get('active_ids', [])): for m in move_obj.browse(cr, uid, context.get('active_ids', []), context=context):
if m.picking_id.type == 'in' and m.product_id.cost_method == 'average' \ if m.picking_id.type == 'in' and m.product_id.cost_method == 'average' \
and m.purchase_line_id and m.picking_id.purchase_id: and m.purchase_line_id and m.picking_id.purchase_id:
# We use the original PO unit purchase price as the basis for the cost, expressed # We use the original PO unit purchase price as the basis for the cost, expressed

View File

@ -47,7 +47,7 @@ class purchase_order_group(osv.osv_memory):
raise osv.except_osv(_('Warning'), raise osv.except_osv(_('Warning'),
_('Please select multiple order to merge in the list view.')) _('Please select multiple order to merge in the list view.'))
return res return res
def merge_orders(self, cr, uid, ids, context): def merge_orders(self, cr, uid, ids, context=None):
""" """
To merge similar type of purchase orders. To merge similar type of purchase orders.
@ -62,6 +62,8 @@ class purchase_order_group(osv.osv_memory):
""" """
order_obj = self.pool.get('purchase.order') order_obj = self.pool.get('purchase.order')
mod_obj =self.pool.get('ir.model.data') mod_obj =self.pool.get('ir.model.data')
if not context:
context = {}
result = mod_obj._get_id(cr, uid, 'purchase', 'view_purchase_order_filter') result = mod_obj._get_id(cr, uid, 'purchase', 'view_purchase_order_filter')
id = mod_obj.read(cr, uid, result, ['res_id']) id = mod_obj.read(cr, uid, result, ['res_id'])

View File

@ -52,9 +52,11 @@ class purchase_requisition(osv.osv):
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.requisition'), 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.requisition'),
} }
def copy(self, cr, uid, id, default=None,context={}): def copy(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context:
context = {}
default.update({ default.update({
'state':'draft', 'state':'draft',
'purchase_ids':[], 'purchase_ids':[],
@ -63,7 +65,9 @@ class purchase_requisition(osv.osv):
return super(purchase_requisition, self).copy(cr, uid, id, default, context) return super(purchase_requisition, self).copy(cr, uid, id, default, context)
def tender_cancel(self, cr, uid, ids, context=None): def tender_cancel(self, cr, uid, ids, context=None):
purchase_order_obj = self.pool.get('purchase.order') purchase_order_obj = self.pool.get('purchase.order')
for purchase in self.browse(cr, uid, ids): if not context:
context = {}
for purchase in self.browse(cr, uid, ids, context=context):
for purchase_id in purchase.purchase_ids: for purchase_id in purchase.purchase_ids:
if str(purchase_id.state) in('draft','wait'): if str(purchase_id.state) in('draft','wait'):
purchase_order_obj.action_cancel(cr,uid,[purchase_id.id]) purchase_order_obj.action_cancel(cr,uid,[purchase_id.id])
@ -71,14 +75,20 @@ class purchase_requisition(osv.osv):
return True return True
def tender_in_progress(self, cr, uid, ids, context=None): def tender_in_progress(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state':'in_progress'} ,context=context) self.write(cr, uid, ids, {'state':'in_progress'} ,context=context)
return True return True
def tender_reset(self, cr, uid, ids, context=None): def tender_reset(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'draft'}) self.write(cr, uid, ids, {'state': 'draft'})
return True return True
def tender_done(self, cr, uid, ids, context=None): def tender_done(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context) self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
return True return True
@ -106,8 +116,10 @@ class purchase_requisition_line(osv.osv):
@return: Dictionary of changed values @return: Dictionary of changed values
""" """
value = {'product_uom_id': ''} value = {'product_uom_id': ''}
if not context:
context = {}
if product_id: if product_id:
prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] prod = self.pool.get('product.product').browse(cr, uid, [product_id], context=context)[0]
value = {'product_uom_id': prod.uom_id.id,'product_qty':1.0} value = {'product_uom_id': prod.uom_id.id,'product_qty':1.0}
return {'value': value} return {'value': value}
@ -121,10 +133,12 @@ class purchase_order(osv.osv):
_columns = { _columns = {
'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition') 'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition')
} }
def wkf_confirm_order(self, cr, uid, ids, context={}): def wkf_confirm_order(self, cr, uid, ids, context=None):
res = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context) if not context:
context = {}
res = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context=context)
proc_obj=self.pool.get('procurement.order') proc_obj=self.pool.get('procurement.order')
for po in self.browse(cr, uid, ids, context): for po in self.browse(cr, uid, ids, context=context):
if po.requisition_id and (po.requisition_id.exclusive=='exclusive'): if po.requisition_id and (po.requisition_id.exclusive=='exclusive'):
for order in po.requisition_id.purchase_ids: for order in po.requisition_id.purchase_ids:
if order.id<>po.id: if order.id<>po.id:
@ -158,9 +172,11 @@ class procurement_order(osv.osv):
} }
def make_po(self, cr, uid, ids, context=None): def make_po(self, cr, uid, ids, context=None):
sequence_obj = self.pool.get('ir.sequence') sequence_obj = self.pool.get('ir.sequence')
if not context:
context = {}
res = super(procurement_order, self).make_po(cr, uid, ids, context=context) res = super(procurement_order, self).make_po(cr, uid, ids, context=context)
for proc_id, po_id in res.items(): for proc_id, po_id in res.items():
procurement = self.browse(cr, uid, proc_id) procurement = self.browse(cr, uid, proc_id, context=context)
requisition_id=False requisition_id=False
if procurement.product_id.purchase_requisition: if procurement.product_id.purchase_requisition:
requisition_id=self.pool.get('purchase.requisition').create(cr, uid, { requisition_id=self.pool.get('purchase.requisition').create(cr, uid, {

View File

@ -34,9 +34,11 @@ class purchase_requisition_partner(osv.osv_memory):
} }
def view_init(self, cr, uid, fields_list, context=None): def view_init(self, cr, uid, fields_list, context=None):
if not context:
context = {}
res = super(purchase_requisition_partner, self).view_init(cr, uid, fields_list, context=context) res = super(purchase_requisition_partner, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
tender = self.pool.get('purchase.requisition').browse(cr, uid, record_id) tender = self.pool.get('purchase.requisition').browse(cr, uid, record_id, context=context)
if not tender.line_ids: if not tender.line_ids:
raise osv.except_osv('Error!','No Product in Tender') raise osv.except_osv('Error!','No Product in Tender')
True True
@ -48,7 +50,7 @@ class purchase_requisition_partner(osv.osv_memory):
part = self.pool.get('res.partner').browse(cr, uid, partner_id) part = self.pool.get('res.partner').browse(cr, uid, partner_id)
return {'value':{'partner_address_id': addr['default']}} return {'value':{'partner_address_id': addr['default']}}
def create_order(self, cr, uid, ids, context): def create_order(self, cr, uid, ids, context=None):
""" """
To Create a purchase orders . To Create a purchase orders .
@ -60,6 +62,8 @@ class purchase_requisition_partner(osv.osv_memory):
@return: {} @return: {}
""" """
if not context:
context = {}
record_ids = context and context.get('active_ids', False) record_ids = context and context.get('active_ids', False)
if record_ids: if record_ids:
data = self.read(cr, uid, ids) data = self.read(cr, uid, ids)
@ -74,12 +78,12 @@ class purchase_requisition_partner(osv.osv_memory):
acc_pos_obj = self.pool.get('account.fiscal.position') acc_pos_obj = self.pool.get('account.fiscal.position')
partner_id = data[0]['partner_id'] partner_id = data[0]['partner_id']
supplier_data = partner_obj.browse(cr, uid,[ partner_id])[0] supplier_data = partner_obj.browse(cr, uid,[ partner_id], context=context)[0]
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
list_line=[] list_line=[]
purchase_order_line={} purchase_order_line={}
for tender in tender_obj.browse(cr, uid, record_ids): for tender in tender_obj.browse(cr, uid, record_ids, context=context):
for line in tender.line_ids: for line in tender.line_ids:
partner_list = sorted([(partner.sequence, partner) for partner in line.product_id.seller_ids if partner]) partner_list = sorted([(partner.sequence, partner) for partner in line.product_id.seller_ids if partner])
partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False

View File

@ -59,6 +59,8 @@ class ReportXML(osv.osv):
def unlink(self, cursor, user, ids, context=None): def unlink(self, cursor, user, ids, context=None):
"""Delete report and unregister it""" """Delete report and unregister it"""
if not context:
context = {}
trans_obj = self.pool.get('ir.translation') trans_obj = self.pool.get('ir.translation')
trans_ids = trans_obj.search( trans_ids = trans_obj.search(
cursor, cursor,
@ -81,6 +83,8 @@ class ReportXML(osv.osv):
def create(self, cursor, user, vals, context=None): def create(self, cursor, user, vals, context=None):
"Create report and register it" "Create report and register it"
if not context:
context = {}
res = super(ReportXML, self).create(cursor, user, vals, context) res = super(ReportXML, self).create(cursor, user, vals, context)
if vals.get('report_type','') == 'webkit': if vals.get('report_type','') == 'webkit':
# I really look forward to virtual functions :S # I really look forward to virtual functions :S
@ -95,6 +99,8 @@ class ReportXML(osv.osv):
"Edit report and manage it registration" "Edit report and manage it registration"
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids,] ids = [ids,]
if not context:
context = {}
for rep in self.browse(cr, uid, ids, context=context): for rep in self.browse(cr, uid, ids, context=context):
if rep.report_type != 'webkit': if rep.report_type != 'webkit':
continue continue

View File

@ -320,6 +320,8 @@ class WebKitParser(report_sxw):
def create(self, cursor, uid, ids, data, context=None): def create(self, cursor, uid, ids, data, context=None):
"""We override the create function in order to handle generator """We override the create function in order to handle generator
Code taken from report openoffice. Thanks guys :) """ Code taken from report openoffice. Thanks guys :) """
if not context:
context = {}
pool = pooler.get_pool(cursor.dbname) pool = pooler.get_pool(cursor.dbname)
ir_obj = pool.get('ir.actions.report.xml') ir_obj = pool.get('ir.actions.report.xml')
report_xml_ids = ir_obj.search(cursor, uid, report_xml_ids = ir_obj.search(cursor, uid,

View File

@ -242,6 +242,8 @@ class resource_resource(osv.osv):
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if default is None: if default is None:
default = {} default = {}
if not context:
context = {}
if not default.get('name', False): if not default.get('name', False):
default['name'] = self.browse(cr, uid, id, context=context).name + _(' (copy)') default['name'] = self.browse(cr, uid, id, context=context).name + _(' (copy)')
return super(resource_resource, self).copy(cr, uid, id, default, context) return super(resource_resource, self).copy(cr, uid, id, default, context)
@ -364,7 +366,9 @@ class resource_calendar_leaves(osv.osv):
'resource_id' : fields.many2one("resource.resource", "Resource", help="If empty, this is a generic holiday for the company. If a resource is set, the holiday/leave is only for this resource"), 'resource_id' : fields.many2one("resource.resource", "Resource", help="If empty, this is a generic holiday for the company. If a resource is set, the holiday/leave is only for this resource"),
} }
def check_dates(self, cr, uid, ids, context={}): def check_dates(self, cr, uid, ids, context=None):
if not context:
context = {}
leave = self.read(cr, uid, ids[0], ['date_from', 'date_to']) leave = self.read(cr, uid, ids[0], ['date_from', 'date_to'])
if leave['date_from'] and leave['date_to']: if leave['date_from'] and leave['date_to']:
if leave['date_from'] > leave['date_to']: if leave['date_from'] > leave['date_to']:
@ -377,9 +381,11 @@ class resource_calendar_leaves(osv.osv):
def onchange_resource(self,cr, uid, ids, resource, context=None): def onchange_resource(self,cr, uid, ids, resource, context=None):
result = {} result = {}
if not context:
context = {}
if resource: if resource:
resource_pool = self.pool.get('resource.resource') resource_pool = self.pool.get('resource.resource')
result['calendar_id'] = resource_pool.browse(cr, uid, resource).calendar_id.id result['calendar_id'] = resource_pool.browse(cr, uid, resource, context=context).calendar_id.id
return {'value': result} return {'value': result}
return {'value': {'calendar_id': []}} return {'value': {'calendar_id': []}}

View File

@ -33,8 +33,8 @@ class product_product(osv.osv):
pricelist_ids = pricelist_obj.search(cr, uid, [('type', '=', 'purchase')]) pricelist_ids = pricelist_obj.search(cr, uid, [('type', '=', 'purchase')])
else: else:
pricelist_ids = pricelist_obj.search(cr, uid, [('type', '=', 'sale')]) pricelist_ids = pricelist_obj.search(cr, uid, [('type', '=', 'sale')])
pricelist_browse = pricelist_obj.browse(cr, uid, pricelist_ids) pricelist_browse = pricelist_obj.browse(cr, uid, pricelist_ids, context=context)
for product in self.browse(cr, uid, ids, context): for product in self.browse(cr, uid, ids, context=context):
result[product.id] = "" result[product.id] = ""
for pricelist in pricelist_browse: for pricelist in pricelist_browse:
for version in pricelist.version_id: for version in pricelist.version_id:

View File

@ -28,6 +28,8 @@ class stock_move(osv.osv):
} }
def _create_chained_picking(self, cr, uid, pick_name, picking, ptype, move, context=None): def _create_chained_picking(self, cr, uid, pick_name, picking, ptype, move, context=None):
if not context:
context = {}
res = super(stock_move, self)._create_chained_picking(cr, uid, pick_name, picking, ptype, move, context=context) res = super(stock_move, self)._create_chained_picking(cr, uid, pick_name, picking, ptype, move, context=context)
if picking.sale_id: if picking.sale_id:
self.pool.get('stock.picking').write(cr, uid, [res], {'sale_id': picking.sale_id.id}) self.pool.get('stock.picking').write(cr, uid, [res], {'sale_id': picking.sale_id.id})
@ -181,9 +183,11 @@ class stock_picking(osv.osv):
}) })
return result return result
def action_cancel(self, cr, uid, ids, context={}): def action_cancel(self, cr, uid, ids, context=None):
if not context:
context = {}
res = super(stock_picking, self).action_cancel(cr, uid, ids, context=context) res = super(stock_picking, self).action_cancel(cr, uid, ids, context=context)
for pick in self.browse(cr, uid, ids, context): for pick in self.browse(cr, uid, ids, context=context):
call_ship_end = True call_ship_end = True
if pick.sale_id: if pick.sale_id:
for picks in pick.sale_id.picking_ids: for picks in pick.sale_id.picking_ids:
@ -191,7 +195,7 @@ class stock_picking(osv.osv):
call_ship_end = False call_ship_end = False
break break
if call_ship_end: if call_ship_end:
self.pool.get('sale.order').action_ship_end(cr, uid, [pick.sale_id.id], context) self.pool.get('sale.order').action_ship_end(cr, uid, [pick.sale_id.id], context=context)
return res return res
stock_picking() stock_picking()

View File

@ -26,7 +26,7 @@ import netsvc
class sale_order_line_make_invoice(osv.osv_memory): class sale_order_line_make_invoice(osv.osv_memory):
_name = "sale.order.line.make.invoice" _name = "sale.order.line.make.invoice"
_description = "Sale OrderLine Make_invoice" _description = "Sale OrderLine Make_invoice"
def make_invoices(self, cr, uid, ids, context): def make_invoices(self, cr, uid, ids, context=None):
""" """
To make invoices. To make invoices.
@ -80,7 +80,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
sales_order_line_obj = self.pool.get('sale.order.line') sales_order_line_obj = self.pool.get('sale.order.line')
sales_order_obj = self.pool.get('sale.order') sales_order_obj = self.pool.get('sale.order')
wf_service = netsvc.LocalService('workflow') wf_service = netsvc.LocalService('workflow')
for line in sales_order_line_obj.browse(cr, uid, context['active_ids']): for line in sales_order_line_obj.browse(cr, uid, context.get('active_ids', []), context=context):
if (not line.invoiced) and (line.state not in ('draft', 'cancel')): if (not line.invoiced) and (line.state not in ('draft', 'cancel')):
if not line.order_id.id in invoices: if not line.order_id.id in invoices:
invoices[line.order_id.id] = [] invoices[line.order_id.id] = []
@ -98,7 +98,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
(order_id,invoice_id) values (%s,%s)', (order.id, res)) (order_id,invoice_id) values (%s,%s)', (order.id, res))
flag = True flag = True
data_sale = sales_order_obj.browse(cr, uid, line.order_id.id) data_sale = sales_order_obj.browse(cr, uid, line.order_id.id, context=context)
for line in data_sale.order_line: for line in data_sale.order_line:
if not line.invoiced: if not line.invoiced:
flag = False flag = False

View File

@ -37,22 +37,24 @@ class sale_make_invoice(osv.osv_memory):
if context is None: if context is None:
context = {} context = {}
record_id = context and context.get('active_id', False) record_id = context and context.get('active_id', False)
order = self.pool.get('sale.order').browse(cr, uid, record_id) order = self.pool.get('sale.order').browse(cr, uid, record_id, context=context)
if order.state == 'draft': if order.state == 'draft':
raise osv.except_osv(_('Warning !'),'You can not create invoice when sale order is not confirmed.') raise osv.except_osv(_('Warning !'),'You can not create invoice when sale order is not confirmed.')
return False return False
def make_invoices(self, cr, uid, ids, context={}): def make_invoices(self, cr, uid, ids, context=None):
order_obj = self.pool.get('sale.order') order_obj = self.pool.get('sale.order')
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
newinv = [] newinv = []
if not context:
context = {}
data = self.read(cr, uid, ids)[0] data = self.read(cr, uid, ids)[0]
order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_inv = data['invoice_date']) order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_inv = data['invoice_date'])
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
for id in context.get(('active_ids'), []): for id in context.get(('active_ids'), []):
wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context): for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context):
for i in o.invoice_ids: for i in o.invoice_ids:
newinv.append(i.id) newinv.append(i.id)

View File

@ -34,7 +34,7 @@ class sale_advance_payment_inv(osv.osv_memory):
'qtty': 1.0 'qtty': 1.0
} }
def create_invoices(self, cr, uid, ids, context={}): def create_invoices(self, cr, uid, ids, context=None):
""" """
To create invoices. To create invoices.
@ -51,9 +51,11 @@ class sale_advance_payment_inv(osv.osv_memory):
obj_sale = self.pool.get('sale.order') obj_sale = self.pool.get('sale.order')
obj_lines = self.pool.get('account.invoice.line') obj_lines = self.pool.get('account.invoice.line')
inv_obj = self.pool.get('account.invoice') inv_obj = self.pool.get('account.invoice')
if not context:
context = {}
for sale_adv_obj in self.browse(cr, uid, ids): for sale_adv_obj in self.browse(cr, uid, ids, context=context):
for sale in obj_sale.browse(cr, uid, context['active_ids']): for sale in obj_sale.browse(cr, uid, context.get('active_ids', []), context=context):
create_ids = [] create_ids = []
ids_inv = [] ids_inv = []
if sale.order_policy == 'postpaid': if sale.order_policy == 'postpaid':
@ -151,7 +153,7 @@ class sale_open_invoice(osv.osv_memory):
if context is None: if context is None:
context = {} context = {}
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
for advance_pay in self.browse(cr, uid, ids): for advance_pay in self.browse(cr, uid, ids, context=context):
form_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form') form_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
form_id = form_res and form_res[1] or False form_id = form_res and form_res[1] or False
tree_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree') tree_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree')

View File

@ -33,10 +33,12 @@ class sale_order_line(osv.osv):
return super(sale_order_line, self)._amount_line(cr, uid, ids, field_name, arg, context) return super(sale_order_line, self)._amount_line(cr, uid, ids, field_name, arg, context)
return res return res
def invoice_line_create(self, cr, uid, ids, context={}): def invoice_line_create(self, cr, uid, ids, context=None):
new_ids = [] new_ids = []
list_seq = [] list_seq = []
for line in self.browse(cr, uid, ids, context): if not context:
context = {}
for line in self.browse(cr, uid, ids, context=context):
if line.layout_type == 'article': if line.layout_type == 'article':
new_ids.append(line.id) new_ids.append(line.id)
list_seq.append(line.sequence) list_seq.append(line.sequence)
@ -78,6 +80,8 @@ class sale_order_line(osv.osv):
return {} return {}
def create(self, cr, user, vals, context=None): def create(self, cr, user, vals, context=None):
if not context:
context = {}
if vals.has_key('layout_type'): if vals.has_key('layout_type'):
if vals['layout_type'] == 'line': if vals['layout_type'] == 'line':
vals['name'] = ' ' vals['name'] = ' '
@ -88,6 +92,8 @@ class sale_order_line(osv.osv):
return super(sale_order_line, self).create(cr, user, vals, context) return super(sale_order_line, self).create(cr, user, vals, context)
def write(self, cr, user, ids, vals, context=None): def write(self, cr, user, ids, vals, context=None):
if not context:
context = {}
if vals.has_key('layout_type'): if vals.has_key('layout_type'):
if vals['layout_type'] == 'line': if vals['layout_type'] == 'line':
vals['name'] = ' ' vals['name'] = ' '
@ -96,9 +102,11 @@ class sale_order_line(osv.osv):
return super(sale_order_line, self).write(cr, user, ids, vals, context) return super(sale_order_line, self).write(cr, user, ids, vals, context)
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if not context:
context = {}
if default is None: if default is None:
default = {} default = {}
default['layout_type'] = self.browse(cr, uid, id).layout_type default['layout_type'] = self.browse(cr, uid, id, context=context).layout_type
return super(sale_order_line, self).copy(cr, uid, id, default, context) return super(sale_order_line, self).copy(cr, uid, id, default, context)
_order = "order_id, sequence asc" _order = "order_id, sequence asc"

View File

@ -36,7 +36,9 @@ class sale_order_line(osv.osv):
def _product_margin(self, cr, uid, ids, field_name, arg, context=None): def _product_margin(self, cr, uid, ids, field_name, arg, context=None):
res = {} res = {}
for line in self.browse(cr, uid, ids): if not context:
context = {}
for line in self.browse(cr, uid, ids, context=context):
res[line.id] = 0 res[line.id] = 0
if line.product_id: if line.product_id:
if line.purchase_price: if line.purchase_price:
@ -57,6 +59,8 @@ class sale_order(osv.osv):
def _product_margin(self, cr, uid, ids, field_name, arg, context=None): def _product_margin(self, cr, uid, ids, field_name, arg, context=None):
result = {} result = {}
if not context:
context = {}
for sale in self.browse(cr, uid, ids, context=context): for sale in self.browse(cr, uid, ids, context=context):
result[sale.id] = 0.0 result[sale.id] = 0.0
for line in sale.order_line: for line in sale.order_line:
@ -94,13 +98,17 @@ class account_invoice_line(osv.osv):
_columns = { _columns = {
'cost_price': fields.float('Cost Price', digits=(16, 2)), 'cost_price': fields.float('Cost Price', digits=(16, 2)),
} }
def write(self, cr, uid, ids, vals, context={}): def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
if vals.get('product_id', False): if vals.get('product_id', False):
res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price']) res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
vals['cost_price'] = res[0]['standard_price'] vals['cost_price'] = res[0]['standard_price']
return super(account_invoice_line, self).write(cr, uid, ids, vals, context) return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
def create(self, cr, uid, vals, context={}): def create(self, cr, uid, vals, context=None):
if not context:
context = {}
if vals.get('product_id',False): if vals.get('product_id',False):
res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price']) res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
vals['cost_price'] = res[0]['standard_price'] vals['cost_price'] = res[0]['standard_price']

View File

@ -30,7 +30,9 @@ class sale_order_dates(osv.osv):
def _get_effective_date(self, cr, uid, ids, name, arg, context=None): def _get_effective_date(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
dates_list = [] dates_list = []
for order in self.browse(cr, uid, ids): if not context:
context = {}
for order in self.browse(cr, uid, ids, context=context):
dates_list = [] dates_list = []
for pick in order.picking_ids: for pick in order.picking_ids:
dates_list.append(pick.date) dates_list.append(pick.date)
@ -43,7 +45,9 @@ class sale_order_dates(osv.osv):
def _get_commitment_date(self, cr, uid, ids, name, arg, context=None): def _get_commitment_date(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
dates_list = [] dates_list = []
for order in self.browse(cr, uid, ids): if not context:
context = {}
for order in self.browse(cr, uid, ids, context=context):
dates_list = [] dates_list = []
for line in order.order_line: for line in order.order_line:
dt = datetime.strptime(order.date_order, '%Y-%m-%d') + relativedelta(days=line.delay or 0.0) dt = datetime.strptime(order.date_order, '%Y-%m-%d') + relativedelta(days=line.delay or 0.0)

View File

@ -53,7 +53,7 @@ class product_product(osv.osv):
'property_stock_variation': account_variation 'property_stock_variation': account_variation
} }
def do_change_standard_price(self, cr, uid, ids, datas, context={}): def do_change_standard_price(self, cr, uid, ids, datas, context=None):
""" Changes the Standard Price of Product and creates an account move accordingly. """ Changes the Standard Price of Product and creates an account move accordingly.
@param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
@param context: A standard dictionary @param context: A standard dictionary
@ -63,19 +63,21 @@ class product_product(osv.osv):
location_obj = self.pool.get('stock.location') location_obj = self.pool.get('stock.location')
move_obj = self.pool.get('account.move') move_obj = self.pool.get('account.move')
move_line_obj = self.pool.get('account.move.line') move_line_obj = self.pool.get('account.move.line')
if not context:
context = {}
new_price = datas.get('new_price', 0.0) new_price = datas.get('new_price', 0.0)
stock_output_acc = datas.get('stock_output_account', False) stock_output_acc = datas.get('stock_output_account', False)
stock_input_acc = datas.get('stock_input_account', False) stock_input_acc = datas.get('stock_input_account', False)
journal_id = datas.get('stock_journal', False) journal_id = datas.get('stock_journal', False)
product_obj=self.browse(cr,uid,ids)[0] product_obj=self.browse(cr, uid, ids, context=context)[0]
account_variation = product_obj.categ_id.property_stock_variation account_variation = product_obj.categ_id.property_stock_variation
account_variation_id = account_variation and account_variation.id or False account_variation_id = account_variation and account_variation.id or False
if not account_variation_id: raise osv.except_osv(_('Error!'), _('Variation Account is not specified for Product Category: %s' % (product_obj.categ_id.name))) if not account_variation_id: raise osv.except_osv(_('Error!'), _('Variation Account is not specified for Product Category: %s' % (product_obj.categ_id.name)))
move_ids = [] move_ids = []
loc_ids = location_obj.search(cr, uid,[('usage','=','internal')]) loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])
for rec_id in ids: for rec_id in ids:
for location in location_obj.browse(cr, uid, loc_ids): for location in location_obj.browse(cr, uid, loc_ids, context=context):
c = context.copy() c = context.copy()
c.update({ c.update({
'location': location.id, 'location': location.id,

View File

@ -534,7 +534,9 @@ class stock_picking(osv.osv):
return False return False
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids] ids = [ids]
for pick in self.browse(cr, uid, ids, context): if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context):
sql_str = """update stock_move set sql_str = """update stock_move set
date='%s' date='%s'
where where
@ -556,6 +558,8 @@ class stock_picking(osv.osv):
return False return False
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids] ids = [ids]
if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context): for pick in self.browse(cr, uid, ids, context=context):
sql_str = """update stock_move set sql_str = """update stock_move set
date='%s' date='%s'
@ -591,6 +595,8 @@ class stock_picking(osv.osv):
return res return res
def create(self, cr, user, vals, context=None): def create(self, cr, user, vals, context=None):
if not context:
context = {}
if ('name' not in vals) or (vals.get('name')=='/'): if ('name' not in vals) or (vals.get('name')=='/'):
seq_obj_name = 'stock.picking.' + vals['type'] seq_obj_name = 'stock.picking.' + vals['type']
vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)
@ -649,7 +655,9 @@ class stock_picking(osv.osv):
'date': time.strftime('%Y-%m-%d %H:%M:%S'), 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c) 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c)
} }
def action_process(self, cr, uid, ids, context={}): def action_process(self, cr, uid, ids, context=None):
if not context:
context = {}
return { return {
'name':_("Products to Process"), 'name':_("Products to Process"),
'view_mode': 'form', 'view_mode': 'form',
@ -670,7 +678,9 @@ class stock_picking(osv.osv):
if default is None: if default is None:
default = {} default = {}
default = default.copy() default = default.copy()
picking_obj = self.browse(cr, uid, [id], context)[0] if not context:
context = {}
picking_obj = self.browse(cr, uid, [id], context=context)[0]
move_obj=self.pool.get('stock.move') move_obj=self.pool.get('stock.move')
if ('name' not in default) or (picking_obj.name=='/'): if ('name' not in default) or (picking_obj.name=='/'):
seq_obj_name = 'stock.picking.' + picking_obj.type seq_obj_name = 'stock.picking.' + picking_obj.type
@ -696,6 +706,8 @@ class stock_picking(osv.osv):
""" """
self.write(cr, uid, ids, {'state': 'confirmed'}) self.write(cr, uid, ids, {'state': 'confirmed'})
todo = [] todo = []
if not context:
context = {}
for picking in self.browse(cr, uid, ids, context=context): for picking in self.browse(cr, uid, ids, context=context):
for r in picking.move_lines: for r in picking.move_lines:
if r.state == 'draft': if r.state == 'draft':
@ -754,7 +766,7 @@ class stock_picking(osv.osv):
context = {} context = {}
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
self.draft_force_assign(cr, uid, ids) self.draft_force_assign(cr, uid, ids)
for pick in self.browse(cr, uid, ids): for pick in self.browse(cr, uid, ids, context=context):
move_ids = [x.id for x in pick.move_lines] move_ids = [x.id for x in pick.move_lines]
self.pool.get('stock.move').force_assign(cr, uid, move_ids) self.pool.get('stock.move').force_assign(cr, uid, move_ids)
wf_service.trg_write(uid, 'stock.picking', pick.id, cr) wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
@ -784,6 +796,8 @@ class stock_picking(osv.osv):
""" Changes picking state to assigned. """ Changes picking state to assigned.
@return: True @return: True
""" """
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'assigned'}) self.write(cr, uid, ids, {'state': 'assigned'})
self.log_picking(cr, uid, ids, context=context) self.log_picking(cr, uid, ids, context=context)
return True return True
@ -820,7 +834,9 @@ class stock_picking(osv.osv):
""" Changes picking state to cancel. """ Changes picking state to cancel.
@return: True @return: True
""" """
for pick in self.browse(cr, uid, ids): if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context):
ids2 = [move.id for move in pick.move_lines] ids2 = [move.id for move in pick.move_lines]
self.pool.get('stock.move').action_cancel(cr, uid, ids2, context) self.pool.get('stock.move').action_cancel(cr, uid, ids2, context)
self.write(cr, uid, ids, {'state': 'cancel', 'invoice_state': 'none'}) self.write(cr, uid, ids, {'state': 'cancel', 'invoice_state': 'none'})
@ -1068,6 +1084,8 @@ class stock_picking(osv.osv):
@return: True or False @return: True or False
""" """
ok = False ok = False
if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context): for pick in self.browse(cr, uid, ids, context=context):
if not pick.move_lines: if not pick.move_lines:
return True return True
@ -1082,13 +1100,17 @@ class stock_picking(osv.osv):
""" Test whether the move lines are canceled or not. """ Test whether the move lines are canceled or not.
@return: True or False @return: True or False
""" """
if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context): for pick in self.browse(cr, uid, ids, context=context):
for move in pick.move_lines: for move in pick.move_lines:
if move.state not in ('cancel',): if move.state not in ('cancel',):
return False return False
return True return True
def allow_cancel(self, cr, uid, ids, context={}): def allow_cancel(self, cr, uid, ids, context=None):
if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context): for pick in self.browse(cr, uid, ids, context=context):
if not pick.move_lines: if not pick.move_lines:
return True return True
@ -1262,6 +1284,8 @@ class stock_picking(osv.osv):
@param ids: List of Picking Ids @param ids: List of Picking Ids
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context:
context = {}
for pick in self.browse(cr, uid, ids, context=context): for pick in self.browse(cr, uid, ids, context=context):
msg='' msg=''
if pick.auto_picking: if pick.auto_picking:
@ -1311,6 +1335,8 @@ class stock_production_lot(osv.osv):
""" Gets stock of products for locations """ Gets stock of products for locations
@return: Dictionary of values @return: Dictionary of values
""" """
if not context:
context = {}
if 'location_id' not in context: if 'location_id' not in context:
locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')], context=context) locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')], context=context)
else: else:
@ -1336,6 +1362,8 @@ class stock_production_lot(osv.osv):
""" Searches Ids of products """ Searches Ids of products
@return: Ids of locations @return: Ids of locations
""" """
if not context:
context = {}
locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')]) locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')])
cr.execute('''select cr.execute('''select
prodlot_id, prodlot_id,
@ -1370,7 +1398,7 @@ class stock_production_lot(osv.osv):
_sql_constraints = [ _sql_constraints = [
('name_ref_uniq', 'unique (name, ref)', _('The combination of serial number and internal reference must be unique !')), ('name_ref_uniq', 'unique (name, ref)', _('The combination of serial number and internal reference must be unique !')),
] ]
def action_traceability(self, cr, uid, ids, context={}): def action_traceability(self, cr, uid, ids, context=None):
""" It traces the information of a product """ It traces the information of a product
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -1379,6 +1407,8 @@ class stock_production_lot(osv.osv):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary of values @return: A dictionary of values
""" """
if not context:
context = {}
value=self.pool.get('action.traceability').action_traceability(cr,uid,ids,context) value=self.pool.get('action.traceability').action_traceability(cr,uid,ids,context)
return value return value
stock_production_lot() stock_production_lot()
@ -1425,7 +1455,9 @@ class stock_move(osv.osv):
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
res = [] res = []
for line in self.browse(cr, uid, ids, context): if not context:
context = {}
for line in self.browse(cr, uid, ids, context=context):
res.append((line.id, (line.product_id.code or '/')+': '+line.location_id.name+' > '+line.location_dest_id.name)) res.append((line.id, (line.product_id.code or '/')+': '+line.location_id.name+' > '+line.location_dest_id.name))
return res return res
@ -1507,6 +1539,8 @@ class stock_move(osv.osv):
""" Gets default address of partner for destination location """ Gets default address of partner for destination location
@return: Address id or False @return: Address id or False
""" """
if not context:
context = {}
if context.get('move_line', []): if context.get('move_line', []):
if context['move_line'][0]: if context['move_line'][0]:
if isinstance(context['move_line'][0], (tuple, list)): if isinstance(context['move_line'][0], (tuple, list)):
@ -1523,6 +1557,8 @@ class stock_move(osv.osv):
""" Gets default address of partner for source location """ Gets default address of partner for source location
@return: Address id or False @return: Address id or False
""" """
if not context:
context = {}
if context.get('move_line', []): if context.get('move_line', []):
try: try:
return context['move_line'][0][2]['location_id'] return context['move_line'][0][2]['location_id']
@ -1545,9 +1581,11 @@ class stock_move(osv.osv):
} }
def write(self, cr, uid, ids, vals, context=None): def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
if uid != 1: if uid != 1:
frozen_fields = set(['product_qty', 'product_uom', 'product_uos_qty', 'product_uos', 'location_id', 'location_dest_id', 'product_id']) frozen_fields = set(['product_qty', 'product_uom', 'product_uos_qty', 'product_uos', 'location_id', 'location_dest_id', 'product_id'])
for move in self.browse(cr, uid, ids): for move in self.browse(cr, uid, ids, context=context):
if move.state == 'done': if move.state == 'done':
if frozen_fields.intersection(vals): if frozen_fields.intersection(vals):
raise osv.except_osv(_('Operation forbidden'), raise osv.except_osv(_('Operation forbidden'),
@ -1558,9 +1596,13 @@ class stock_move(osv.osv):
if default is None: if default is None:
default = {} default = {}
default = default.copy() default = default.copy()
if not context:
context = {}
return super(stock_move, self).copy(cr, uid, id, default, context=context) return super(stock_move, self).copy(cr, uid, id, default, context=context)
def _auto_init(self, cursor, context=None): def _auto_init(self, cursor, context=None):
if not context:
context = {}
res = super(stock_move, self)._auto_init(cursor, context=context) res = super(stock_move, self)._auto_init(cursor, context=context)
cursor.execute('SELECT indexname \ cursor.execute('SELECT indexname \
FROM pg_indexes \ FROM pg_indexes \
@ -1659,6 +1701,8 @@ class stock_move(osv.osv):
@return: Dictionary containing destination location with chained location type. @return: Dictionary containing destination location with chained location type.
""" """
result = {} result = {}
if not context:
context = {}
for m in moves: for m in moves:
dest = self.pool.get('stock.location').chained_location_get( dest = self.pool.get('stock.location').chained_location_get(
cr, cr,
@ -1691,6 +1735,8 @@ class stock_move(osv.osv):
def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None): def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None):
res_obj = self.pool.get('res.company') res_obj = self.pool.get('res.company')
picking_obj = self.pool.get('stock.picking') picking_obj = self.pool.get('stock.picking')
if not context:
context = {}
pick_id= picking_obj.create(cr, uid, { pick_id= picking_obj.create(cr, uid, {
'name': pick_name, 'name': pick_name,
'origin': str(picking.origin or ''), 'origin': str(picking.origin or ''),
@ -1709,7 +1755,9 @@ class stock_move(osv.osv):
""" Confirms stock move. """ Confirms stock move.
@return: List of ids. @return: List of ids.
""" """
moves = self.browse(cr, uid, ids) if not context:
context = {}
moves = self.browse(cr, uid, ids, context=context)
self.write(cr, uid, ids, {'state': 'confirmed'}) self.write(cr, uid, ids, {'state': 'confirmed'})
res_obj = self.pool.get('res.company') res_obj = self.pool.get('res.company')
location_obj = self.pool.get('stock.location') location_obj = self.pool.get('stock.location')
@ -1762,17 +1810,21 @@ class stock_move(osv.osv):
res = self.check_assign(cr, uid, todo) res = self.check_assign(cr, uid, todo)
return res return res
def force_assign(self, cr, uid, ids, context={}): def force_assign(self, cr, uid, ids, context=None):
""" Changes the state to assigned. """ Changes the state to assigned.
@return: True @return: True
""" """
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'assigned'}) self.write(cr, uid, ids, {'state': 'assigned'})
return True return True
def cancel_assign(self, cr, uid, ids, context={}): def cancel_assign(self, cr, uid, ids, context=None):
""" Changes the state to confirmed. """ Changes the state to confirmed.
@return: True @return: True
""" """
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'confirmed'}) self.write(cr, uid, ids, {'state': 'confirmed'})
return True return True
@ -1875,6 +1927,8 @@ class stock_move(osv.osv):
:param context: context dictionary that can explicitly mention the company to consider via the 'force_company' key :param context: context dictionary that can explicitly mention the company to consider via the 'force_company' key
:raise: osv.except_osv() is any mandatory account or journal is not defined. :raise: osv.except_osv() is any mandatory account or journal is not defined.
""" """
if not context:
context = {}
product_obj=self.pool.get('product.product') product_obj=self.pool.get('product.product')
accounts = product_obj.get_product_accounts(cr, uid, move.product_id.id, context) accounts = product_obj.get_product_accounts(cr, uid, move.product_id.id, context)
acc_src = accounts['stock_account_input'] acc_src = accounts['stock_account_input']
@ -1980,13 +2034,13 @@ class stock_move(osv.osv):
context = {} context = {}
todo = [] todo = []
for move in self.browse(cr, uid, ids): for move in self.browse(cr, uid, ids, context=context):
if move.state=="draft": if move.state=="draft":
todo.append(move.id) todo.append(move.id)
if todo: if todo:
self.action_confirm(cr, uid, todo, context=context) self.action_confirm(cr, uid, todo, context=context)
for move in self.browse(cr, uid, ids): for move in self.browse(cr, uid, ids, context=context):
if move.picking_id: if move.picking_id:
picking_ids.append(move.picking_id.id) picking_ids.append(move.picking_id.id)
if move.move_dest_id.id and (move.state != 'done'): if move.move_dest_id.id and (move.state != 'done'):
@ -2096,6 +2150,8 @@ class stock_move(osv.osv):
if quantity <= 0: if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide a positive quantity to scrap!')) raise osv.except_osv(_('Warning!'), _('Please provide a positive quantity to scrap!'))
res = [] res = []
if not context:
context = {}
for move in self.browse(cr, uid, ids, context=context): for move in self.browse(cr, uid, ids, context=context):
move_qty = move.product_qty move_qty = move.product_qty
uos_qty = quantity / move_qty * move.product_uos_qty uos_qty = quantity / move_qty * move.product_uos_qty
@ -2405,7 +2461,7 @@ class stock_inventory(osv.osv):
product_context = dict(context, compute_child=False) product_context = dict(context, compute_child=False)
location_obj = self.pool.get('stock.location') location_obj = self.pool.get('stock.location')
for inv in self.browse(cr, uid, ids): for inv in self.browse(cr, uid, ids, context=context):
move_ids = [] move_ids = []
for line in inv.inventory_line_id: for line in inv.inventory_line_id:
pid = line.product_id.id pid = line.product_id.id
@ -2451,7 +2507,9 @@ class stock_inventory(osv.osv):
""" Cancels the stock move and change inventory state to draft. """ Cancels the stock move and change inventory state to draft.
@return: True @return: True
""" """
for inv in self.browse(cr, uid, ids): if not context:
context = {}
for inv in self.browse(cr, uid, ids, context=context):
self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context) self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context)
self.write(cr, uid, [inv.id], {'state': 'draft'}) self.write(cr, uid, [inv.id], {'state': 'draft'})
return True return True
@ -2460,7 +2518,9 @@ class stock_inventory(osv.osv):
""" Cancels both stock move and inventory """ Cancels both stock move and inventory
@return: True @return: True
""" """
for inv in self.browse(cr,uid,ids): if not context:
context = {}
for inv in self.browse(cr, uid, ids, context=context):
self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context) self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context)
self.write(cr, uid, [inv.id], {'state':'cancel'}) self.write(cr, uid, [inv.id], {'state':'cancel'})
return True return True

View File

@ -37,7 +37,7 @@ class change_standard_price(osv.osv_memory):
'enable_stock_in_out_acc':fields.boolean('Enable Related Account',), 'enable_stock_in_out_acc':fields.boolean('Enable Related Account',),
} }
def default_get(self, cr, uid, fields, context): def default_get(self, cr, uid, fields, context=None):
""" To get default values for the object. """ To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -46,6 +46,8 @@ class change_standard_price(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
product_pool = self.pool.get('product.product') product_pool = self.pool.get('product.product')
product_obj = product_pool.browse(cr, uid, context.get('active_id', False)) product_obj = product_pool.browse(cr, uid, context.get('active_id', False))
res = super(change_standard_price, self).default_get(cr, uid, fields, context=context) res = super(change_standard_price, self).default_get(cr, uid, fields, context=context)
@ -67,7 +69,7 @@ class change_standard_price(osv.osv_memory):
return res return res
def onchange_price(self, cr, uid, ids, new_price, context = {}): def onchange_price(self, cr, uid, ids, new_price, context=None):
""" Sets stock input and output account according to the difference """ Sets stock input and output account according to the difference
of old price and new price. of old price and new price.
@param self: The object pointer. @param self: The object pointer.
@ -78,7 +80,9 @@ class change_standard_price(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: Dictionary of values @return: Dictionary of values
""" """
product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False)) if not context:
context = {}
product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False), context=context)
price = product_obj.standard_price price = product_obj.standard_price
diff = price - new_price diff = price - new_price
if diff > 0 : if diff > 0 :
@ -86,7 +90,7 @@ class change_standard_price(osv.osv_memory):
else : else :
return {'value' : {'enable_stock_in_out_acc':False}} return {'value' : {'enable_stock_in_out_acc':False}}
def change_price(self, cr, uid, ids, context): def change_price(self, cr, uid, ids, context=None):
""" Changes the Standard Price of Product. """ Changes the Standard Price of Product.
And creates an account move accordingly. And creates an account move accordingly.
@param self: The object pointer. @param self: The object pointer.
@ -96,10 +100,12 @@ class change_standard_price(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
if not context:
context = {}
rec_id = context and context.get('active_id', False) rec_id = context and context.get('active_id', False)
assert rec_id, _('Active ID is not set in Context') assert rec_id, _('Active ID is not set in Context')
prod_obj = self.pool.get('product.product') prod_obj = self.pool.get('product.product')
res = self.browse(cr, uid, ids) res = self.browse(cr, uid, ids, context=context)
datas = { datas = {
'new_price' : res[0].new_price, 'new_price' : res[0].new_price,
'stock_output_account' : res[0].stock_account_output.id, 'stock_output_account' : res[0].stock_account_output.id,

View File

@ -67,7 +67,7 @@ class stock_fill_inventory(osv.osv_memory):
ids = ids[0] ids = ids[0]
else: else:
return {} return {}
fill_inventory = self.browse(cr, uid, ids) fill_inventory = self.browse(cr, uid, ids, context=context)
res = {} res = {}
res_location = {} res_location = {}
if fill_inventory.recursive : if fill_inventory.recursive :
@ -86,7 +86,7 @@ class stock_fill_inventory(osv.osv_memory):
for location in res_location.keys(): for location in res_location.keys():
res = res_location[location] res = res_location[location]
for product_id in res.keys(): for product_id in res.keys():
prod = product_obj.browse(cr, uid, [product_id])[0] prod = product_obj.browse(cr, uid, [product_id], context=context)[0]
uom = prod.uom_id.id uom = prod.uom_id.id
context.update(uom=uom, compute_child=False) context.update(uom=uom, compute_child=False)
amount = stock_location_obj._product_get(cr, uid, amount = stock_location_obj._product_get(cr, uid,

View File

@ -30,7 +30,7 @@ class stock_inventory_line_split(osv.osv_memory):
_description = "Split inventory lines" _description = "Split inventory lines"
def default_get(self, cr, uid, fields, context): def default_get(self, cr, uid, fields, context=None):
""" To check the availability of production lot. """ To check the availability of production lot.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -39,9 +39,11 @@ class stock_inventory_line_split(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
record_id = context and context.get('active_id',False) record_id = context and context.get('active_id',False)
res = {} res = {}
line = self.pool.get('stock.inventory.line').browse(cr, uid, record_id) line = self.pool.get('stock.inventory.line').browse(cr, uid, record_id, context=context)
if 'product_id' in fields: if 'product_id' in fields:
res.update({'product_id':line.product_id.id}) res.update({'product_id':line.product_id.id})
if 'product_uom' in fields: if 'product_uom' in fields:
@ -64,8 +66,10 @@ class stock_inventory_line_split(osv.osv_memory):
ir_sequence_obj = self.pool.get('ir.sequence') ir_sequence_obj = self.pool.get('ir.sequence')
line_obj = self.pool.get('stock.inventory.line') line_obj = self.pool.get('stock.inventory.line')
new_line = [] new_line = []
for data in self.browse(cr, uid, ids): if not context:
for inv_line in line_obj.browse(cr, uid, line_ids): context = {}
for data in self.browse(cr, uid, ids, context=context):
for inv_line in line_obj.browse(cr, uid, line_ids, context=context):
line_qty = inv_line.product_qty line_qty = inv_line.product_qty
quantity_rest = inv_line.product_qty quantity_rest = inv_line.product_qty
new_line = [] new_line = []

View File

@ -44,7 +44,7 @@ class stock_inventory_merge(osv.osv_memory):
_('Please select multiple physical inventories to merge in the list view.')) _('Please select multiple physical inventories to merge in the list view.'))
return res return res
def do_merge(self, cr, uid, ids, context): def do_merge(self, cr, uid, ids, context=None):
""" To merge selected Inventories. """ To merge selected Inventories.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -56,6 +56,8 @@ class stock_inventory_merge(osv.osv_memory):
invent_obj = self.pool.get('stock.inventory') invent_obj = self.pool.get('stock.inventory')
invent_line_obj = self.pool.get('stock.inventory.line') invent_line_obj = self.pool.get('stock.inventory.line')
invent_lines = {} invent_lines = {}
if not context:
context = {}
for inventory in invent_obj.browse(cr, uid, context['active_ids'], context=context): for inventory in invent_obj.browse(cr, uid, context['active_ids'], context=context):
if inventory.state == "done": if inventory.state == "done":
raise osv.except_osv(_('Warning'), raise osv.except_osv(_('Warning'),

View File

@ -39,7 +39,7 @@ class stock_invoice_onshipping(osv.osv_memory):
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
count = 0 count = 0
active_ids = context.get('active_ids',[]) active_ids = context.get('active_ids',[])
for pick in pick_obj.browse(cr, uid, active_ids): for pick in pick_obj.browse(cr, uid, active_ids, context=context):
if pick.invoice_state != '2binvoiced': if pick.invoice_state != '2binvoiced':
count += 1 count += 1
if len(active_ids) == 1 and count: if len(active_ids) == 1 and count:

View File

@ -29,7 +29,7 @@ class stock_location_product(osv.osv_memory):
'to_date': fields.datetime('To'), 'to_date': fields.datetime('To'),
} }
def action_open_window(self, cr, uid, ids, context): def action_open_window(self, cr, uid, ids, context=None):
""" To open location wise product information specific to given duration """ To open location wise product information specific to given duration
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor

View File

@ -34,7 +34,7 @@ class stock_move_track(osv.osv_memory):
'quantity': lambda *x: 1 'quantity': lambda *x: 1
} }
def track_lines(self, cr, uid, ids, context={}): def track_lines(self, cr, uid, ids, context=None):
""" To track stock moves lines """ To track stock moves lines
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -70,6 +70,8 @@ class stock_move_consume(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: default values of fields @return: default values of fields
""" """
if not context:
context = {}
res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context)
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
if 'product_id' in fields: if 'product_id' in fields:
@ -83,7 +85,7 @@ class stock_move_consume(osv.osv_memory):
return res return res
def do_move_consume(self, cr, uid, ids, context={}): def do_move_consume(self, cr, uid, ids, context=None):
""" To move consumed products """ To move consumed products
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -92,6 +94,8 @@ class stock_move_consume(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
if not context:
context = {}
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
move_ids = context['active_ids'] move_ids = context['active_ids']
for data in self.read(cr, uid, ids): for data in self.read(cr, uid, ids):
@ -121,6 +125,8 @@ class stock_move_scrap(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: default values of fields @return: default values of fields
""" """
if not context:
context = {}
res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context)
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
location_obj = self.pool.get('stock.location') location_obj = self.pool.get('stock.location')
@ -140,7 +146,7 @@ class stock_move_scrap(osv.osv_memory):
return res return res
def move_scrap(self, cr, uid, ids, context={}): def move_scrap(self, cr, uid, ids, context=None):
""" To move scrapped products """ To move scrapped products
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -149,6 +155,8 @@ class stock_move_scrap(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
if not context:
context = {}
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
move_ids = context['active_ids'] move_ids = context['active_ids']
for data in self.read(cr, uid, ids): for data in self.read(cr, uid, ids):
@ -173,6 +181,8 @@ class split_in_production_lot(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: Default values of fields @return: Default values of fields
""" """
if not context:
context = {}
res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context) res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context)
if context.get('active_id'): if context.get('active_id'):
@ -205,6 +215,8 @@ class split_in_production_lot(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
if not context:
context = {}
self.split(cr, uid, ids, context.get('active_ids'), context=context) self.split(cr, uid, ids, context.get('active_ids'), context=context)
return {} return {}
@ -221,8 +233,10 @@ class split_in_production_lot(osv.osv_memory):
prodlot_obj = self.pool.get('stock.production.lot') prodlot_obj = self.pool.get('stock.production.lot')
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
new_move = [] new_move = []
for data in self.browse(cr, uid, ids): if not context:
for move in move_obj.browse(cr, uid, move_ids): context = {}
for data in self.browse(cr, uid, ids, context=context):
for move in move_obj.browse(cr, uid, move_ids, context=context):
move_qty = move.product_qty move_qty = move.product_qty
quantity_rest = move.product_qty quantity_rest = move.product_qty
uos_qty_rest = move.product_uos_qty uos_qty_rest = move.product_uos_qty

View File

@ -53,7 +53,7 @@ class stock_partial_move(osv.osv_memory):
if not context: if not context:
context = {} context = {}
for move in move_obj.browse(cr, uid, context.get('active_ids', [])): for move in move_obj.browse(cr, uid, context.get('active_ids', []), context=context):
if move.state in ('done', 'cancel'): if move.state in ('done', 'cancel'):
raise osv.except_osv(_('Invalid action !'), _('Cannot deliver products which are already delivered !')) raise osv.except_osv(_('Invalid action !'), _('Cannot deliver products which are already delivered !'))
@ -81,7 +81,7 @@ class stock_partial_move(osv.osv_memory):
context = {} context = {}
res = [] res = []
for move in move_obj.browse(cr, uid, context.get('active_ids', [])): for move in move_obj.browse(cr, uid, context.get('active_ids', []), context=context):
if move.state in ('done', 'cancel'): if move.state in ('done', 'cancel'):
continue continue
res.append(self.__create_partial_move_memory(move)) res.append(self.__create_partial_move_memory(move))
@ -141,7 +141,7 @@ class stock_partial_move(osv.osv_memory):
result['fields'] = _moves_fields result['fields'] = _moves_fields
return result return result
def do_partial(self, cr, uid, ids, context): def do_partial(self, cr, uid, ids, context=None):
""" Makes partial moves and pickings done. """ Makes partial moves and pickings done.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -151,11 +151,12 @@ class stock_partial_move(osv.osv_memory):
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
move_ids = context.get('active_ids', False) move_ids = context.get('active_ids', False)
partial = self.browse(cr, uid, ids[0], context) partial = self.browse(cr, uid, ids[0], context=context)
partial_datas = { partial_datas = {
'delivery_date' : partial.date 'delivery_date' : partial.date
} }
@ -165,7 +166,7 @@ class stock_partial_move(osv.osv_memory):
p_moves[product_move.move_id.id] = product_move p_moves[product_move.move_id.id] = product_move
moves_ids_final = [] moves_ids_final = []
for move in move_obj.browse(cr, uid, move_ids): for move in move_obj.browse(cr, uid, move_ids, context=context):
if move.state in ('done', 'cancel'): if move.state in ('done', 'cancel'):
continue continue
if not p_moves.get(move.id, False): if not p_moves.get(move.id, False):

View File

@ -35,7 +35,7 @@ class stock_partial_picking(osv.osv_memory):
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
if not context: if not context:
context={} context={}
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])): for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context=context):
need_product_cost = (pick.type == 'in') need_product_cost = (pick.type == 'in')
for m in pick.move_lines: for m in pick.move_lines:
if m.state in ('done', 'cancel'): if m.state in ('done', 'cancel'):
@ -157,14 +157,15 @@ class stock_partial_picking(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context) res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
if not context: if not context:
context={} context={}
if 'date' in fields: if 'date' in fields:
res.update({'date': time.strftime('%Y-%m-%d %H:%M:%S')}) res.update({'date': time.strftime('%Y-%m-%d %H:%M:%S')})
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])): for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context=context):
need_product_cost = (pick.type == 'in') need_product_cost = (pick.type == 'in')
for m in pick.move_lines: for m in pick.move_lines:
if m.state in ('done', 'cancel'): if m.state in ('done', 'cancel'):
@ -188,7 +189,7 @@ class stock_partial_picking(osv.osv_memory):
res['move%s_product_currency'%(m.id)] = currency res['move%s_product_currency'%(m.id)] = currency
return res return res
def do_partial(self, cr, uid, ids, context): def do_partial(self, cr, uid, ids, context=None):
""" Makes partial moves and pickings done. """ Makes partial moves and pickings done.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -199,11 +200,11 @@ class stock_partial_picking(osv.osv_memory):
""" """
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
picking_ids = context.get('active_ids', False) picking_ids = context.get('active_ids', False)
partial = self.browse(cr, uid, ids[0], context) partial = self.browse(cr, uid, ids[0], context=context)
partial_datas = { partial_datas = {
'delivery_date' : partial.date 'delivery_date' : partial.date
} }
for pick in pick_obj.browse(cr, uid, picking_ids): for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
need_product_cost = (pick.type == 'in') need_product_cost = (pick.type == 'in')
for m in pick.move_lines: for m in pick.move_lines:
if m.state in ('done', 'cancel'): if m.state in ('done', 'cancel'):

View File

@ -30,10 +30,10 @@ class stock_replacement(osv.osv_memory):
_name = "stock.replacement" _name = "stock.replacement"
_description = "Stock Replacement" _description = "Stock Replacement"
def get_composant(self, cr, uid, ids, context = {}): def get_composant(self, cr, uid, ids, context=None):
return {} return {}
def replace_composant(self, cr, uid, ids, context = {}): def replace_composant(self, cr, uid, ids, context=None):
""" To open a new wizard that acknowledge, a replacement task """ To open a new wizard that acknowledge, a replacement task
@return: It returns the replacement acknowledgement form @return: It returns the replacement acknowledgement form
""" """

View File

@ -29,7 +29,7 @@ class stock_return_picking(osv.osv_memory):
_name = 'stock.return.picking' _name = 'stock.return.picking'
_description = 'Return Picking' _description = 'Return Picking'
def default_get(self, cr, uid, fields, context): def default_get(self, cr, uid, fields, context=None):
""" """
To get default values for the object. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -39,10 +39,12 @@ class stock_return_picking(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary with default values for all field in ``fields`` @return: A dictionary with default values for all field in ``fields``
""" """
if not context:
context = {}
res = super(stock_return_picking, self).default_get(cr, uid, fields, context=context) res = super(stock_return_picking, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id) pick = pick_obj.browse(cr, uid, record_id, context=context)
if pick: if pick:
if 'invoice_state' in fields: if 'invoice_state' in fields:
if pick.invoice_state=='invoiced': if pick.invoice_state=='invoiced':
@ -64,11 +66,13 @@ class stock_return_picking(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: New arch of view with new columns. @return: New arch of view with new columns.
""" """
if not context:
context = {}
res = super(stock_return_picking, self).view_init(cr, uid, fields_list, context=context) res = super(stock_return_picking, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) record_id = context and context.get('active_id', False)
if record_id: if record_id:
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id) pick = pick_obj.browse(cr, uid, record_id, context=context)
if pick.state not in ['done','confirmed','assigned']: if pick.state not in ['done','confirmed','assigned']:
raise osv.except_osv(_('Warning !'), _("You may only return pickings that are Confirmed, Available or Done!")) raise osv.except_osv(_('Warning !'), _("You may only return pickings that are Confirmed, Available or Done!"))
return_history = {} return_history = {}
@ -128,7 +132,7 @@ class stock_return_picking(osv.osv_memory):
res['arch'] = '\n'.join(arch_lst) res['arch'] = '\n'.join(arch_lst)
return res return res
def create_returns(self, cr, uid, ids, context): def create_returns(self, cr, uid, ids, context=None):
""" """
Creates return picking. Creates return picking.
@param self: The object pointer. @param self: The object pointer.
@ -137,14 +141,16 @@ class stock_return_picking(osv.osv_memory):
@param ids: List of ids selected @param ids: List of ids selected
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
pick = pick_obj.browse(cr, uid, record_id) pick = pick_obj.browse(cr, uid, record_id, context=context)
data = self.read(cr, uid, ids[0]) data = self.read(cr, uid, ids[0])
new_picking = None new_picking = None
date_cur = time.strftime('%Y-%m-%d %H:%M:%S') date_cur = time.strftime('%Y-%m-%d %H:%M:%S')

View File

@ -25,7 +25,7 @@ class stock_split_move_line(osv.osv_memory):
_name = 'stock.move.line.split' _name = 'stock.move.line.split'
_description = "Split Moves" _description = "Split Moves"
def default_get(self, cr, uid, fields, context): def default_get(self, cr, uid, fields, context=None):
""" To get default values for the object. """ To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -34,6 +34,8 @@ class stock_split_move_line(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
res = super(stock_split_move_line, self).default_get(cr, uid, fields, context=context) res = super(stock_split_move_line, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
@ -90,7 +92,7 @@ class stock_split_move_line(osv.osv_memory):
res['arch'] = '\n'.join(arch_lst) res['arch'] = '\n'.join(arch_lst)
return res return res
def split_lines(self, cr, uid, ids, context): def split_lines(self, cr, uid, ids, context=None):
""" Splits moves in quantity given in the wizard. """ Splits moves in quantity given in the wizard.
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -99,6 +101,8 @@ class stock_split_move_line(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
record_id = context and context.get('active_id', False) or False record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')

View File

@ -34,12 +34,14 @@ class stock_split_into(osv.osv_memory):
} }
def split(self, cr, uid, data, context=None): def split(self, cr, uid, data, context=None):
if not context:
context = {}
rec_id = context and context.get('active_ids', False) rec_id = context and context.get('active_ids', False)
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
track_obj = self.pool.get('stock.tracking') track_obj = self.pool.get('stock.tracking')
quantity = self.browse(cr, uid, data[0], context).quantity or 0.0 quantity = self.browse(cr, uid, data[0], context=context).quantity or 0.0
for move in move_obj.browse(cr, uid, rec_id): for move in move_obj.browse(cr, uid, rec_id, context=context):
quantity_rest = move.product_qty - quantity quantity_rest = move.product_qty - quantity
#if move.tracking_id : #if move.tracking_id :
# raise osv.except_osv(_('Error!'), _('The current move line is already assigned to a pack, please remove it first if you really want to change it ' \ # raise osv.except_osv(_('Error!'), _('The current move line is already assigned to a pack, please remove it first if you really want to change it ' \

View File

@ -29,7 +29,7 @@ class action_traceability(osv.osv_memory):
_name = "action.traceability" _name = "action.traceability"
_description = "Action traceability " _description = "Action traceability "
def action_traceability(self, cr, uid, ids, context={}): def action_traceability(self, cr, uid, ids, context=None):
""" It traces the information of a product """ It traces the information of a product
@param self: The object pointer. @param self: The object pointer.
@param cr: A database cursor @param cr: A database cursor
@ -38,7 +38,8 @@ class action_traceability(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary of values @return: A dictionary of values
""" """
if not context:
context = {}
type1 = context['type'] or 'move_history_ids2' type1 = context['type'] or 'move_history_ids2'
field = context['field'] or 'tracking_id' field = context['field'] or 'tracking_id'
obj = self.pool.get('stock.move') obj = self.pool.get('stock.move')

View File

@ -27,7 +27,7 @@ class stock_ups(osv.osv_memory):
_name = "stock.ups" _name = "stock.ups"
_description = "Stock ups" _description = "Stock ups"
def ups_save(self, cr, uid, ids, context = {}): def ups_save(self, cr, uid, ids, context=None):
return { return {
'name': False, 'name': False,
'view_type': 'form', 'view_type': 'form',
@ -37,7 +37,7 @@ class stock_ups(osv.osv_memory):
'target':'new', 'target':'new',
} }
def ups_upload(self, cr, uid, ids, context = {}): def ups_upload(self, cr, uid, ids, context=None):
return { return {
'name': False, 'name': False,
'view_type': 'form', 'view_type': 'form',
@ -60,7 +60,7 @@ class stock_ups_final(osv.osv_memory):
_name = "stock.ups.final" _name = "stock.ups.final"
_description = "Stock ups final" _description = "Stock ups final"
def create_xmlfile(self, cr, uid, ids, context = {}): def create_xmlfile(self, cr, uid, ids, context=None):
""" Creates xml report file. """ Creates xml report file.
@return: xml file @return: xml file
""" """
@ -79,7 +79,7 @@ class stock_ups_upload(osv.osv_memory):
_name = "stock.ups.upload" _name = "stock.ups.upload"
_description = "Stock ups upload" _description = "Stock ups upload"
def upload_xmlfile(self, cr, uid, ids, context = {}): def upload_xmlfile(self, cr, uid, ids, context=None):
""" Uploads xml report file. """ Uploads xml report file.
@return: @return:
""" """

View File

@ -24,7 +24,7 @@ from osv import fields, osv
class invoice_directly(osv.osv_memory): class invoice_directly(osv.osv_memory):
_inherit = 'stock.partial.picking' _inherit = 'stock.partial.picking'
def do_partial(self, cr, uid, ids, context): def do_partial(self, cr, uid, ids, context=None):
""" Makes partial moves and pickings done and """ Makes partial moves and pickings done and
launches Create invoice wizard if invoice state is To be Invoiced. launches Create invoice wizard if invoice state is To be Invoiced.
@param self: The object pointer. @param self: The object pointer.
@ -33,10 +33,12 @@ class invoice_directly(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
if not context:
context = {}
result = super(invoice_directly, self).do_partial(cr, uid, ids, context) result = super(invoice_directly, self).do_partial(cr, uid, ids, context)
pick_obj = self.pool.get('stock.picking') pick_obj = self.pool.get('stock.picking')
picking_ids = context.get('active_ids', False) picking_ids = context.get('active_ids', False)
pick = pick_obj.browse(cr, uid, picking_ids, context)[0] pick = pick_obj.browse(cr, uid, picking_ids, context=context)[0]
if pick.invoice_state == '2binvoiced': if pick.invoice_state == '2binvoiced':
return { return {
'name': 'Create Invoice', 'name': 'Create Invoice',

View File

@ -25,21 +25,27 @@ from tools.translate import _
class procurement_order(osv.osv): class procurement_order(osv.osv):
_inherit = 'procurement.order' _inherit = 'procurement.order'
def check_buy(self, cr, uid, ids, context=None): def check_buy(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids): if not context:
context = {}
for procurement in self.browse(cr, uid, ids, context=context):
for line in procurement.product_id.flow_pull_ids: for line in procurement.product_id.flow_pull_ids:
if line.location_id==procurement.location_id: if line.location_id==procurement.location_id:
return line.type_proc=='buy' return line.type_proc=='buy'
return super(procurement_order, self).check_buy(cr, uid, ids) return super(procurement_order, self).check_buy(cr, uid, ids)
def check_produce(self, cr, uid, ids, context=None): def check_produce(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids): if not context:
context = {}
for procurement in self.browse(cr, uid, ids, context=context):
for line in procurement.product_id.flow_pull_ids: for line in procurement.product_id.flow_pull_ids:
if line.location_id==procurement.location_id: if line.location_id==procurement.location_id:
return line.type_proc=='produce' return line.type_proc=='produce'
return super(procurement_order, self).check_produce(cr, uid, ids) return super(procurement_order, self).check_produce(cr, uid, ids)
def check_move(self, cr, uid, ids, context=None): def check_move(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids): if not context:
context = {}
for procurement in self.browse(cr, uid, ids, context=context):
for line in procurement.product_id.flow_pull_ids: for line in procurement.product_id.flow_pull_ids:
if line.location_id==procurement.location_id: if line.location_id==procurement.location_id:
return (line.type_proc=='move') and (line.location_src_id) return (line.type_proc=='move') and (line.location_src_id)
@ -50,6 +56,8 @@ class procurement_order(osv.osv):
move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move')
picking_obj=self.pool.get('stock.picking') picking_obj=self.pool.get('stock.picking')
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
if not context:
context = {}
for proc in proc_obj.browse(cr, uid, ids, context=context): for proc in proc_obj.browse(cr, uid, ids, context=context):
line = None line = None
for line in proc.product_id.flow_pull_ids: for line in proc.product_id.flow_pull_ids:

View File

@ -106,7 +106,9 @@ class stock_move(osv.osv):
_columns = { _columns = {
'cancel_cascade': fields.boolean('Cancel Cascade', help='If checked, when this move is cancelled, cancel the linked move too') 'cancel_cascade': fields.boolean('Cancel Cascade', help='If checked, when this move is cancelled, cancel the linked move too')
} }
def action_cancel(self,cr,uid,ids,context={ }): def action_cancel(self, cr, uid, ids, context=None):
if not context:
context = {}
for m in self.browse(cr, uid, ids, context=context): for m in self.browse(cr, uid, ids, context=context):
if m.cancel_cascade and m.move_dest_id: if m.cancel_cascade and m.move_dest_id:
self.action_cancel(cr, uid, [m.move_dest_id.id], context=context) self.action_cancel(cr, uid, [m.move_dest_id.id], context=context)
@ -116,7 +118,9 @@ stock_move()
class stock_location(osv.osv): class stock_location(osv.osv):
_inherit = 'stock.location' _inherit = 'stock.location'
def chained_location_get(self, cr, uid, location, partner=None, product=None, context={}): def chained_location_get(self, cr, uid, location, partner=None, product=None, context=None):
if not context:
context = {}
if product: if product:
for path in product.path_ids: for path in product.path_ids:
if path.location_from_id.id == location.id: if path.location_from_id.id == location.id:

View File

@ -47,11 +47,15 @@ class stock_period(osv.osv):
'state': 'draft' 'state': 'draft'
} }
def button_open(self, cr, uid, ids, context): def button_open(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'open'}) self.write(cr, uid, ids, {'state': 'open'})
return True return True
def button_close(self, cr, uid, ids, context): def button_close(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state': 'close'}) self.write(cr, uid, ids, {'state': 'close'})
return True return True
@ -192,17 +196,21 @@ class stock_sale_forecast(osv.osv):
def _to_default_uom_factor(self, cr, uid, product_id, uom_id, context=None): def _to_default_uom_factor(self, cr, uid, product_id, uom_id, context=None):
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id) if not context:
context = {}
product = product_obj.browse(cr, uid, product_id, context=context)
uom = uom_obj.browse(cr, uid, uom_id, context=context) uom = uom_obj.browse(cr, uid, uom_id, context=context)
coef = uom.factor coef = uom.factor
if uom.category_id.id <> product.uom_id.category_id.id: if uom.category_id.id <> product.uom_id.category_id.id:
coef = coef / product.uos_coeff coef = coef / product.uos_coeff
return product.uom_id.factor / coef return product.uom_id.factor / coef
def _from_default_uom_factor(self, cr, uid, product_id, uom_id, context): def _from_default_uom_factor(self, cr, uid, product_id, uom_id, context=None):
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id) if not context:
context = {}
product = product_obj.browse(cr, uid, product_id, context=context)
uom = uom_obj.browse(cr, uid, uom_id, context=context) uom = uom_obj.browse(cr, uid, uom_id, context=context)
res = uom.factor res = uom.factor
if uom.category_id.id <> product.uom_id.category_id.id: if uom.category_id.id <> product.uom_id.category_id.id:
@ -346,8 +354,10 @@ class stock_planning(osv.osv):
res = self._to_planning_uom(cr, uid, val, planning_qtys, context) res = self._to_planning_uom(cr, uid, val, planning_qtys, context)
return res return res
def _to_planning_uom(self, cr, uid, val, qtys, context): def _to_planning_uom(self, cr, uid, val, qtys, context=None):
res_qty = 0 res_qty = 0
if not context:
context = {}
if qtys: if qtys:
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
for qty, prod_uom in qtys: for qty, prod_uom in qtys:
@ -360,7 +370,9 @@ class stock_planning(osv.osv):
def _get_forecast(self, cr, uid, ids, field_names, arg, context=None): def _get_forecast(self, cr, uid, ids, field_names, arg, context=None):
res = {} res = {}
for val in self.browse(cr, uid, ids): if not context:
context = {}
for val in self.browse(cr, uid, ids, context=context):
res[val.id] = {} res[val.id] = {}
valid_part = val.confirmed_forecasts_only and " AND state = 'validated'" or "" valid_part = val.confirmed_forecasts_only and " AND state = 'validated'" or ""
cr.execute('SELECT sum(product_qty), product_uom \ cr.execute('SELECT sum(product_qty), product_uom \
@ -382,6 +394,8 @@ class stock_planning(osv.osv):
return res return res
def _get_stock_start(self, cr, uid, val, date, context=None): def _get_stock_start(self, cr, uid, val, date, context=None):
if not context:
context = {}
context['from_date'] = None context['from_date'] = None
context['to_date'] = date context['to_date'] = date
locations = [val.warehouse_id.lot_stock_id.id,] locations = [val.warehouse_id.lot_stock_id.id,]
@ -393,8 +407,10 @@ class stock_planning(osv.osv):
res = product_obj['qty_available'] # value for stock_start res = product_obj['qty_available'] # value for stock_start
return res return res
def _get_past_future(self, cr, uid, ids, field_names, arg, context): def _get_past_future(self, cr, uid, ids, field_names, arg, context=None):
res = {} res = {}
if not context:
context = {}
for val in self.browse(cr, uid, ids, context=context): for val in self.browse(cr, uid, ids, context=context):
if val.period_id.date_stop < time.strftime('%Y-%m-%d'): if val.period_id.date_stop < time.strftime('%Y-%m-%d'):
res[val.id] = 'Past' res[val.id] = 'Past'
@ -404,6 +420,8 @@ class stock_planning(osv.osv):
def _get_op(self, cr, uid, ids, field_names, arg, context=None): # op = OrderPoint def _get_op(self, cr, uid, ids, field_names, arg, context=None): # op = OrderPoint
res = {} res = {}
if not context:
context = {}
for val in self.browse(cr, uid, ids, context=context): for val in self.browse(cr, uid, ids, context=context):
res[val.id]={} res[val.id]={}
cr.execute("SELECT product_min_qty, product_max_qty, product_uom \ cr.execute("SELECT product_min_qty, product_max_qty, product_uom \
@ -519,7 +537,9 @@ class stock_planning(osv.osv):
def _to_default_uom_factor(self, cr, uid, product_id, uom_id, context=None): def _to_default_uom_factor(self, cr, uid, product_id, uom_id, context=None):
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id) if not context:
context = {}
product = product_obj.browse(cr, uid, product_id, context=context)
uom = uom_obj.browse(cr, uid, uom_id, context=context) uom = uom_obj.browse(cr, uid, uom_id, context=context)
coef = uom.factor coef = uom.factor
if uom.category_id.id != product.uom_id.category_id.id: if uom.category_id.id != product.uom_id.category_id.id:
@ -530,7 +550,7 @@ class stock_planning(osv.osv):
def _from_default_uom_factor(self, cr, uid, product_id, uom_id, context=None): def _from_default_uom_factor(self, cr, uid, product_id, uom_id, context=None):
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')
product = product_obj.browse(cr, uid, product_id) product = product_obj.browse(cr, uid, product_id, context=context)
uom = uom_obj.browse(cr, uid, uom_id, context=context) uom = uom_obj.browse(cr, uid, uom_id, context=context)
res = uom.factor res = uom.factor
if uom.category_id.id != product.uom_id.category_id.id: if uom.category_id.id != product.uom_id.category_id.id:
@ -592,9 +612,11 @@ class stock_planning(osv.osv):
# so if UoM is from UoM category it is used as UoM in standard and if product has UoS the UoS will be calcualated. # so if UoM is from UoM category it is used as UoM in standard and if product has UoS the UoS will be calcualated.
# If UoM is from UoS category it is recalculated to basic UoS from product (in planning you can use any UoS from UoS category) # If UoM is from UoS category it is recalculated to basic UoS from product (in planning you can use any UoS from UoS category)
# and basic UoM is calculated. # and basic UoM is calculated.
def _qty_to_standard(self, cr, uid, val, context): def _qty_to_standard(self, cr, uid, val, context=None):
uos = False uos = False
uos_qty = 0.0 uos_qty = 0.0
if not context:
context = {}
if val.product_uom.category_id.id == val.product_id.uom_id.category_id.id: if val.product_uom.category_id.id == val.product_id.uom_id.category_id.id:
uom_qty = val.incoming_left uom_qty = val.incoming_left
uom = val.product_uom.id uom = val.product_uom.id

View File

@ -31,6 +31,8 @@ class stock_period_createlines(osv.osv_memory):
_name = "stock.period.createlines" _name = "stock.period.createlines"
def _get_new_period_start(self, cr, uid, context=None): def _get_new_period_start(self, cr, uid, context=None):
if not context:
context = {}
cr.execute("select max(date_stop) from stock_period") cr.execute("select max(date_stop) from stock_period")
result = cr.fetchone() result = cr.fetchone()
last_date = result and result[0] or False last_date = result and result[0] or False
@ -53,6 +55,8 @@ class stock_period_createlines(osv.osv_memory):
} }
def create_stock_periods(self, cr, uid, ids, context=None): def create_stock_periods(self, cr, uid, ids, context=None):
if not context:
context = {}
interval = context.get('interval',0) interval = context.get('interval',0)
name = context.get('name','Daily') name = context.get('name','Daily')
period_obj = self.pool.get('stock.period') period_obj = self.pool.get('stock.period')

View File

@ -50,6 +50,8 @@ class stock_sale_forecast_createlines(osv.osv_memory):
prod_categ_obj = self.pool.get('product.category') prod_categ_obj = self.pool.get('product.category')
template_obj = self.pool.get('product.template') template_obj = self.pool.get('product.template')
forecast_lines = [] forecast_lines = []
if not context:
context = {}
for f in self.browse(cr, uid, ids, context=context): for f in self.browse(cr, uid, ids, context=context):
categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or [] categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or []
prod_categ_ids = prod_categ_obj.search(cr, uid, [('parent_id','child_of', categ_ids)]) prod_categ_ids = prod_categ_obj.search(cr, uid, [('parent_id','child_of', categ_ids)])

View File

@ -40,6 +40,8 @@ class subscription_document(osv.osv):
} }
def write(self, cr, uid, ids, vals, context=None): def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
if 'model' in vals: if 'model' in vals:
raise osv.except_osv(_('Error !'),_('You cannot modify the Object linked to the Document Type!\nCreate another Document instead !')) raise osv.except_osv(_('Error !'),_('You cannot modify the Object linked to the Document Type!\nCreate another Document instead !'))
return super(subscription_document, self).write(cr, uid, ids, vals, context=context) return super(subscription_document, self).write(cr, uid, ids, vals, context=context)
@ -91,7 +93,9 @@ class subscription_subscription(osv.osv):
'state': lambda *a: 'draft' 'state': lambda *a: 'draft'
} }
def set_process(self, cr, uid, ids, context={}): def set_process(self, cr, uid, ids, context=None):
if not context:
context = {}
for row in self.read(cr, uid, ids): for row in self.read(cr, uid, ids):
mapping = {'name':'name','interval_number':'interval_number','interval_type':'interval_type','exec_init':'numbercall','date_init':'nextcall'} mapping = {'name':'name','interval_number':'interval_number','interval_type':'interval_type','exec_init':'numbercall','date_init':'nextcall'}
res = {'model':'subscription.subscription', 'args': repr([[row['id']]]), 'function':'model_copy', 'priority':6, 'user_id':row['user_id'] and row['user_id'][0]} res = {'model':'subscription.subscription', 'args': repr([[row['id']]]), 'function':'model_copy', 'priority':6, 'user_id':row['user_id'] and row['user_id'][0]}
@ -101,7 +105,9 @@ class subscription_subscription(osv.osv):
self.write(cr, uid, [row['id']], {'cron_id':id, 'state':'running'}) self.write(cr, uid, [row['id']], {'cron_id':id, 'state':'running'})
return True return True
def model_copy(self, cr, uid, ids, context={}): def model_copy(self, cr, uid, ids, context=None):
if not context:
context = {}
for row in self.read(cr, uid, ids): for row in self.read(cr, uid, ids):
if not row.get('cron_id',False): if not row.get('cron_id',False):
continue continue
@ -136,14 +142,18 @@ class subscription_subscription(osv.osv):
self.write(cr, uid, [row['id']], {'state':state}) self.write(cr, uid, [row['id']], {'state':state})
return True return True
def set_done(self, cr, uid, ids, context={}): def set_done(self, cr, uid, ids, context=None):
if not context:
context = {}
res = self.read(cr,uid, ids, ['cron_id']) res = self.read(cr,uid, ids, ['cron_id'])
ids2 = [x['cron_id'][0] for x in res if x['id']] ids2 = [x['cron_id'][0] for x in res if x['id']]
self.pool.get('ir.cron').write(cr, uid, ids2, {'active':False}) self.pool.get('ir.cron').write(cr, uid, ids2, {'active':False})
self.write(cr, uid, ids, {'state':'done'}) self.write(cr, uid, ids, {'state':'done'})
return True return True
def set_draft(self, cr, uid, ids, context={}): def set_draft(self, cr, uid, ids, context=None):
if not context:
context = {}
self.write(cr, uid, ids, {'state':'draft'}) self.write(cr, uid, ids, {'state':'draft'})
return True return True
subscription_subscription() subscription_subscription()

View File

@ -46,7 +46,9 @@ class survey(osv.osv):
_description = 'Survey' _description = 'Survey'
_rec_name = 'title' _rec_name = 'title'
def default_get(self, cr, uid, fields, context={}): def default_get(self, cr, uid, fields, context=None):
if not context:
context = {}
data = super(survey, self).default_get(cr, uid, fields, context) data = super(survey, self).default_get(cr, uid, fields, context)
return data return data
@ -94,7 +96,9 @@ class survey(osv.osv):
self.write(cr, uid, ids, {'state': 'cancel' }) self.write(cr, uid, ids, {'state': 'cancel' })
return True return True
def copy(self, cr, uid, id, default=None,context={}): def copy(self, cr, uid, id, default=None,context=None):
if not context:
context = {}
raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!')) raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
def action_print_survey(self, cr, uid, ids, context=None): def action_print_survey(self, cr, uid, ids, context=None):
@ -173,7 +177,9 @@ class survey_page(osv.osv):
'sequence': lambda * a: 1 'sequence': lambda * a: 1
} }
def default_get(self, cr, uid, fields, context={}): def default_get(self, cr, uid, fields, context=None):
if not context:
context = {}
data = super(survey_page, self).default_get(cr, uid, fields, context) data = super(survey_page, self).default_get(cr, uid, fields, context)
if context.get('line_order',False): if context.get('line_order',False):
if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'): if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'):
@ -182,7 +188,9 @@ class survey_page(osv.osv):
data['survey_id'] = context['survey_id'] data['survey_id'] = context['survey_id']
return data return data
def survey_save(self, cr, uid, ids, context): def survey_save(self, cr, uid, ids, context=None):
if not context:
context = {}
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz = self.pool.get('survey.name.wiz')
@ -197,7 +205,9 @@ class survey_page(osv.osv):
'context': context 'context': context
} }
def copy(self, cr, uid, id, default=None, context={}): def copy(self, cr, uid, id, default=None, context=None):
if not context:
context = {}
raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!')) raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
survey_page() survey_page()
@ -208,10 +218,12 @@ class survey_question(osv.osv):
_rec_name = 'question' _rec_name = 'question'
_order = 'sequence' _order = 'sequence'
def _calc_response(self, cr, uid, ids, field_name, arg, context): def _calc_response(self, cr, uid, ids, field_name, arg, context=None):
if len(ids) == 0: if len(ids) == 0:
return {} return {}
val = {} val = {}
if not context:
context = {}
cr.execute("select question_id, count(id) as Total_response from \ cr.execute("select question_id, count(id) as Total_response from \
survey_response_line where state='done' and question_id IN %s\ survey_response_line where state='done' and question_id IN %s\
group by question_id" ,(tuple(ids),)) group by question_id" ,(tuple(ids),))
@ -439,9 +451,11 @@ class survey_question(osv.osv):
return super(survey_question, self).write(cr, uid, ids, vals, context=context) return super(survey_question, self).write(cr, uid, ids, vals, context=context)
def create(self, cr, uid, vals, context): def create(self, cr, uid, vals, context=None):
minimum_ans = 0 minimum_ans = 0
maximum_ans = 0 maximum_ans = 0
if not context:
context = {}
if vals.has_key('answer_choice_ids') and not len(vals['answer_choice_ids']): if vals.has_key('answer_choice_ids') and not len(vals['answer_choice_ids']):
if vals.has_key('type') and vals['type'] not in ['descriptive_text', 'single_textbox', 'comment','table']: if vals.has_key('type') and vals['type'] not in ['descriptive_text', 'single_textbox', 'comment','table']:
raise osv.except_osv(_('Warning !'),_("You must enter one or more answer.")) raise osv.except_osv(_('Warning !'),_("You must enter one or more answer."))
@ -475,7 +489,9 @@ class survey_question(osv.osv):
res = super(survey_question, self).create(cr, uid, vals, context) res = super(survey_question, self).create(cr, uid, vals, context)
return res return res
def survey_save(self, cr, uid, ids, context): def survey_save(self, cr, uid, ids, context=None):
if not context:
context = {}
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz = self.pool.get('survey.name.wiz')
@ -490,7 +506,9 @@ class survey_question(osv.osv):
'context': context 'context': context
} }
def default_get(self, cr, uid, fields, context={}): def default_get(self, cr, uid, fields, context=None):
if not context:
context = {}
data = super(survey_question, self).default_get(cr, uid, fields, context) data = super(survey_question, self).default_get(cr, uid, fields, context)
if context.get('line_order',False): if context.get('line_order',False):
if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'): if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'):
@ -508,11 +526,15 @@ class survey_question_column_heading(osv.osv):
_description = 'Survey Question Column Heading' _description = 'Survey Question Column Heading'
_rec_name = 'title' _rec_name = 'title'
def _get_in_visible_rating_weight(self,cr, uid, context={}): def _get_in_visible_rating_weight(self,cr, uid, context=None):
if not context:
context = {}
if context.get('in_visible_rating_weight', False): if context.get('in_visible_rating_weight', False):
return context['in_visible_rating_weight'] return context['in_visible_rating_weight']
return False return False
def _get_in_visible_menu_choice(self,cr, uid, context={}): def _get_in_visible_menu_choice(self,cr, uid, context=None):
if not context:
context = {}
if context.get('in_visible_menu_choice', False): if context.get('in_visible_menu_choice', False):
return context['in_visible_menu_choice'] return context['in_visible_menu_choice']
return False return False
@ -537,9 +559,11 @@ class survey_answer(osv.osv):
_rec_name = 'answer' _rec_name = 'answer'
_order = 'sequence' _order = 'sequence'
def _calc_response_avg(self, cr, uid, ids, field_name, arg, context): def _calc_response_avg(self, cr, uid, ids, field_name, arg, context=None):
val = {} val = {}
for rec in self.browse(cr, uid, ids, context): if not context:
context = {}
for rec in self.browse(cr, uid, ids, context=context):
cr.execute("select count(question_id) ,(select count(answer_id) \ cr.execute("select count(question_id) ,(select count(answer_id) \
from survey_response_answer sra, survey_response_line sa \ from survey_response_answer sra, survey_response_line sa \
where sra.response_id = sa.id and sra.answer_id = %d \ where sra.response_id = sa.id and sra.answer_id = %d \
@ -557,7 +581,9 @@ class survey_answer(osv.osv):
} }
return val return val
def _get_in_visible_answer_type(self,cr, uid, context={}): def _get_in_visible_answer_type(self,cr, uid, context=None):
if not context:
context = {}
return context.get('in_visible_answer_type', False) return context.get('in_visible_answer_type', False)
_columns = { _columns = {
@ -578,7 +604,9 @@ class survey_answer(osv.osv):
'in_visible_answer_type':_get_in_visible_answer_type, 'in_visible_answer_type':_get_in_visible_answer_type,
} }
def default_get(self, cr, uid, fields, context={}): def default_get(self, cr, uid, fields, context=None):
if not context:
context = {}
data = super(survey_answer, self).default_get(cr, uid, fields, context) data = super(survey_answer, self).default_get(cr, uid, fields, context)
if context.get('line_order', False): if context.get('line_order', False):
if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'): if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'):
@ -615,7 +643,9 @@ class survey_response(osv.osv):
res.append((record['id'], name)) res.append((record['id'], name))
return res return res
def copy(self, cr, uid, id, default=None,context={}): def copy(self, cr, uid, id, default=None,context=None):
if not context:
context = {}
raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!')) raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
survey_response() survey_response()
@ -714,9 +744,11 @@ class survey_request(osv.osv):
return True return True
def on_change_user(self, cr, uid, ids, user_id, context=None): def on_change_user(self, cr, uid, ids, user_id, context=None):
if not context:
context = {}
if user_id: if user_id:
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
user = user_obj.browse(cr, uid, user_id) user = user_obj.browse(cr, uid, user_id, context=context)
return {'value': {'email': user.address_id.email}} return {'value': {'email': user.address_id.email}}
return {} return {}

View File

@ -74,10 +74,10 @@ class survey_question_wiz(osv.osv_memory):
'response': 0 'response': 0
} }
wiz_id = surv_name_wiz.create(cr, uid, res_data) wiz_id = surv_name_wiz.create(cr, uid, res_data)
sur_name_rec = surv_name_wiz.browse(cr, uid, wiz_id) sur_name_rec = surv_name_wiz.browse(cr, uid, wiz_id, context=context)
context.update({'sur_name_id' :wiz_id}) context.update({'sur_name_id' :wiz_id})
else: else:
sur_name_rec = surv_name_wiz.browse(cr, uid, context['sur_name_id']) sur_name_rec = surv_name_wiz.browse(cr, uid, context['sur_name_id'], context=context)
if context.has_key('active_id'): if context.has_key('active_id'):
context.pop('active_id') context.pop('active_id')
@ -96,7 +96,7 @@ class survey_question_wiz(osv.osv_memory):
return super(survey_question_wiz, self).\ return super(survey_question_wiz, self).\
fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context,
toolbar=toolbar, submenu=submenu) toolbar=toolbar, submenu=submenu)
sur_rec = survey_obj.browse(cr, uid, survey_id) sur_rec = survey_obj.browse(cr, uid, survey_id, context=context)
p_id = map(lambda x:x.id, sur_rec.page_ids) p_id = map(lambda x:x.id, sur_rec.page_ids)
total_pages = len(p_id) total_pages = len(p_id)
pre_button = False pre_button = False
@ -109,7 +109,7 @@ class survey_question_wiz(osv.osv_memory):
if not sur_name_rec.page_no + 1 : if not sur_name_rec.page_no + 1 :
surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'store_ans':{}}) surv_name_wiz.write(cr, uid, [context['sur_name_id'],], {'store_ans':{}})
sur_name_read = surv_name_wiz.browse(cr, uid, context['sur_name_id']) sur_name_read = surv_name_wiz.browse(cr, uid, context['sur_name_id'], context=context)
page_number = int(sur_name_rec.page_no) page_number = int(sur_name_rec.page_no)
if sur_name_read.transfer or not sur_name_rec.page_no + 1: if sur_name_read.transfer or not sur_name_rec.page_no + 1:
surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'transfer':False}) surv_name_wiz.write(cr, uid, [context['sur_name_id']], {'transfer':False})
@ -149,7 +149,7 @@ class survey_question_wiz(osv.osv_memory):
if sur_name_rec.page_no > 1: if sur_name_rec.page_no > 1:
pre_button = True pre_button = True
if flag: if flag:
pag_rec = page_obj.browse(cr, uid, p_id) pag_rec = page_obj.browse(cr, uid, p_id, context=context)
xml_form = etree.Element('form', {'string': tools.ustr(pag_rec.title)}) xml_form = etree.Element('form', {'string': tools.ustr(pag_rec.title)})
xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'}) xml_group = etree.SubElement(xml_form, 'group', {'col': '1', 'colspan': '4'})
if context.has_key('response_id') and context.get('response_id', False) \ if context.has_key('response_id') and context.get('response_id', False) \
@ -177,7 +177,7 @@ class survey_question_wiz(osv.osv_memory):
for que in que_ids: for que in que_ids:
qu_no += 1 qu_no += 1
que_rec = que_obj.browse(cr, uid, que.id) que_rec = que_obj.browse(cr, uid, que.id, context=context)
descriptive_text = "" descriptive_text = ""
separator_string = tools.ustr(qu_no) + "." + tools.ustr(que_rec.question) separator_string = tools.ustr(qu_no) + "." + tools.ustr(que_rec.question)
if ((context.has_key('active') and not context.get('active',False)) or not context.has_key('active')) and que_rec.is_require_answer: if ((context.has_key('active') and not context.get('active',False)) or not context.has_key('active')) and que_rec.is_require_answer:
@ -424,7 +424,7 @@ class survey_question_wiz(osv.osv_memory):
cr.execute("select email from res_partner_address where id =%s", (resp_id.id,)) cr.execute("select email from res_partner_address where id =%s", (resp_id.id,))
resp_email = cr.fetchone()[0] resp_email = cr.fetchone()[0]
if user_email and resp_email: if user_email and resp_email:
user_name = user_obj.browse(cr, uid, uid).name user_name = user_obj.browse(cr, uid, uid, context=context).name
mail = "Hello " + survey_data.responsible_id.name + ",\n\n " + str(user_name) + " Give Response Of " + survey_data.title + " Survey.\n\n Thanks," mail = "Hello " + survey_data.responsible_id.name + ",\n\n " + str(user_name) + " Give Response Of " + survey_data.title + " Survey.\n\n Thanks,"
tools.email_send(user_email, [resp_email], "Survey Answer Of " + str(user_name) , mail, attach = attachments) tools.email_send(user_email, [resp_email], "Survey Answer Of " + str(user_name) , mail, attach = attachments)
@ -479,6 +479,8 @@ class survey_question_wiz(osv.osv_memory):
@return : Dictionary value for fields list with value. @return : Dictionary value for fields list with value.
""" """
value = {} value = {}
if not context:
context = {}
for field in fields_list: for field in fields_list:
if field.split('_')[0] == 'progress': if field.split('_')[0] == 'progress':
tot_page_id = self.pool.get('survey').browse(cr, uid, context.get('survey_id',False)) tot_page_id = self.pool.get('survey').browse(cr, uid, context.get('survey_id',False))
@ -1006,7 +1008,7 @@ class survey_question_wiz(osv.osv_memory):
return True return True
def action_new_question(self,cr, uid, ids, context): def action_new_question(self,cr, uid, ids, context=None):
""" """
New survey.Question form. New survey.Question form.
@ -1017,6 +1019,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open new survey.Qestion form. @return : Dictionary value for Open new survey.Qestion form.
""" """
if not context:
context = {}
for key,val in context.items(): for key,val in context.items():
if type(key) == type(True): if type(key) == type(True):
context.pop(key) context.pop(key)
@ -1032,7 +1036,7 @@ class survey_question_wiz(osv.osv_memory):
'context': context 'context': context
} }
def action_new_page(self, cr, uid, ids, context): def action_new_page(self, cr, uid, ids, context=None):
""" """
New survey.Page form. New survey.Page form.
@ -1043,6 +1047,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open new survey.page form. @return : Dictionary value for Open new survey.page form.
""" """
if not context:
context = {}
for key,val in context.items(): for key,val in context.items():
if type(key) == type(True): if type(key) == type(True):
context.pop(key) context.pop(key)
@ -1058,7 +1064,7 @@ class survey_question_wiz(osv.osv_memory):
'context': context 'context': context
} }
def action_edit_page(self,cr, uid, ids, context): def action_edit_page(self,cr, uid, ids, context=None):
""" """
Edit survey.page. Edit survey.page.
@ -1069,6 +1075,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open Edit survey.page form. @return : Dictionary value for Open Edit survey.page form.
""" """
if not context:
context = {}
for key,val in context.items(): for key,val in context.items():
if type(key) == type(True): if type(key) == type(True):
context.pop(key) context.pop(key)
@ -1085,7 +1093,7 @@ class survey_question_wiz(osv.osv_memory):
'context': context 'context': context
} }
def action_delete_page(self,cr, uid, ids, context): def action_delete_page(self,cr, uid, ids, context=None):
""" """
Delete survey.page. Delete survey.page.
@ -1096,6 +1104,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open next survey.page form, but delete the selected page. @return : Dictionary value for Open next survey.page form, but delete the selected page.
""" """
if not context:
context = {}
for key,val in context.items(): for key,val in context.items():
if type(key) == type(True): if type(key) == type(True):
context.pop(key) context.pop(key)
@ -1116,7 +1126,7 @@ class survey_question_wiz(osv.osv_memory):
'context': context 'context': context
} }
def action_edit_question(self,cr, uid, ids, context): def action_edit_question(self,cr, uid, ids, context=None):
""" """
Edit survey.question. Edit survey.question.
@ -1127,6 +1137,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open Edit survey.question form. @return : Dictionary value for Open Edit survey.question form.
""" """
if not context:
context = {}
for key,val in context.items(): for key,val in context.items():
if type(key) == type(True): if type(key) == type(True):
context.pop(key) context.pop(key)
@ -1143,7 +1155,7 @@ class survey_question_wiz(osv.osv_memory):
'context': context 'context': context
} }
def action_delete_question(self,cr, uid, ids, context): def action_delete_question(self,cr, uid, ids, context=None):
""" """
Delete survey.question. Delete survey.question.
@ -1154,6 +1166,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open same survey.page form, but delete the selected survey.question in current survey.page. @return : Dictionary value for Open same survey.page form, but delete the selected survey.question in current survey.page.
""" """
if not context:
context = {}
for key,val in context.items(): for key,val in context.items():
if type(key) == type(True): if type(key) == type(True):
context.pop(key) context.pop(key)
@ -1186,6 +1200,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open Previous Answer form. @return : Dictionary value for Open Previous Answer form.
""" """
if not context:
context = {}
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz = self.pool.get('survey.name.wiz')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\ search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\
@ -1216,6 +1232,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open Next Answer form. @return : Dictionary value for Open Next Answer form.
""" """
if not context:
context = {}
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz = self.pool.get('survey.name.wiz')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\ search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\
@ -1246,6 +1264,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open Next survey.page form. @return : Dictionary value for Open Next survey.page form.
""" """
if not context:
context = {}
surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz = self.pool.get('survey.name.wiz')
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')]) search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),('name','=','Survey Search')])
@ -1271,6 +1291,8 @@ class survey_question_wiz(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for Open Previous survey.page form. @return : Dictionary value for Open Previous survey.page form.
""" """
if not context:
context = {}
surv_name_wiz = self.pool.get('survey.name.wiz') surv_name_wiz = self.pool.get('survey.name.wiz')
search_obj = self.pool.get('ir.ui.view') search_obj = self.pool.get('ir.ui.view')
search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\ search_id = search_obj.search(cr,uid,[('model','=','survey.question.wiz'),\

View File

@ -56,6 +56,8 @@ class survey_print(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for print survey form. @return : Dictionary value for print survey form.
""" """
if not context:
context = {}
datas = {'ids' : self.read(cr, uid, ids, [], context)[0]['survey_ids']} datas = {'ids' : self.read(cr, uid, ids, [], context)[0]['survey_ids']}
res = self.read(cr, uid, ids, ['survey_title', 'orientation', 'paper_size',\ res = self.read(cr, uid, ids, ['survey_title', 'orientation', 'paper_size',\

View File

@ -56,6 +56,8 @@ class survey_print_answer(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return : Dictionary value for created survey answer report @return : Dictionary value for created survey answer report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['response_ids', 'orientation', 'paper_size',\ res = self.read(cr, uid, ids, ['response_ids', 'orientation', 'paper_size',\
'page_number', 'without_pagebreak'], context) 'page_number', 'without_pagebreak'], context)

View File

@ -42,6 +42,8 @@ class survey_print_statistics(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return: Dictionary value for created survey statistics report @return: Dictionary value for created survey statistics report
""" """
if not context:
context = {}
datas = {'ids': context.get('active_ids', [])} datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['survey_ids'], context) res = self.read(cr, uid, ids, ['survey_ids'], context)
res = res and res[0] or {} res = res and res[0] or {}

View File

@ -60,11 +60,13 @@ class survey_send_invitation(osv.osv_memory):
return ''.join([choice(chars) for i in range(6)]) return ''.join([choice(chars) for i in range(6)])
def default_get(self, cr, uid, fields_list, context=None): def default_get(self, cr, uid, fields_list, context=None):
if not context:
context = {}
data = super(survey_send_invitation, self).default_get(cr, uid, fields_list, context) data = super(survey_send_invitation, self).default_get(cr, uid, fields_list, context)
survey_obj = self.pool.get('survey') survey_obj = self.pool.get('survey')
msg = "" msg = ""
name = "" name = ""
for sur in survey_obj.browse(cr, uid, context.get('active_ids', [])): for sur in survey_obj.browse(cr, uid, context.get('active_ids', []), context=context):
name += "\t --> " + sur.title + "\n" name += "\t --> " + sur.title + "\n"
if sur.state != 'open': if sur.state != 'open':
msg += sur.title + "\n" msg += sur.title + "\n"
@ -92,6 +94,8 @@ class survey_send_invitation(osv.osv_memory):
def action_send(self, cr, uid, ids, context=None): def action_send(self, cr, uid, ids, context=None):
if not context:
context = {}
record = self.read(cr, uid, ids, []) record = self.read(cr, uid, ids, [])
survey_ids = context.get('active_ids', []) survey_ids = context.get('active_ids', [])
record = record and record[0] record = record and record[0]
@ -220,6 +224,8 @@ class survey_send_invitation_log(osv.osv_memory):
} }
def default_get(self, cr, uid, fields_list, context=None): def default_get(self, cr, uid, fields_list, context=None):
if not context:
context = {}
data = super(survey_send_invitation_log, self).default_get(cr, uid, fields_list, context) data = super(survey_send_invitation_log, self).default_get(cr, uid, fields_list, context)
data['note'] = context.get('note', '') data['note'] = context.get('note', '')
return data return data

View File

@ -31,7 +31,9 @@ class thunderbird_installer(osv.osv_memory):
_name = 'thunderbird.installer' _name = 'thunderbird.installer'
_inherit = 'res.config.installer' _inherit = 'res.config.installer'
def default_get(self, cr, uid, fields, context={}): def default_get(self, cr, uid, fields, context=None):
if not context:
context = {}
data = super(thunderbird_installer, self).default_get(cr, uid, fields, context) data = super(thunderbird_installer, self).default_get(cr, uid, fields, context)
data['pdf_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_thunderbird.html' data['pdf_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_thunderbird.html'
file = open(addons.get_module_resource('thunderbird','plugin', 'openerp_plugin.xpi'),'rb') file = open(addons.get_module_resource('thunderbird','plugin', 'openerp_plugin.xpi'),'rb')

View File

@ -54,7 +54,7 @@ class wiki_group(osv.osv):
'method': lambda *a: 'page', 'method': lambda *a: 'page',
} }
def open_wiki_page(self, cr, uid, ids, context): def open_wiki_page(self, cr, uid, ids, context=None):
""" Opens Wiki Page of Group """ Opens Wiki Page of Group
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -131,7 +131,7 @@ class wiki_wiki2(osv.osv):
'minor_edit': lambda *a: True, 'minor_edit': lambda *a: True,
} }
def onchange_group_id(self, cr, uid, ids, group_id, content, context={}): def onchange_group_id(self, cr, uid, ids, group_id, content, context=None):
""" @param cr: the current row, from the database cursor, """ @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@ -140,7 +140,9 @@ class wiki_wiki2(osv.osv):
if (not group_id) or content: if (not group_id) or content:
return {} return {}
grp = self.pool.get('wiki.groups').browse(cr, uid, group_id) if not context:
context = {}
grp = self.pool.get('wiki.groups').browse(cr, uid, group_id, context=context)
section = '0' section = '0'
for page in grp.page_ids: for page in grp.page_ids:
if page.section: section = page.section if page.section: section = page.section
@ -164,6 +166,8 @@ class wiki_wiki2(osv.osv):
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param id: Give wiki page's ID """ @param id: Give wiki page's ID """
if not context:
context = {}
return super(wiki_wiki2, 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): def create_history(self, cr, uid, ids, vals, context=None):

View File

@ -31,7 +31,7 @@ class wiki_create_menu(osv.osv_memory):
'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True), 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
} }
def wiki_menu_create(self, cr, uid, ids, context): def wiki_menu_create(self, cr, uid, ids, context=None):
""" Create Menu On the base of Group id and Action id """ Create Menu On the base of Group id and Action id
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -39,6 +39,8 @@ class wiki_create_menu(osv.osv_memory):
@param ids: List of create menus IDs @param ids: List of create menus IDs
""" """
if not context:
context = {}
obj_wiki_group = self.pool.get('wiki.groups') obj_wiki_group = self.pool.get('wiki.groups')
obj_view = self.pool.get('ir.ui.view') obj_view = self.pool.get('ir.ui.view')
obj_menu = self.pool.get('ir.ui.menu') obj_menu = self.pool.get('ir.ui.menu')

View File

@ -27,7 +27,7 @@ class wiki_make_index(osv.osv_memory):
_name = "wiki.make.index" _name = "wiki.make.index"
_description = "Create Index" _description = "Create Index"
def wiki_do_index(self, cr, uid, ids, context): def wiki_do_index(self, cr, uid, ids, context=None):
""" Makes Index according to page hierarchy """ Makes Index according to page hierarchy
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -35,9 +35,11 @@ class wiki_make_index(osv.osv_memory):
@param ids: list of wiki indexs IDs @param ids: list of wiki indexs IDs
""" """
if not context:
context = {}
data = context and context.get('active_ids', []) or [] data = context and context.get('active_ids', []) or []
for index_obj in self.browse(cr, uid, ids): for index_obj in self.browse(cr, uid, ids, context=context):
wiki_pool = self.pool.get('wiki.wiki') wiki_pool = self.pool.get('wiki.wiki')
cr.execute("Select id, section from wiki_wiki where id IN %s \ cr.execute("Select id, section from wiki_wiki where id IN %s \
order by section ", (tuple(data),)) order by section ", (tuple(data),))

View File

@ -33,6 +33,8 @@ class showdiff(osv.osv_memory):
""" @param cr: the current row, from the database cursor, """ @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
""" """
if not context:
context = {}
history = self.pool.get('wiki.wiki.history') history = self.pool.get('wiki.wiki.history')
ids = context.get('active_ids', []) ids = context.get('active_ids', [])

View File

@ -27,7 +27,7 @@ class wiki_wiki_page_open(osv.osv_memory):
_name = "wiki.wiki.page.open" _name = "wiki.wiki.page.open"
_description = "wiz open page" _description = "wiz open page"
def open_wiki_page(self, cr, uid, ids, context): def open_wiki_page(self, cr, uid, ids, context=None):
""" Opens Wiki Page of Group """ Opens Wiki Page of Group
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -35,8 +35,10 @@ class wiki_wiki_page_open(osv.osv_memory):
@param ids: List of open wiki pages IDs @param ids: List of open wiki pages IDs
@return: dictionay of open wiki window on give group id @return: dictionay of open wiki window on give group id
""" """
if not context:
context = {}
group_ids = context.get('active_ids', []) group_ids = context.get('active_ids', [])
for group in self.pool.get('wiki.groups').browse(cr, uid, group_ids): for group in self.pool.get('wiki.groups').browse(cr, uid, group_ids, context=context):
value = { value = {
'domain': "[('group_id','=',%d)]" % (group.id), 'domain': "[('group_id','=',%d)]" % (group.id),
'name': 'Wiki Page', 'name': 'Wiki Page',