[REV] purchase: ensure all vendor bills are gathered from purchase order

With the recent change made in this task:
https://www.odoo.com/web#id=3279233&menu_id=4720&cids=1&action=333&active_id=967&model=project.task&view_type=form
The following commit can be reverted. (@Whenrow confirm to me that this commit
is no longer useful).
https://github.com/odoo/odoo/commit/e3101d92187946b2bd539e05956e4e83cd9c9097

opw-3214033

Part-of: odoo/odoo#120628
This commit is contained in:
Maximilien (malb)
2023-07-13 16:52:45 +02:00
parent 3e09bdff0c
commit 929f6288ec
2 changed files with 0 additions and 45 deletions
-4
View File
@@ -669,11 +669,7 @@ class PurchaseOrder(models.Model):
immediately.
"""
if not invoices:
# Invoice_ids may be filtered depending on the user. To ensure we get all
# invoices related to the purchase order, we read them in sudo to fill the
# cache.
self.invalidate_model(['invoice_ids'])
self.sudo().fetch(['invoice_ids'])
invoices = self.invoice_ids
result = self.env['ir.actions.act_window']._for_xml_id('account.action_move_in_invoice_type')
@@ -96,47 +96,6 @@ class TestPurchaseInvoice(AccountTestInvoicingCommon):
vendor_bill_user1 = Form(vendor_bill_user2.with_user(self.purchase_user))
vendor_bill_user1 = vendor_bill_user1.save()
def test_read_purchase_order_2(self):
""" Check that a 2 purchase users with open the vendor bill the same
way even with a 'own documents only' record rule. """
# edit the account.move record rule for purchase user in order to ensure
# a user can only see his own invoices
rule = self.env.ref('purchase.purchase_user_account_move_rule')
rule.domain_force = "['&', ('move_type', 'in', ('in_invoice', 'in_refund', 'in_receipt')), ('invoice_user_id', '=', user.id)]"
# create a purchase and make a vendor bill from it as purchase user 2
purchase_user_2 = self.purchase_user.copy({
'name': 'Purchase user 2',
'login': 'purchaseUser2',
'email': 'pu2@odoo.com',
})
purchase_order_form = Form(self.env['purchase.order'].with_user(purchase_user_2))
purchase_order_form.partner_id = self.vendor
with purchase_order_form.order_line.new() as line:
line.name = self.product.name
line.product_id = self.product
line.product_qty = 4
line.price_unit = 5
purchase_order_user2 = purchase_order_form.save()
purchase_order_user2.button_confirm()
purchase_order_user2.order_line.qty_received = 4
purchase_order_user2.action_create_invoice()
vendor_bill_user2 = purchase_order_user2.invoice_ids
# check user 1 cannot read the invoice
with self.assertRaises(AccessError):
Form(vendor_bill_user2.with_user(self.purchase_user))
# Check that calling 'action_view_invoice' return the same action despite the record rule
action_user_1 = purchase_order_user2.with_user(self.purchase_user).action_view_invoice()
purchase_order_user2.invalidate_recordset()
action_user_2 = purchase_order_user2.with_user(purchase_user_2).action_view_invoice()
self.assertEqual(action_user_1, action_user_2)
def test_double_validation(self):
"""Only purchase managers can approve a purchase order when double
validation is enabled"""