36
36
def get_bvr_ref(self, cursor, uid, move_line_id, context=None):
37
"""Retrieve ESR/BVR reference from move line in order to print it"""
37
"""Retrieve ESR/BVR reference from move line in order to print it
39
Returns False when no BVR reference should be generated. No
40
reference is generated when a transaction reference already
41
exists for the line (likely been generated by a payment service).
39
44
if isinstance(move_line_id, (tuple, list)):
40
45
assert len(move_line_id) == 1, "Only 1 ID expected"
41
46
move_line_id = move_line_id[0]
42
47
move_line = self.browse(cursor, uid, move_line_id, context=context)
43
48
## We check if the type is bvr, if not we return false
44
if move_line.invoice.partner_bank_id.state != 'bvr':
49
if (move_line.invoice.partner_bank_id.state != 'bvr' or
50
move_line.transaction_ref):
47
53
if move_line.invoice.partner_bank_id.bvr_adherent_num:
96
102
store=True, readonly=True)
105
def _get_bvr_ref(self, cr, uid, invoice, context=None):
106
"""Retrieve ESR/BVR reference form invoice in order to print it
108
Receive a browse record so it can be overloaded without rebrowsing
112
## We check if the type is bvr, if not we return false
113
if invoice.partner_bank_id.state != 'bvr':
116
if invoice.partner_bank_id.bvr_adherent_num:
117
res = invoice.partner_bank_id.bvr_adherent_num
120
invoice_number = self._compile_get_ref.sub('', invoice.number)
121
return mod10r(res + invoice_number.rjust(26 - len(res), '0'))
99
123
def get_bvr_ref(self, cursor, uid, inv_id, context=None):
100
"""Retrieve ESR/BVR reference form invoice in order to print it"""
102
if isinstance(inv_id, list):
124
"""Retrieve ESR/BVR reference form invoice in order to print it
126
Returns False when no BVR reference should be generated. No
127
reference is generated when the invoice is not a BVR invoice.
129
if isinstance(inv_id, (list, tuple)):
130
assert len(inv_id) == 1, "1 ID expected, got %s" % inv_id
103
131
inv_id = inv_id[0]
104
132
inv = self.browse(cursor, uid, inv_id, context=context)
105
## We check if the type is bvr, if not we return false
106
if inv.partner_bank_id.state != 'bvr':
109
if inv.partner_bank_id.bvr_adherent_num:
110
res = inv.partner_bank_id.bvr_adherent_num
113
invoice_number = self._compile_get_ref.sub('', inv.number)
114
return mod10r(res + invoice_number.rjust(26 - len(res), '0'))
133
return self._get_bvr_ref(cursor, uid, inv, context=context)
116
135
def _space(self, nbr, nbrspc=5):
144
163
# We keep this branch for compatibility with single BVR report.
145
164
# This should be cleaned when porting to V8
166
# An existing transaction_ref as the priority if we
167
# already have a transaction ref, it has been issued by
168
# a payment service, so we don't need a BVR reference.
147
169
if len(move_lines) == 1:
148
170
ref = inv.get_bvr_ref()
149
171
move_id = inv.move_id
151
173
cr.execute('UPDATE account_move_line SET transaction_ref=%s'
152
174
' WHERE move_id=%s',
153
175
(ref, move_id.id))