From fc14ed6642c370d616afe6da7f26620b5c745ca5 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 18 Jun 2018 14:49:49 +0200 Subject: [PATCH] [FIX] stock_account, stock_dropshipping: do not change accounts - Change the one of the following default account on a product category: Stock Input Account Stock Output Account Stock Valuation Account - Upgrade stock_account The account is changed back to the default value. This was due to commit 1bf25fc018a49bc which attempted to solve an error in a test. We fix the test by making sure we check the right accounts. We also make sure to avoid creating 2 identical `ir.properties` (one `False`, the other with a value). We only update the property if it is `False`. opw-1859706 --- .../data/stock_account_data_post_install.yml | 10 +++++----- .../stock_dropshipping/tests/test_stockvaluation.py | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) 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