[FIX] all: update context_today calls after API change
authorOlivier Dony <odo@openerp.com>
Tue, 14 Feb 2012 12:25:20 +0000 (13:25 +0100)
committerOlivier Dony <odo@openerp.com>
Tue, 14 Feb 2012 12:25:20 +0000 (13:25 +0100)
See also server revision 4053
revision-id: odo@openerp.com-20120214122413-rznpdyqajrzswk4o

bzr revid: odo@openerp.com-20120214122520-f4lyaoolw1sik7zo

addons/account/account.py
addons/account/account_bank_statement.py
addons/account/account_invoice.py
addons/account_coda/wizard/account_coda_import.py
addons/crm_partner_assign/partner_geo_assign.py
addons/hr_timesheet/hr_timesheet.py
addons/point_of_sale/wizard/pos_return.py
addons/project_planning/project_planning.py
addons/purchase/purchase.py
addons/sale/sale.py
addons/sale_crm/wizard/crm_make_sale.py

index 215c5fe..a1c03db 100644 (file)
@@ -933,7 +933,7 @@ class account_fiscalyear(osv.osv):
                 if de.strftime('%Y-%m-%d') > fy.date_stop:
                     de = datetime.strptime(fy.date_stop, '%Y-%m-%d')
 
-                context_today = fields.date.context_today(cr,uid,context=context)
+                context_today = fields.date.context_today(self,cr,uid,context=context)
                 period_obj.create(cr, uid, {
                     'name': ds.strftime('%m/%Y'),
                     'code': ds.strftime('%m/%Y'),
@@ -951,7 +951,7 @@ class account_fiscalyear(osv.osv):
     def finds(self, cr, uid, dt=None, exception=True, context=None):
         if context is None: context = {}
         if not dt:
-            dt = fields.date.context_today(cr,uid,context=context)
+            dt = fields.date.context_today(self,cr,uid,context=context)
         args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)]
         if context.get('company_id', False):
             args.append(('company_id', '=', context['company_id']))
@@ -1040,7 +1040,7 @@ class account_period(osv.osv):
     def find(self, cr, uid, dt=None, context=None):
         if context is None: context = {}
         if not dt:
-            dt = fields.date.context_today(cr,uid,context=context)
+            dt = fields.date.context_today(self,cr,uid,context=context)
 #CHECKME: shouldn't we check the state of the period?
         args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)]
         if context.get('company_id', False):
@@ -2270,7 +2270,7 @@ class account_model(osv.osv):
                 'ref': entry['name'],
                 'period_id': period_id,
                 'journal_id': model.journal_id.id,
-                'date': context.get('date', fields.date.context_today(cr,uid,context=context))
+                'date': context.get('date', fields.date.context_today(self,cr,uid,context=context))
             })
             move_ids.append(move_id)
             for line in model.lines_id:
@@ -2307,7 +2307,7 @@ class account_model(osv.osv):
                     'account_id': line.account_id.id,
                     'move_id': move_id,
                     'partner_id': line.partner_id.id,
-                    'date': context.get('date', fields.date.context_today(cr,uid,context=context)),
+                    'date': context.get('date', fields.date.context_today(self,cr,uid,context=context)),
                     'date_maturity': date_maturity
                 })
                 account_move_line_obj.create(cr, uid, val, context=ctx)
index 7f09cc7..6a2bf7f 100644 (file)
@@ -483,7 +483,7 @@ class account_bank_statement_line(osv.osv):
     }
     _defaults = {
         'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
-        'date': lambda self,cr,uid,context={}: context.get('date', fields.date.context_today(cr,uid,context=context)),
+        'date': lambda self,cr,uid,context={}: context.get('date', fields.date.context_today(self,cr,uid,context=context)),
         'type': 'general',
     }
 
index bcc8b69..32864f9 100644 (file)
@@ -814,7 +814,7 @@ class account_invoice(osv.osv):
             ctx = context.copy()
             ctx.update({'lang': inv.partner_id.lang})
             if not inv.date_invoice:
-                self.write(cr, uid, [inv.id], {'date_invoice': fields.date.context_today(cr,uid,context=context)}, context=ctx)
+                self.write(cr, uid, [inv.id], {'date_invoice': fields.date.context_today(self,cr,uid,context=context)}, context=ctx)
             company_currency = inv.company_id.currency_id.id
             # create the analytical lines
             # one move line per invoice line
index d780c2d..c49eb9f 100644 (file)
@@ -567,7 +567,7 @@ class account_coda_import(osv.osv_memory):
                 'name' : codafilename,
                 'coda_data': codafile,
                 'coda_creation_date' : coda_statement['date'],
-                'date': fields.date.context_today(cr, uid, context=context),
+                'date': fields.date.context_today(self, cr, uid, context=context),
                 'user_id': uid,
                 })
             context.update({'coda_id': coda_id})
index 48b5427..f522cc6 100644 (file)
@@ -102,7 +102,7 @@ class res_partner(osv.osv):
                 self.write(cr, uid, [partner.id], {
                     'partner_latitude': result[0],
                     'partner_longitude': result[1],
-                    'date_localization': fields.date.context_today(cr,uid,context=context)
+                    'date_localization': fields.date.context_today(self,cr,uid,context=context)
                 }, context=context)
         return True
 res_partner()
@@ -128,7 +128,7 @@ class crm_lead(osv.osv):
             partners = self.pool.get('res.partner').browse(cr, uid, [partner_assigned_id], context=context)
             user_id = partners[0] and partners[0].user_id.id or False
             return {'value':
-                        {'date_assign': fields.date.context_today(cr,uid,context=context),
+                        {'date_assign': fields.date.context_today(self,cr,uid,context=context),
                          'user_id' : user_id}
                    }
 
@@ -151,7 +151,7 @@ class crm_lead(osv.osv):
             if partner.user_id:
                 for lead_id in ids:
                     self.allocate_salesman(cr, uid, [lead_id], [partner.user_id.id], context=context)
-            self.write(cr, uid, [lead.id], {'date_assign': fields.date.context_today(cr,uid,context=context), 'partner_assigned_id': partner_id}, context=context)
+            self.write(cr, uid, [lead.id], {'date_assign': fields.date.context_today(self,cr,uid,context=context), 'partner_assigned_id': partner_id}, context=context)
         return res
 
 
index 82163f7..1e15e5b 100644 (file)
@@ -149,7 +149,7 @@ class hr_analytic_timesheet(osv.osv):
         'product_id': _getEmployeeProduct,
         'general_account_id': _getGeneralAccount,
         'journal_id': _getAnalyticJournal,
-        'date': lambda self, cr, uid, ctx: ctx.get('date', fields.date.context_today(cr,uid,context=ctx)),
+        'date': lambda self, cr, uid, ctx: ctx.get('date', fields.date.context_today(self,cr,uid,context=ctx)),
         'user_id': lambda obj, cr, uid, ctx: ctx.get('user_id', uid),
     }
     def on_change_account_id(self, cr, uid, ids, account_id):
index cc9f294..30b16a7 100644 (file)
@@ -151,7 +151,7 @@ class pos_return(osv.osv_memory):
                                                 'name': 'Refund %s'%order_id.name,
                                                 'statement_id': order_id.statement_ids[0].statement_id.id,
                                                 'pos_statement_id': new_order,
-                                                'date': fields.date.context_today(cr, uid, context=context),
+                                                'date': fields.date.context_today(self, cr, uid, context=context),
                                                 'account_id': order_id.partner_id and order_id.partner_id.property_account_payable \
                                                              and order_id.partner_id.property_account_payable.id or account_def.id,
                                                 'amount': -amount,
index 5f9d33f..fafaf85 100644 (file)
@@ -136,8 +136,8 @@ class report_account_analytic_planning(osv.osv):
         'total_free': fields.function(_get_total_free, string='Total Free'),
     }
     _defaults = {
-        'date_from': lambda self,cr,uid,ctx: fields.date.context_today(cr,uid,timestamp=(datetime.now()+relativedelta(day=1)),context=ctx),
-        'date_to': lambda self,cr,uid,ctx: fields.date.context_today(cr,uid,timestamp=(datetime.now()+relativedelta(months=1, day=1, days=-1)),context=ctx),
+        'date_from': lambda self,cr,uid,ctx: fields.date.context_today(self,cr,uid,timestamp=(datetime.now()+relativedelta(day=1)),context=ctx),
+        'date_to': lambda self,cr,uid,ctx: fields.date.context_today(self,cr,uid,timestamp=(datetime.now()+relativedelta(months=1, day=1, days=-1)),context=ctx),
         'user_id': lambda self, cr, uid, c: uid,
         'state': 'draft',
         'business_days': 20,
index deabf18..5432067 100644 (file)
@@ -274,7 +274,7 @@ class purchase_order(osv.osv):
         return {'value':{'partner_address_id': supplier_address['default'], 'pricelist_id': pricelist, 'fiscal_position': fiscal_position}}
 
     def wkf_approve_order(self, cr, uid, ids, context=None):
-        self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(cr,uid,context=context)})
+        self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)})
         return True
 
     #TODO: implement messages system
index ccdae77..d2f3ffd 100644 (file)
@@ -631,9 +631,9 @@ class sale_order(osv.osv):
             if not o.order_line:
                 raise osv.except_osv(_('Error !'),_('You cannot confirm a sale order which has no line.'))
             if (o.order_policy == 'manual'):
-                self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': fields.date.context_today(cr, uid, context=context)})
+                self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
             else:
-                self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': fields.date.context_today(cr, uid, context=context)})
+                self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
             self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line])
             message = _("The quotation '%s' has been converted to a sales order.") % (o.name,)
             self.log(cr, uid, o.id, message)
index 2730967..c3515cc 100644 (file)
@@ -97,7 +97,7 @@ class crm_make_sale(osv.osv_memory):
                     'partner_invoice_id': partner_addr['invoice'],
                     'partner_order_id': partner_addr['contact'],
                     'partner_shipping_id': partner_addr['delivery'],
-                    'date_order': fields.date.context_today(cr,uid,context=context),
+                    'date_order': fields.date.context_today(self,cr,uid,context=context),
                     'fiscal_position': fpos,
                 }
                 if partner.id: