Skip to content

Commit

Permalink
[FIx] check the bvr reference for bvr supplier invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
vrenaville committed Jun 5, 2015
1 parent 78ff107 commit baedc9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion l10n_ch_base_bank/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _check_bvr(self):
The validation is based on l10n_ch
"""
for invoice in self:
if invoice.reference_type == 'bvr' and invoice.state != 'draft':
if invoice.reference_type == 'bvr':
if not invoice.reference:
raise exceptions.ValidationError(
_('BVR/ESR Reference is required')
Expand Down
17 changes: 11 additions & 6 deletions l10n_ch_payment_slip/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,18 @@ def action_number(self):
res = super(AccountInvoice, self).action_number()
pay_slip = self.env['l10n_ch.payment_slip']
for inv in self:
for pay_slip in pay_slip.compute_pay_slips_from_invoices(inv):
if inv.type in ('out_invoice', 'out_refund'):
ref = pay_slip.reference
elif inv.reference_type == 'bvr' and inv.reference:
if inv.type in ('in_invoice', 'in_refund'):
if inv.reference_type == 'bvr' and inv._check_bvr():
ref = inv.reference
else:
ref = False
self._action_bvr_number_move_line(pay_slip.move_line_id,
ref)
move_lines = inv.get_payment_move_line()
for move_line_id in move_lines:
self._action_bvr_number_move_line(move_line_id,
ref)
else:
for pay_slip in pay_slip.compute_pay_slips_from_invoices(inv):
ref = pay_slip.reference
self._action_bvr_number_move_line(pay_slip.move_line_id,
ref)
return res
15 changes: 4 additions & 11 deletions l10n_ch_payment_slip/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,10 @@ class payment_line(models.Model):
@api.returns('self', lambda value: value.id)
def create(self, vals):
"""In case of BVR
we will search if the invoice related has BVR reference"""
we will search the transaction ref instead of ref for
communication field"""
account_move_line_obj = self.env['account.move.line']
move_line = account_move_line_obj.browse(vals['move_line_id'])
account_invoice_obj = self.env['account.invoice']
invoice = account_invoice_obj.search([('move_id',
'=',
move_line.move_id.id)])
# We found a invoice related to this move line
if invoice:
# if this invoice is a BVR invoice we take the BVR
# reference instead of ref
if invoice.reference_type == 'bvr' and invoice.reference:
vals['communication'] = invoice.reference
if move_line.transaction_ref:
vals['communication'] = move_line.transaction_ref
return super(payment_line, self).create(vals)

0 comments on commit baedc9f

Please sign in to comment.