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:
|
else:
|
||||||
return account
|
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):
|
class Move(metaclass=PoolMeta):
|
||||||
__name__ = 'account.move'
|
__name__ = 'account.move'
|
||||||
|
@ -339,6 +352,7 @@ class AccountImportContaplus(Wizard):
|
||||||
invoice.sii_issued_key = '02'
|
invoice.sii_issued_key = '02'
|
||||||
return invoice
|
return invoice
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def import_invoices(self, company, imp_record):
|
def import_invoices(self, company, imp_record):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
|
@ -367,6 +381,8 @@ class AccountImportContaplus(Wizard):
|
||||||
invoice_number = iline.serie + iline.factura
|
invoice_number = iline.serie + iline.factura
|
||||||
if invoice_number not in to_create:
|
if invoice_number not in to_create:
|
||||||
# todo check num factura not alredy there.
|
# todo check num factura not alredy there.
|
||||||
|
check_factura_not_exists(invoice_number, company)
|
||||||
|
|
||||||
if invoice:
|
if invoice:
|
||||||
# check factura
|
# check factura
|
||||||
# if lines empty remove from to_create
|
# if lines empty remove from to_create
|
||||||
|
|
|
@ -24,5 +24,8 @@
|
||||||
<record model="ir.message" id="msg_missing_payment_term">
|
<record model="ir.message" id="msg_missing_payment_term">
|
||||||
<field name="text">Payment terms missing for %(party)s.</field>
|
<field name="text">Payment terms missing for %(party)s.</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
<record model="ir.message" id="msg_factura_exists">
|
||||||
|
<field name="text">Invoice "%(number)s" already exists for this company.</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
Loading…
Reference in New Issue