~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to analytic_distribution_supply/purchase.py

  • Committer: jf
  • Date: 2012-03-27 14:38:50 UTC
  • Revision ID: jf@tempo4-20120327143850-e41gh5zyjam3un11
[FIX] Default values

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
            self.pool.get('account.invoice').fetch_analytic_distribution(cr, uid, [x.id for x in po.invoice_ids])
65
65
        return res
66
66
 
67
 
    def button_analytic_distribution(self, cr, uid, ids, context={}):
 
67
    def button_analytic_distribution(self, cr, uid, ids, context=None):
68
68
        """
69
69
        Launch analytic distribution wizard on a purchase order
70
70
        """
109
109
                'context': context,
110
110
        }
111
111
 
112
 
    def copy_data(self, cr, uid, id, default={}, context={}):
 
112
    def copy_data(self, cr, uid, id, default=None, context=None):
113
113
        """
114
114
        Copy global distribution and give it to new purchase.
115
115
        Delete commitment_ids link.
117
117
        # Some verifications
118
118
        if not context:
119
119
            context = {}
 
120
        if not default:
 
121
            default = {}
120
122
        # Update default
121
123
        default.update({'commitment_ids': False,})
122
124
        # Default method
130
132
                self.write(cr, uid, [res], {'analytic_distribution_id': new_distrib_id}, context=context)
131
133
        return res
132
134
 
133
 
    def action_create_commitment(self, cr, uid, ids, type=False, context={}):
 
135
    def action_create_commitment(self, cr, uid, ids, type=False, context=None):
134
136
        """
135
137
        Create commitment from given PO, but only for external and esc partner_types
136
138
        """
213
215
            self.pool.get('account.commitment').log(cr, uid, commit_id, message, context={'view_id': view_id})
214
216
        return True
215
217
 
216
 
    def wkf_approve_order(self, cr, uid, ids, context={}):
 
218
    def wkf_approve_order(self, cr, uid, ids, context=None):
217
219
        """
218
220
        Checks:
219
221
        1/ if all purchase line could take an analytic distribution
241
243
                self.action_create_commitment(cr, uid, [po.id], po.partner_id and po.partner_id.partner_type, context=context)
242
244
        return res
243
245
 
244
 
    def _finish_commitment(self, cr, uid, ids, context={}):
 
246
    def _finish_commitment(self, cr, uid, ids, context=None):
245
247
        """
246
248
        Change commitment(s) to Done state from given Purchase Order.
247
249
        """
257
259
                self.pool.get('account.commitment').action_commitment_done(cr, uid, [x.id for x in po.commitment_ids], context=context)
258
260
        return True
259
261
 
260
 
    def action_cancel(self, cr, uid, ids, context={}):
 
262
    def action_cancel(self, cr, uid, ids, context=None):
261
263
        """
262
264
        Delete commitment from purchase before 'cancel' state.
263
265
        """
270
272
        self._finish_commitment(cr, uid, ids, context=context)
271
273
        return super(purchase_order, self).action_cancel(cr, uid, ids, context=context)
272
274
 
273
 
    def action_done(self, cr, uid, ids, context={}):
 
275
    def action_done(self, cr, uid, ids, context=None):
274
276
        """
275
277
        Delete commitment from purchase before 'done' state.
276
278
        """
299
301
    _name = 'purchase.order.line'
300
302
    _inherit = 'purchase.order.line'
301
303
 
302
 
    def _have_analytic_distribution_from_header(self, cr, uid, ids, name, arg, context={}):
 
304
    def _have_analytic_distribution_from_header(self, cr, uid, ids, name, arg, context=None):
303
305
        if isinstance(ids, (int, long)):
304
306
            ids = [ids]
305
307
        res = {}
320
322
    _defaults = {
321
323
        'have_analytic_distribution_from_header': lambda *a: True,
322
324
    }
323
 
    def button_analytic_distribution(self, cr, uid, ids, context={}):
 
325
    def button_analytic_distribution(self, cr, uid, ids, context=None):
324
326
        """
325
327
        Launch analytic distribution wizard on a purchase order
326
328
        """
365
367
                'context': context,
366
368
        }
367
369
 
368
 
    def copy_data(self, cr, uid, id, default={}, context={}):
 
370
    def copy_data(self, cr, uid, id, default=None, context=None):
369
371
        """
370
372
        Copy global distribution and give it to new purchase line
371
373
        Copy global distribution and give it to new purchase line.
373
375
        # Some verifications
374
376
        if not context:
375
377
            context = {}
 
378
        if not default:
 
379
            default = {}
376
380
        # Update default
377
381
        default.update({'commitment_line_ids': [(6, 0, [])],})
378
382
        # Copy analytic distribution