59
59
Launch analytic distribution wizard from a statement line
63
64
if isinstance(ids, (int, long)):
65
# we get the analytical distribution object linked to this line
67
statement_line_obj = self.browse(cr, uid, ids[0], context=context)
68
amount = statement_line_obj.amount * -1 or 0.0
67
absl = self.browse(cr, uid, ids[0], context=context)
68
amount = absl.amount * -1 or 0.0
69
69
# Search elements for currency
70
70
company_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
71
currency = statement_line_obj.statement_id.journal_id.currency and statement_line_obj.statement_id.journal_id.currency.id or company_currency
72
if statement_line_obj.analytic_distribution_id:
73
distrib_id = statement_line_obj.analytic_distribution_id.id
75
distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {}, context=context)
76
newvals={'analytic_distribution_id': distrib_id}
77
super(account_bank_statement_line, self).write(cr, uid, ids, newvals, context=context)
78
wiz_obj = self.pool.get('wizard.costcenter.distribution')
79
wiz_id = wiz_obj.create(cr, uid, {'total_amount': amount, 'distribution_id': distrib_id, 'currency_id': currency}, context=context)
71
currency = absl.statement_id.journal_id.currency and absl.statement_id.journal_id.currency.id or company_currency
72
# Get analytic distribution id from this line
73
distrib_id = absl.analytic_distribution_id and absl.analytic_distribution_id.id or False
74
# Prepare values for wizard
76
'total_amount': amount,
77
'register_line_id': absl.id,
78
'currency_id': currency or False,
80
'account_id': absl.account_id and absl.account_id.id or False,
83
vals.update({'distribution_id': distrib_id,})
85
wiz_obj = self.pool.get('analytic.distribution.wizard')
86
wiz_id = wiz_obj.create(cr, uid, vals, context=context)
87
# Update some context values
82
89
'active_id': ids[0],
84
'wizard_ids': {'cost_center': wiz_id},
87
94
'type': 'ir.actions.act_window',
88
'res_model': 'wizard.costcenter.distribution',
95
'res_model': 'analytic.distribution.wizard',
89
96
'view_type': 'form',
90
97
'view_mode': 'form',