Add check that invoices do not exist already before import.
This commit is contained in:
parent
6458ea1b60
commit
bba1edb759
16
account.py
16
account.py
|
@ -107,6 +107,19 @@ def convert_account(account):
|
|||
else:
|
||||
return account
|
||||
|
||||
def find_factura(number, company):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
invoice, = Invoice.search([('number', '=', number),
|
||||
('company', '=', company)], limit=1)
|
||||
return invoice
|
||||
|
||||
def check_factura_not_exists(number, company):
|
||||
if find_factura(number, company):
|
||||
raise UserError(
|
||||
gettext('account_import_contaplus.msg_factura_exists',
|
||||
number=number))
|
||||
|
||||
|
||||
class Move(metaclass=PoolMeta):
|
||||
__name__ = 'account.move'
|
||||
|
@ -340,6 +353,7 @@ class AccountImportContaplus(Wizard):
|
|||
return invoice
|
||||
|
||||
|
||||
|
||||
def import_invoices(self, company, imp_record):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
|
@ -367,6 +381,8 @@ class AccountImportContaplus(Wizard):
|
|||
invoice_number = iline.serie + iline.factura
|
||||
if invoice_number not in to_create:
|
||||
# todo check num factura not alredy there.
|
||||
check_factura_not_exists(invoice_number, company)
|
||||
|
||||
if invoice:
|
||||
# check factura
|
||||
# if lines empty remove from to_create
|
||||
|
|
|
@ -24,5 +24,8 @@
|
|||
<record model="ir.message" id="msg_missing_payment_term">
|
||||
<field name="text">Payment terms missing for %(party)s.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_factura_exists">
|
||||
<field name="text">Invoice "%(number)s" already exists for this company.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
Loading…
Reference in New Issue