Skip to content

Commit

Permalink
[IMP] test45 should not depend on previous tests
Browse files Browse the repository at this point in the history
./odoo-bin -d db --stop-after-init --test-enable --test-tags=.test_45_xml_import_no_duplicate_partner
falliva perché non trovava il partner, visto che gli altri test non
erano stati eseguiti. Se manca il partner, viene importato l'XML due
volte.

Incluso fix odoo/odoo#71920, altrimenti il test
non passa.
  • Loading branch information
TheMule71 committed Jun 11, 2021
1 parent d5842cc commit cd1214c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions l10n_it_fatturapa_in/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ class Partner(models.Model):
"-1 to use the default precision",
default=-1,
)

# https://github.com/odoo/odoo/pull/71920
# this is temporary fix, we depend on the issue do the solved for our test
# to be all green
def _split_vat(self, vat):
vat = vat.replace(" ", "")
return super()._split_vat(vat)
16 changes: 14 additions & 2 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,22 @@ def test_44_xml_import(self):

def test_45_xml_import_no_duplicate_partner(self):
partner_id = self.env["res.partner"].search([("vat", "ilike", "05979361218")])
partner_id.vat = " %s " % partner_id.vat
res = self.run_wizard("test45", "IT05979361218_001.xml")
if not partner_id:
# load bill (when this test is run by itself)
res = self.run_wizard("test45a", "IT05979361218_001.xml")
partner_id = self.env["res.partner"].search(
[("vat", "ilike", "05979361218")]
)

# try and alter the vat of the existing partner
partner_id.write({"vat": " %s " % partner_id.vat})

# load bill (2nd time)
res = self.run_wizard("test45b", "IT05979361218_001.xml")
invoice_id = res.get("domain")[0][2][0]
invoice = self.invoice_model.browse(invoice_id)

# check for duplicates
self.assertEqual(invoice.partner_id.id, partner_id.id)
self.assertEqual(
len(self.env["res.partner"].search([("vat", "ilike", "05979361218")])), 1
Expand Down

0 comments on commit cd1214c

Please sign in to comment.