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

« back to all changes in this revision

Viewing changes to analytic_distribution/wizard/analytic_distribution_wizard.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:
32
32
    _name = 'analytic.distribution.wizard.lines'
33
33
    _description = 'analytic.distribution.wizard.lines'
34
34
 
35
 
    def _get_amount(self, cr, uid, ids, name, args, context={}):
 
35
    def _get_amount(self, cr, uid, ids, name, args, context=None):
36
36
        """
37
37
        Give amount regarding percentage and wizard's total_amount
38
38
        """
63
63
            #+ to construct object research !
64
64
    }
65
65
 
66
 
    def default_get(self, cr, uid, fields, context={}):
 
66
    def default_get(self, cr, uid, fields, context=None):
67
67
        """
68
68
        Verify that percentage or amount are correctly set
69
69
        """
86
86
                res['percentage'] = (amount / total_amount) * 100.0
87
87
        return res
88
88
 
89
 
    def _get_remaining_allocation(self, cr, uid, context={}):
 
89
    def _get_remaining_allocation(self, cr, uid, context=None):
90
90
        """
91
91
        Get remaining allocation for this object
92
92
        """
93
93
        # Some verifications
 
94
        if context is None:
 
95
            context = {}
94
96
        id = None
95
97
        mode = None
96
98
        if context and context.get('parent_id', False):
224
226
            view['arch'] = etree.tostring(tree)
225
227
        return view
226
228
 
227
 
    def verify_analytic_account(self, cr, uid, vals, line_type=None, context={}):
 
229
    def verify_analytic_account(self, cr, uid, vals, line_type=None, context=None):
228
230
        """
229
231
        Verify that analytic account match with line_type
230
232
        """
257
259
                    raise osv.except_osv(_('Error'), _("Choosen cost center '%s' is not from OC Category.") % (cc.name,))
258
260
        return True
259
261
 
260
 
    def create(self, cr, uid, vals, context={}):
 
262
    def create(self, cr, uid, vals, context=None):
261
263
        """
262
264
        Calculate amount and percentage regarding context content
263
265
        """
278
280
            self.pool.get('analytic.distribution.wizard').validate(cr, uid, vals.get('wizard_id'), context=context)
279
281
        return res
280
282
 
281
 
    def write(self, cr, uid, ids, vals, context={}):
 
283
    def write(self, cr, uid, ids, vals, context=None):
282
284
        """
283
285
        Calculate amount and percentage regarding context content
284
286
        """
346
348
    _name = 'analytic.distribution.wizard'
347
349
    _description = 'analytic.distribution.wizard'
348
350
 
349
 
    def _is_writable(self, cr, uid, ids, name, args, context={}):
 
351
    def _is_writable(self, cr, uid, ids, name, args, context=None):
350
352
        """
351
353
        Give possibility to write or not on this wizard
352
354
        """
 
355
        if context is None:
 
356
            context = {}
353
357
        # Prepare some values
354
358
        res = {}
355
359
        # Browse all given wizard
378
382
                res[el.id] = False
379
383
        return res
380
384
 
381
 
    def _have_header(self, cr, uid, ids, name, args, context={}):
 
385
    def _have_header(self, cr, uid, ids, name, args, context=None):
382
386
        """
383
387
        Return true if this wizard is on a line and if the parent has a distrib
384
388
        """
439
443
        'entry_mode': lambda *a: 'percentage',
440
444
    }
441
445
 
442
 
    def dummy(self, cr, uid, ids, context={}, *args, **kwargs):
 
446
    def dummy(self, cr, uid, ids, context=None, *args, **kwargs):
443
447
        """
444
448
        Change entry mode
445
449
        """
 
450
        if context is None:
 
451
            context = {}
446
452
        mode = self.read(cr, uid, ids, ['entry_mode'])[0]['entry_mode']
447
453
        self.write(cr, uid, [ids[0]], {'entry_mode': mode=='percentage' and 'amount' or 'percentage'})
448
454
        return {
455
461
                'context': context,
456
462
        }
457
463
 
458
 
    def _get_lines_from_distribution(self, cr, uid, ids, distrib_id=None, context={}):
 
464
    def _get_lines_from_distribution(self, cr, uid, ids, distrib_id=None, context=None):
459
465
        """
460
466
        Get lines from a distribution and copy them to the wizard
461
467
        """
516
522
                                self.pool.get(wiz_line_obj).create(cr, uid, vals, context=context)
517
523
            return True
518
524
 
519
 
    def create(self, cr, uid, vals, context={}):
 
525
    def create(self, cr, uid, vals, context=None):
520
526
        """
521
527
        Add distribution lines to the wizard
522
528
        """
531
537
            self._get_lines_from_distribution(cr, uid, [wiz.id], wiz.distribution_id.id, context=context)
532
538
        return res
533
539
 
534
 
    def wizard_verifications(self, cr, uid, ids, context={}):
 
540
    def wizard_verifications(self, cr, uid, ids, context=None):
535
541
        """
536
542
        Do some verifications on wizard:
537
543
         - Raise an exception if we come from a purchase order that have been approved
595
601
                    raise osv.except_osv(_('Warning'), _('Allocation is not fully done for %s') % type_name)
596
602
            return True
597
603
 
598
 
    def update_cost_center_lines(self, cr, uid, wizard_id, context={}):
 
604
    def update_cost_center_lines(self, cr, uid, wizard_id, context=None):
599
605
        """
600
606
        Update cost_center_lines from wizard regarding funding pool lines
601
607
        """
641
647
                cc_obj.unlink(cr, uid, [line_id], context=context)
642
648
        return True
643
649
 
644
 
    def compare_and_write_modifications(self, cr, uid, wizard_id, line_type=False, context={}):
 
650
    def compare_and_write_modifications(self, cr, uid, wizard_id, line_type=False, context=None):
645
651
        """
646
652
        Compare wizard lines to database lines and write modifications done
647
653
        """
719
725
                line_obj.unlink(cr, uid, id, context=context)
720
726
        return True
721
727
 
722
 
    def button_confirm(self, cr, uid, ids, context={}):
 
728
    def button_confirm(self, cr, uid, ids, context=None):
723
729
        """
724
730
        Calculate total of lines and verify that it's equal to total_amount
725
731
        """
826
832
                context={'skip_validation': True})
827
833
        return True
828
834
 
829
 
    def button_get_header_distribution(self, cr, uid, ids, context={}):
 
835
    def button_get_header_distribution(self, cr, uid, ids, context=None):
830
836
        """
831
837
        Get distribution from invoice or purchase
832
838
        """
869
875
                'context': context,
870
876
        }
871
877
 
872
 
    def button_cancel(self, cr, uid, ids, context={}):
 
878
    def button_cancel(self, cr, uid, ids, context=None):
873
879
        """
874
880
        Close the wizard or return on Direct Invoice wizard if we come from this one.
875
881
        """
906
912
                }
907
913
        return {'type' : 'ir.actions.act_window_close'}
908
914
 
909
 
    def update_analytic_lines(self, cr, uid, ids, context={}):
 
915
    def update_analytic_lines(self, cr, uid, ids, context=None):
910
916
        """
911
917
        Update analytic lines with an ugly method: delete old lines and create new ones
912
918
        """