Skip to content

Commit

Permalink
Context better user
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo committed Dec 27, 2015
1 parent 2388de5 commit 420843e
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 47 deletions.
29 changes: 16 additions & 13 deletions account_fiscal_year_closing/fyc.py
Expand Up @@ -404,13 +404,13 @@ def action_draft(self, cr, uid, ids, context=None):
"""

if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
#
# Make sure the lang is defined on the context
#
user = self.pool.get('res.users').browse(cr, uid, uid, context)
#for 7.0## context['lang'] = context.get('lang') or user.lang
context['lang'] = context.get('lang') or user.context_lang
# user = self.pool.get('res.users').browse(cr, uid, uid, context)
# #for 7.0## context['lang'] = context.get('lang') or user.lang
# context['lang'] = context.get('lang') or user.context_lang

for fyc in self.browse(cr, uid, ids, context):
#
Expand Down Expand Up @@ -508,13 +508,13 @@ def action_confirm(self, cr, uid, ids, context=None):
Called when the user clicks the confirm button.
"""
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
#
# Make sure the lang is defined on the context
#
user = self.pool.get('res.users').browse(cr, uid, uid, context)
#for 7.0###context['lang'] = context.get('lang') or user.lang
context['lang'] = context.get('lang') or user.context_lang
# user = self.pool.get('res.users').browse(cr, uid, uid, context)
# #for 7.0###context['lang'] = context.get('lang') or user.lang
# context['lang'] = context.get('lang') or user.context_lang

for fyc in self.browse(cr, uid, ids, context):
#
Expand Down Expand Up @@ -608,13 +608,13 @@ def action_cancel(self, cr, uid, ids, context=None):
Called when the user clicks the cancel button.
"""
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
#
# Make sure the lang is defined on the context
#
user = self.pool.get('res.users').browse(cr, uid, uid, context)
#for 7.0###context['lang'] = context.get('lang') or user.lang
context['lang'] = context.get('lang') or user.context_lang
# user = self.pool.get('res.users').browse(cr, uid, uid, context)
# #for 7.0###context['lang'] = context.get('lang') or user.lang
# context['lang'] = context.get('lang') or user.context_lang
#
# Uncheck all the operations
#
Expand Down Expand Up @@ -681,7 +681,10 @@ def action_recover(self, cr, uid, ids, context=None):
Called when the user clicks the draft button to create
a new workflow instance.
"""
self.write(cr, uid, ids, {'state': 'new'})
if not context:
context = self.pool['res.users'].context_get(cr, uid)

self.write(cr, uid, ids, {'state': 'new'}, context)
wf_service = netsvc.LocalService("workflow")
for item_id in ids:
wf_service.trg_create(uid, 'account_fiscal_year_closing.fyc', item_id, cr)
Expand Down
21 changes: 9 additions & 12 deletions account_invoice_reopen/account_invoice.py
Expand Up @@ -120,14 +120,14 @@ def action_reopen(self, cr, uid, ids, *args):
# attachment_obj.write(cr, uid, a.id, vals)

# unset set the invoices move_id
self.write(cr, uid, ids, {'move_id': False})
self.write(cr, uid, ids, {'move_id': False}, context)

if move_ids:

for move in account_move_obj.browse(cr, uid, move_ids):
for move in account_move_obj.browse(cr, uid, move_ids, context):
name = move.name + now
account_move_obj.write(cr, uid, [move.id], {'name': name})
_logger.debug('FGF reopen move_copy moveid %s' % (move.id))
_logger.debug('FGF reopen move_copy moveid %s' % move.id)
if move.journal_id.entry_posted:
raise orm.except_orm(_('Error !'),
_('You can not reopen an invoice if the journal is set to skip draft!'))
Expand All @@ -137,21 +137,21 @@ def action_reopen(self, cr, uid, ids, *args):
cr.execute("""update account_move_line
set debit=credit, credit=debit, tax_amount= -tax_amount
where move_id = %s;""" % move_copy_id)
account_move_obj.write(cr, uid, [move_copy_id], {'name': name})
account_move_obj.write(cr, uid, [move_copy_id], {'name': name}, context)
_logger.debug('FGF reopen move_copy_id validate')
account_move_obj.button_validate(cr, uid, [move_copy_id], context=None)
account_move_obj.button_validate(cr, uid, [move_copy_id], context=context)
_logger.debug('FGF reopen move_copy_id validated')
# reconcile
r_id = self.pool.get('account.move.reconcile').create(cr, uid, {'type': 'auto'})
r_id = self.pool.get('account.move.reconcile').create(cr, uid, {'type': 'auto'}, context)
_logger.debug('FGF reopen reconcile_id %s' % r_id)
line_ids = account_move_line_obj.search(cr, uid, [('move_id', 'in', [move_copy_id, move.id])])
line_ids = account_move_line_obj.search(cr, uid, [('move_id', 'in', [move_copy_id, move.id])], context=context)
_logger.debug('FGF reopen reconcile_line_ids %s' % line_ids)
lines_to_reconile = []
for ltr in account_move_line_obj.browse(cr, uid, line_ids):
for ltr in account_move_line_obj.browse(cr, uid, line_ids, context):
if ltr.account_id.id in (
ltr.partner_id.property_account_payable.id, ltr.partner_id.property_account_receivable.id):
lines_to_reconile.append(ltr.id)
account_move_line_obj.write(cr, uid, lines_to_reconile, {'reconcile_id': r_id})
account_move_line_obj.write(cr, uid, lines_to_reconile, {'reconcile_id': r_id}, context)

self._log_event(cr, uid, ids, -1.0, 'Reopened Invoice')

Expand All @@ -173,6 +173,3 @@ def action_number(self, cr, uid, ids, context=None):
if not inv.internal_number:
super(account_invoice, self).action_number(cr, uid, ids, context)
return True


account_invoice()
2 changes: 1 addition & 1 deletion account_invoice_template/wizard/select_template.py
Expand Up @@ -80,7 +80,7 @@ def load_lines(self, cr, uid, ids, context=None):

def load_template(self, cr, uid, ids, context=None):
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
template_obj = self.pool['account.invoice.template']
account_invoice_obj = self.pool['account.invoice']
account_invoice_line_obj = self.pool['account.invoice.line']
Expand Down
2 changes: 1 addition & 1 deletion account_journal_report_xls/report/nov_account_journal.py
Expand Up @@ -65,7 +65,7 @@ def set_context(self, objects, data, ids, report_type=None):

def __init__(self, cr, uid, name, context):
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
super(nov_journal_print, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
Expand Down
Expand Up @@ -80,7 +80,7 @@ def find_period(self, date, context=None):

def __init__(self, cr, uid, name, context=None):
if context is None:
context = self.pool['res.users'].context_get(self.cr, self.uid)
context = self.pool['res.users'].context_get(self.cr, self.uid)
super(print_vat_period_end_statement, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
Expand Down
2 changes: 1 addition & 1 deletion base_address_contacts/res_partner_address.py
Expand Up @@ -181,7 +181,7 @@ def name_get(self, cr, uid, ids, context=None):
return []
res = []
if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
length = context.get('name_lenght', False) or 80
for record in self.browse(cr, uid, ids, context=context):
name = record.complete_name or record.name or ''
Expand Down
2 changes: 1 addition & 1 deletion crm_lead_correct/wizard/mail_compose_message.py
Expand Up @@ -34,7 +34,7 @@ class mail_compose_message(orm.TransientModel):
def default_get(self, cr, uid, fields, context=None):

if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
result = super(mail_compose_message, self).default_get(cr, uid, fields, context=context)

# link to model and record if not done yet
Expand Down
2 changes: 1 addition & 1 deletion data_migration/wizard/sale_order_state.py
Expand Up @@ -36,7 +36,7 @@ class sale_order_cancel(orm.TransientModel):

def order_cancel(self, cr, uid, ids, context=None):
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)

sale_orders = self.pool['sale.order'].browse(cr, uid, context['active_ids'], context=context)

Expand Down
4 changes: 2 additions & 2 deletions dt_product_serial/wizard/stock_move.py
Expand Up @@ -44,7 +44,7 @@ class split_in_production_lot(orm.TransientModel):
def split_lot_serial(self, cr, uid, ids, context=None):
""" To split a lot"""
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
res = self.split_serial(cr, uid, ids, context.get('active_ids'), context=context)
return {'type': 'ir.actions.act_window_close'}

Expand All @@ -54,7 +54,7 @@ def split_serial(self, cr, uid, ids, move_ids, context=None):
:param move_ids: the ID or list of IDs of stock move we want to split
"""
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
assert context.get('active_model') == 'stock.move',\
'Incorrect use of the stock move split wizard'

Expand Down
4 changes: 2 additions & 2 deletions material_asset/asset.py
Expand Up @@ -329,7 +329,7 @@ class asset_product(orm.Model):
def _product_code(self, cr, uid, ids, name, arg, context=None):
res = {}
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
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=context)['code']
return res
Expand All @@ -345,7 +345,7 @@ def _product_code(self, cr, uid, ids, name, arg, context=None):
def onchange_category_id(self, cr, uid, ids, asset_category_id, context=None):
has_date_option = False
if asset_category_id:
category_id_obj = self.pool.get('asset.category')
category_id_obj = self.pool['asset.category']
category_type = category_id_obj.browse(cr, uid, [asset_category_id], context)
if category_type and category_type[0].has_date_option:
has_date_option = True
Expand Down
4 changes: 2 additions & 2 deletions material_asset/stock.py
Expand Up @@ -69,7 +69,7 @@ def action_done(self, cr, uid, ids, context=None):

def create_asset(self, cr, uid, ids, context):
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
for move in self.browse(cr, uid, ids, context=context):

if not move.prodlot_id.id and move.location_dest_id.usage == 'assets':
Expand All @@ -78,7 +78,7 @@ def create_asset(self, cr, uid, ids, context):
prodlot_id = move.prodlot_id.id

# verify that product is not yet an asset:
asset_product_ids = self.pool.get('asset.product').search(cr, uid, [('product_product_id', '=', move.product_id.id), ])
asset_product_ids = self.pool['asset.product'].search(cr, uid, [('product_product_id', '=', move.product_id.id), ], context=context)
if move.location_dest_id.usage == 'assets' and not asset_product_ids:
# Launch a form and ask about category:
assign_category_id = self.pool["asset.assign.category"].create(cr, uid, {}, context=dict(context, active_ids=ids))
Expand Down
2 changes: 1 addition & 1 deletion purchase_discount/purchase_discount.py
Expand Up @@ -68,7 +68,7 @@ def get_real_price(res_dict, product_id, qty, uom, pricelist):
return price * factor

if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)

res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order, fiscal_position_id, date_planned,
Expand Down
2 changes: 1 addition & 1 deletion sale_commission/sale_order.py
Expand Up @@ -229,7 +229,7 @@ def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, cont
line_agent_id = self._create_invoice_line_agent(cr, uid, [], l_comm.agent_id.id,
l_comm.commission_id.id)
list_ids.append(line_agent_id)
res['commission_ids'] = [(6, 0, list_ids)]
# res['commission_ids'] = [(6, 0, list_ids)]
return res

def _create_line_commission(self, cr, uid, ids, agent_id, commission_id):
Expand Down
2 changes: 1 addition & 1 deletion sale_order_confirm/wizard/sale_make_invoice_advance.py
Expand Up @@ -36,7 +36,7 @@ def default_get(self, cr, uid, fields, context=None):
@return: A dictionary which of fields with values.
"""
if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
res = super(sale_advance_payment_inv, self).default_get(cr, uid, fields, context=context)
if not res.get('product_id', False):
product_id = self.pool['res.users'].browse(cr, uid, uid, context).company_id.default_property_advance_product_id.id
Expand Down
2 changes: 1 addition & 1 deletion sale_order_price_recalculation/models/sale_order.py
Expand Up @@ -37,7 +37,7 @@ def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context

def recalculate_prices(self, cr, uid, ids, context=None):
if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
for sale in self.browse(cr, uid, ids, context):
for line in sale.order_line:
order = line.order_id
Expand Down
2 changes: 1 addition & 1 deletion sale_order_version/sale.py
Expand Up @@ -53,7 +53,7 @@ def action_previous_version(self, cr, uid, ids, default=None, context=None):
default = {}

if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)

attachment_obj = self.pool['ir.attachment']

Expand Down
4 changes: 2 additions & 2 deletions sale_subscriptions/models/sale.py
Expand Up @@ -47,7 +47,7 @@ def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
order_obj = self.pool['sale.order']
res = {}
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
for line in self.browse(cr, uid, ids, context=context):
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
Expand Down Expand Up @@ -579,7 +579,7 @@ def get_invoice_dates(self, cr, uid, order_id, context):

def auto_invoice(self, cr, uid, ids, context=None):
if context is None:
context = {}
context = self.pool['res.users'].context_get(cr, uid)

if not ids:
return False
Expand Down
4 changes: 2 additions & 2 deletions stock_picking_extended/sale/sale.py
Expand Up @@ -143,7 +143,7 @@ def _prepare_order_picking(self, cr, uid, order, context=None):

def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
# adaptative function: the system learn

if not isinstance(ids, (list, tuple)):
Expand All @@ -163,7 +163,7 @@ def write(self, cr, uid, ids, vals, context=None):

def create(self, cr, uid, vals, context=None):
if not context:
context = {}
context = self.pool['res.users'].context_get(cr, uid)
# adaptative function: the system learn
sale_order_id = super(sale_order, self).create(cr, uid, vals, context=context)
# create function return only 1 id
Expand Down
2 changes: 1 addition & 1 deletion stock_picking_extended/stock/picking_view.xml
Expand Up @@ -9,7 +9,7 @@
<field name="priority">1</field>
<field name="arch" type="xml">
<field name="carrier_id" position="before">
<field name="address_delivery_id" context="{'name_lenght': '80'}" colspan="6" />
<field name="address_delivery_id" context="{'name_lenght': '180'}" colspan="6" />
<field name="goods_description_id" widget="selection"/>
<field name="carriage_condition_id" widget="selection"/>
<field name="transportation_condition_id" widget="selection"/>
Expand Down

0 comments on commit 420843e

Please sign in to comment.