diff --git a/addons/stock_account/data/stock_account_data_post_install.yml b/addons/stock_account/data/stock_account_data_post_install.yml index f9ee93e3d54..2280e3c5a83 100644 --- a/addons/stock_account/data/stock_account_data_post_install.yml +++ b/addons/stock_account/data/stock_account_data_post_install.yml @@ -55,10 +55,10 @@ 'fields_id': field_id, 'value': value, } - properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company.id)]) - if properties: - # the property exist: modify it - properties.write(vals) - else: + properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company.id)], limit=1) + if not properties: # create the property PropertyObj.create(vals) + elif not properties.value_reference: + # update the property if False + properties.write(vals) diff --git a/addons/stock_dropshipping/tests/test_stockvaluation.py b/addons/stock_dropshipping/tests/test_stockvaluation.py index 2eb1ced2756..5dc475e056a 100644 --- a/addons/stock_dropshipping/tests/test_stockvaluation.py +++ b/addons/stock_dropshipping/tests/test_stockvaluation.py @@ -11,13 +11,14 @@ class TestStockValuation(AccountingTestCase): self.stock_location = self.env.ref('stock.stock_location_stock') self.partner_id = self.env.ref('base.res_partner_1') self.product1 = self.env.ref('product.product_product_8') + self.categ_id = self.product1.categ_id - self.acc_payable = self.env['account.account'].search([('name', '=', 'Account Payable')]).id - self.acc_expense = self.env['account.account'].search([('name', '=', 'Expenses')]).id - self.acc_receivable = self.env['account.account'].search([('name', '=', 'Account Receivable')]).id - self.acc_sale = self.env['account.account'].search([('name', '=', 'Product Sales')]).id - self.acc_stock_in = self.env['account.account'].search([('name', '=', 'Stock Interim Account (Received)')]).id - self.acc_stock_out = self.env['account.account'].search([('name', '=', 'Stock Interim Account (Delivered)')]).id + self.acc_payable = self.partner_id.property_account_payable_id.id + self.acc_expense = self.categ_id.property_account_expense_categ_id.id + self.acc_receivable = self.partner_id.property_account_receivable_id.id + self.acc_sale = self.categ_id.property_account_income_categ_id.id + self.acc_stock_in = self.categ_id.property_stock_account_input_categ_id.id + self.acc_stock_out = self.categ_id.property_stock_account_output_categ_id.id def _dropship_product1(self): # enable the dropship and MTO route on the product