43
42
# Return nothing if no 'output_currency_id' in context
44
43
if not context or not context.get('output_currency_id', False):
46
res[o_id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
45
res[id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
48
47
# Retrieve currency
49
48
currency_id = context.get('output_currency_id')
51
50
rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False)
55
res[out_id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
54
res[id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
57
56
for ml in self.browse(cr, uid, ids, context=context):
58
57
res[ml.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
71
70
res[ml.id]['output_currency'] = currency_id
74
def _get_cheque_number(self, cr, uid, ids, name, args, context=None):
78
if isinstance(ids, (int, long)):
80
for self_br in self.browse(cr, uid, ids, context=context):
81
res[self_br.id] = self_br.move_id and \
82
self_br.move_id.cheque_number or ''
85
def _search_cheque_number(self, cr, uid, ids, name, args, context=None):
89
msg = _("Domain %s not suported") % (str(args), )
90
raise osv.except_osv(_('Error'), msg)
91
if args[0][1] != 'ilike':
92
# g/l selector / analytical selector default operator not found
93
msg = _("Operator %s not suported") % (args[0][1], )
94
raise osv.except_osv(_('Error'), msg)
98
m_ids = self.pool.get('account.move.line').search(cr, uid,
99
[('cheque_number', 'ilike', args[0][2])], context=context)
100
return [('move_id', 'in', m_ids)] if m_ids else [('id', 'in', [])]
103
74
'output_amount': fields.function(_get_output, string="Output amount", type='float', method=True, store=False, multi="analytic_output_currency"),
104
75
'output_amount_debit': fields.function(_get_output, string="Output debit", type='float', method=True, store=False, multi="analytic_output_currency"),
105
76
'output_amount_credit': fields.function(_get_output, string="Output credit", type='float', method=True, store=False, multi="analytic_output_currency"),
106
'output_currency': fields.function(_get_output, string="Output curr.", type='many2one', relation='res.currency', method=True, store=False,
77
'output_currency': fields.function(_get_output, string="Output curr.", type='many2one', relation='res.currency', method=True, store=False,
107
78
multi="analytic_output_currency"),
108
'cheque_number': fields.function(_get_cheque_number, type='char',
109
method=True, string='Cheque Number',
110
fnct_search=_search_cheque_number) # BKLG-7: move cheque number
113
81
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
123
91
for field in element_fields:
124
92
tree.remove(field)
125
93
view['arch'] = etree.tostring(tree)
127
if view_type == 'tree' and \
128
context.get('selector_display_cheque_number', False):
129
# BKLG-7: cheque_number used in analytic selector: display it
130
view['fields']['cheque_number'] = {
131
'function': '_get_cheque_number',
132
'fnct_search': '_search_cheque_number',
134
'string': 'Cheque Number',
137
tree = etree.fromstring(view['arch'])
139
cheque_number_node = etree.Element('field', attrib={
140
'name': 'cheque_number',
142
# insert it after entry sequence
143
es_node = tree.find('.//field[@name="entry_sequence"]')
144
tree.insert(es_node.getparent().index(es_node) + 1,
147
view['arch'] = etree.tostring(tree)
150
96
def copy(self, cr, uid, id, default=None, context=None):