minor fix for delete voucher or notes

This commit is contained in:
wilsongomez 2022-03-24 17:15:56 -05:00
parent 4a49752634
commit 3c18f892fc
3 changed files with 15 additions and 4 deletions

View file

@ -1214,6 +1214,10 @@ msgctxt "model:ir.message,text:msg_invoice_dont_posted"
msgid "The invoice must posted!"
msgstr ""
msgctxt "model:ir.message,text:msg_delete_record"
msgid "You can not delete this record becouse is posted or was processed!."
msgstr "No puedes eliminar este registro porque esta contabilizado o fue procesado"
msgctxt "model:ir.message,text:msg_line_party_required"
msgid "Note Line with account require \"%(s)\" party."
msgstr ""

View file

@ -9,8 +9,8 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_missing_pay_lines">
<field name="text">You have to enter lines to pay!.</field>
</record>
<record model="ir.message" id="msg_delete_voucher">
<field name="text">You can not delete a voucher that is posted!.</field>
<record model="ir.message" id="msg_dont_delete_voucher">
<field name="text">You can not delete this record becouse is posted or was processed!.</field>
</record>
<record model="ir.message" id="msg_missing_journal_account">
<field name="text">Missing debit or credit account on journal!</field>

View file

@ -587,8 +587,8 @@ class Voucher(Workflow, ModelSQL, ModelView):
vouchers_append = voucher_ids.append
for voucher in vouchers:
vouchers_append(voucher.id)
if voucher.state == 'posted':
raise UserError(gettext('account_voucher.msg_delete_voucher'))
if voucher.state == 'posted' or voucher.number:
raise UserError(gettext('account_voucher.msg_delete_record'))
if voucher.move:
Move.delete([voucher.move])
Line.delete([l for v in vouchers for l in v.lines])
@ -1177,6 +1177,13 @@ class Note(Workflow, ModelSQL, ModelView):
def select_move_lines(cls, records):
pass
@classmethod
def delete(cls, notes):
for note in notes:
if note.state == 'posted' or note.number:
raise UserError(gettext('account_voucher.msg_delete_record'))
return super(Note, cls).delete(notes)
def set_number(self):
if self.number:
return