[FIX] sale, sale_expense, stock_landed_costs: fix nightly build.
stock_landed_costs: on nightly, the localization installed may not have stock properties accounts defined. If it's not, we create them on the fly with a random account
sale, sale_expense: fix broken tests due to mismatch currency:
On 10.0-nightly, the currency of the company is not the same that the product.list0
that leads to assertion errors.
This commit is contained in:
@@ -28,3 +28,30 @@ class AccountingTestCase(HttpCase):
|
||||
if theorical_lines:
|
||||
raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines]))
|
||||
return True
|
||||
|
||||
def ensure_account_property(self, property_name):
|
||||
'''Ensure the ir.property targetting an account.account passed as parameter exists.
|
||||
In case it's not: create it with a random account. This is useful when testing with
|
||||
partially defined localization (missing stock properties for example)
|
||||
|
||||
:param property_name: The name of the property.
|
||||
'''
|
||||
company_id = self.env.user.company_id
|
||||
field_id = self.env['ir.model.fields'].search(
|
||||
[('model', '=', 'product.template'), ('name', '=', property_name)], limit=1)
|
||||
property_id = self.env['ir.property'].search([
|
||||
('company_id', '=', company_id.id),
|
||||
('name', '=', property_name),
|
||||
('res_id', '=', None),
|
||||
('fields_id', '=', field_id.id)], limit=1)
|
||||
account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1)
|
||||
value_reference = 'account.account,%d' % account_id.id
|
||||
if property_id and not property_id.value_reference:
|
||||
property_id.value_reference = value_reference
|
||||
else:
|
||||
self.env['ir.property'].create({
|
||||
'name': property_name,
|
||||
'company_id': company_id.id,
|
||||
'fields_id': field_id.id,
|
||||
'value_reference': value_reference,
|
||||
})
|
||||
|
||||
@@ -104,6 +104,9 @@ class TestSaleOrder(TestSale):
|
||||
|
||||
def test_cost_invoicing(self):
|
||||
""" Test confirming a vendor invoice to reinvoice cost on the so """
|
||||
# force the pricelist to have the same currency as the company
|
||||
self.env.ref('product.list0').currency_id = self.env.ref('base.main_company').currency_id
|
||||
|
||||
serv_cost = self.env.ref('product.service_cost_01')
|
||||
prod_gap = self.env.ref('product.product_product_1')
|
||||
so = self.env['sale.order'].create({
|
||||
|
||||
@@ -7,6 +7,9 @@ from odoo.addons.sale.tests.test_sale_common import TestSale
|
||||
class TestSaleExpense(TestSale):
|
||||
def test_sale_expense(self):
|
||||
""" Test the behaviour of sales orders when managing expenses """
|
||||
# force the pricelist to have the same currency as the company
|
||||
self.env.ref('product.list0').currency_id = self.env.ref('base.main_company').currency_id
|
||||
|
||||
# create a so with a product invoiced on delivery
|
||||
prod = self.env.ref('product.product_product_1')
|
||||
so = self.env['sale.order'].create({
|
||||
|
||||
@@ -59,6 +59,9 @@ class TestStockLandedCostsCommon(AccountingTestCase):
|
||||
self.brokerage_quantity = self._create_services('Brokerage Cost')
|
||||
self.transportation_weight = self._create_services('Transportation Cost')
|
||||
self.packaging_volume = self._create_services('Packaging Cost')
|
||||
# Ensure the account properties exists.
|
||||
self.ensure_account_property('property_stock_account_input')
|
||||
self.ensure_account_property('property_stock_account_output')
|
||||
|
||||
def _create_services(self, name):
|
||||
return self.Product.create({
|
||||
|
||||
Reference in New Issue
Block a user