Files
odoo_source/addons/purchase_requisition/tests/common.py
T
higo-odoo 16cbbf96b9 [FIX] purchase_requisition,purchase_requisition_stock: Fix Test case
How to reproduce the problem:
- Install the purchase_requistion, purchase_requistion_stock, and any Localization modules such as l10n_be or l10n_in
  (apart from USD currency any localization module)
- error caught only when at the time of module installation but it must have a different currency_id apart from USD

https://watch.screencastify.com/v/1C7GQKHBASyiluGGkFfV

Cause of the problem:
 static values Currency USD cause the problem.
 the following module will be set the currency value
 l10n_be - EUR
 l10n_in - INR
 l10n_br - BRL
 when we installed the following modules then cls.env.user.company_id.currency_id values get changes accordingly

  will lead to this error
  Traceback (most recent call last):
  File /home/odoo/src/odoo/addons/purchase_requisition/tests/common.py, line 70, in setUpClass
    cls.env.user.company_id.currency_id = cls.env.ref(base.USD).id
  File /home/odoo/src/odoo/odoo/fields.py, line 1217, in __set__
    records.write({self.name: write_value})
  File /home/odoo/src/odoo/addons/account/models/company.py, line 301, in write
    raise UserError(_('You cannot change the currency of the company since some journal items already exist'))
  odoo.exceptions.UserError: You cannot change the currency of the company since some journal items already exist
opw-2945581

closes odoo/odoo#98512

Closes: https://github.com/odoo/odoo/pull/98174
X-original-commit: 70b7c57f7ea0a619a149461e0e738ddc25b822f6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-10-05 19:38:45 +02:00

69 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
from odoo.tests import common
class TestPurchaseRequisitionCommon(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestPurchaseRequisitionCommon, cls).setUpClass()
# Fetch purchase related user groups
user_group_purchase_manager = cls.env.ref('purchase.group_purchase_manager')
user_group_purchase_user = cls.env.ref('purchase.group_purchase_user')
# User Data: purchase requisition Manager and User
Users = cls.env['res.users'].with_context({'tracking_disable': True})
cls.user_purchase_requisition_manager = Users.create({
'name': 'Purchase requisition Manager',
'login': 'prm',
'email': 'requisition_manager@yourcompany.com',
'notification_type': 'inbox',
'groups_id': [(6, 0, [user_group_purchase_manager.id])]})
cls.user_purchase_requisition_user = Users.create({
'name': 'Purchase requisition User',
'login': 'pru',
'email': 'requisition_user@yourcompany.com',
'notification_type': 'inbox',
'groups_id': [(6, 0, [user_group_purchase_user.id])]})
# Create Product
cls.product_uom_id = cls.env.ref('uom.product_uom_unit')
cls.product_09 = cls.env['product.product'].create({
'name': 'Pedal Bin',
'categ_id': cls.env.ref('product.product_category_all').id,
'standard_price': 10.0,
'list_price': 47.0,
'type': 'consu',
'uom_id': cls.product_uom_id.id,
'uom_po_id': cls.product_uom_id.id,
'default_code': 'E-COM10',
})
cls.product_13 = cls.env['product.product'].create({
'name': 'Corner Desk Black',
'categ_id': cls.env.ref('product.product_category_all').id,
'standard_price': 78.0,
'list_price': 85.0,
'type': 'consu',
'uom_id': cls.product_uom_id.id,
'uom_po_id': cls.product_uom_id.id,
'default_code': 'FURN_1118',
})
# In order to test process of the purchase requisition ,create requisition
cls.bo_requisition = cls.env['purchase.requisition'].create({
'line_ids': [(0, 0, {
'product_id': cls.product_09.id,
'product_qty': 10.0,
'product_uom_id': cls.product_uom_id.id})]
})
cls.res_partner_1 = cls.env['res.partner'].create({
'name': 'Wood Corner',
})