[MIG] purchase_by_sale_history: To 16 error on _sale_history method relation with sale_report not exist

This commit is contained in:
Leo Pinedo
2022-10-21 19:06:47 +00:00
parent 66bfcea3e8
commit 6a55ca3af2
2 changed files with 6 additions and 6 deletions

View File

@@ -53,12 +53,12 @@ class TestPurchaseBySaleHistory(common.TransactionCase):
# Assign vendor to products created earlier.
self.env['product.supplierinfo'].create({
'name': purchase_partner.id,
'partner_id': purchase_partner.id,
'product_tmpl_id': product11.product_tmpl_id.id,
'product_id': product11.id,
})
self.env['product.supplierinfo'].create({
'name': purchase_partner.id,
'partner_id': purchase_partner.id,
'product_tmpl_id': product2.product_tmpl_id.id,
})
# New wizard picks up the correct number of products supplied by this vendor.

View File

@@ -40,8 +40,8 @@ class PurchaseBySaleHistory(models.TransientModel):
self.env.cr.execute("""SELECT COUNT(DISTINCT(psi.product_id)) + COUNT(DISTINCT(p.id))
FROM product_supplierinfo psi
LEFT JOIN product_product p ON p.product_tmpl_id = psi.product_tmpl_id AND psi.product_id IS NULL
WHERE psi.name = %d;"""
% (wiz.purchase_id.partner_id.id, ))
WHERE psi.partner_id = %s;""",
(wiz.purchase_id.partner_id.id,))
wiz.product_count = self.env.cr.fetchall()[0][0]
def _history_product_ids(self):
@@ -51,8 +51,8 @@ class PurchaseBySaleHistory(models.TransientModel):
self.env.cr.execute("""SELECT DISTINCT(COALESCE(psi.product_id, p.id))
FROM product_supplierinfo psi
LEFT JOIN product_product p ON p.product_tmpl_id = psi.product_tmpl_id AND psi.product_id IS NULL
WHERE psi.name = %d;"""
% (self.purchase_id.partner_id.id, ))
WHERE psi.partner_id = %s;""",
(self.purchase_id.partner_id.id,))
rows = self.env.cr.fetchall()
return [r[0] for r in rows if r[0]]