124
131
move_obj.post(cr, uid, [move_id], context=context)
135
def create_statement_payment_line(self, cr, uid, st, payment_amount, context=None):
136
st_line_obj = self.pool.get('account.bank.statement.line')
137
payment_account_id = st.profile_id.journal_id.default_credit_account_id.id
138
partner_id = st.profile_id.partner_id and profile.partner_id.id or False
140
'name': _('Payment Transfer'),
142
'amount': -payment_amount,
143
'partner_id': partner_id,
145
'statement_id': st.id,
146
'account_id': payment_account_id,
147
'ref': _('Transfer'),
148
'already_completed': True
150
payment_line_id = st_line_obj.create(cr, uid, vals, context=context)
151
return payment_line_id
154
def create_statement_refund_line(self, cr, uid, st, refund_amount, context=None):
155
st_line_obj = self.pool.get('account.bank.statement.line')
156
refund_account_id = st.profile_id.journal_id.default_credit_account_id.id
157
partner_id = st.profile_id.partner_id and profile.partner_id.id or False
159
'name': _('Refund Transfer'),
161
'amount': -refund_amount,
162
'partner_id': partner_id,
164
'statement_id': st.id,
165
'account_id': refund_account_id,
166
'ref': _('Transfer'),
167
'already_completed': True
169
refund_line_id = st_line_obj.create(cr, uid, vals, context=context)
170
return refund_line_id
173
def prepare_statement_transfer_lines(self, cr, uid, st, context=None):
176
transfer_line_ids = []
177
#Calculate the part of the refund amount and the payment amount
178
for st_line in st.line_ids:
179
if st_line.amount < 0.0:
180
refund_amount += st_line.amount
182
payment_amount += st_line.amount
183
#Create 2 Transfer lines or One global tranfer line
184
if st.profile_id.split_transfer_line:
185
transfer_line_ids.append(self.create_statement_refund_line(cr, uid, st,
188
transfer_line_ids.append(self.create_statement_payment_line(cr, uid, st,
192
global_amount = refund_amount + payment_amount
193
#The global transfer line can be a refund or a payment transfer
194
if global_amount < 0.00:
195
transfer_line_ids.append(self.create_statement_refund_line(cr, uid, st,
199
transfer_line_ids.append(self.create_statement_payment_line(cr, uid, st,
202
return transfer_line_ids
128
206
def button_confirm_bank(self, cr, uid, ids, context=None):
129
207
st_line_obj = self.pool.get('account.bank.statement.line')
130
208
if context is None:
132
210
for st in self.browse(cr, uid, ids, context=context):
211
if st.profile_id.one_move:
212
refund_line_ids = self.prepare_statement_transfer_lines(cr, uid, st,
133
214
super(account_bank_statement, self).button_confirm_bank(cr, uid, ids,
135
216
if st.profile_id.one_move: