From 0c912354a959010e51376ad1b9dab9c1fa9e620d Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 21 May 2019 12:38:57 +0000 Subject: [PATCH 1/5] [FIX] fields: recursive stored fields The compute method of a recursive field must be invoked on single records even when several records are marked to recompute. closes odoo/odoo#33529 Signed-off-by: Raphael Collet (rco) --- odoo/addons/test_new_api/tests/test_new_fields.py | 7 ++++--- odoo/fields.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index ea0b8cdd69ce4..2755612db531c 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -209,11 +209,12 @@ def test_12_recursive_recompute(self): self.assertEqual(c.display_name, 'B / C') self.assertEqual(d.display_name, 'B / C / D') - b.name = 'X' + # rename several records to trigger several recomputations at once + (d + c + b).write({'name': 'X'}) self.assertEqual(a.display_name, 'A') self.assertEqual(b.display_name, 'X') - self.assertEqual(c.display_name, 'X / C') - self.assertEqual(d.display_name, 'X / C / D') + self.assertEqual(c.display_name, 'X / X') + self.assertEqual(d.display_name, 'X / X / X') def test_12_cascade(self): """ test computed field depending on computed field """ diff --git a/odoo/fields.py b/odoo/fields.py index 9a11d8e55ab97..4eea1021e9ee8 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1010,6 +1010,8 @@ def determine_value(self, record): recs = record._recompute_check(self) if recs: # recompute the value (only in cache) + if self.recursive: + recs = record self.compute_value(recs) # HACK: if result is in the wrong cache, copy values if recs.env != env: From c89da3a68304dc971a642dcfc7eb01663ab6ddf6 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 1 Apr 2019 09:05:33 +0000 Subject: [PATCH 2/5] [FIX] delivery: description of the delivery method on SO line Backport of 610b813c87b. In this way the description of the delivery method can be used on a SO line. If the description wasn't set, the name of the delivery method will be used. opw 2000169 closes odoo/odoo#33551 Signed-off-by: Nans Lefebvre (len) --- addons/delivery/models/sale_order.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 601f104ff3c0d..8a84f67d6f1c5 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -87,9 +87,15 @@ def _create_delivery_line(self, carrier, price_unit): taxes_ids = self.fiscal_position_id.map_tax(taxes, carrier.product_id, self.partner_id).ids # Create the sale order line + carrier_with_partner_lang = carrier.with_context(lang=self.partner_id.lang) + if carrier_with_partner_lang.product_id.description_sale: + so_description = '%s: %s' % (carrier_with_partner_lang.name, + carrier_with_partner_lang.product_id.description_sale) + else: + so_description = carrier_with_partner_lang.name values = { 'order_id': self.id, - 'name': carrier.with_context(lang=self.partner_id.lang).name, + 'name': so_description, 'product_uom_qty': 1, 'product_uom': carrier.product_id.uom_id.id, 'product_id': carrier.product_id.id, From 48e93a10a1d1dbb0c6301eb33cf433db6d59f02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Tue, 8 Jan 2019 11:35:23 +0000 Subject: [PATCH 3/5] [FIX] stock: add mising depends on computed field The field had no triggers on the compute method. As the field is not stored, it works fine in most cases where the value is computed in a different transaction that the modification but when it is the case (e.g. OCA/connector-prestashop#101), the values were incorrect Add the correct triggers to recompute the value when needed closes odoo/odoo#30024 Signed-off-by: Martin Trigaux (mat) --- addons/stock/models/product.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 2032550c472c1..1a6144a015eb2 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -444,6 +444,10 @@ class ProductTemplate(models.Model): relation="stock.location.route", string="Category Routes", related='categ_id.total_route_ids') + @api.depends( + 'product_variant_ids', + 'product_variant_ids.stock_quant_ids', + ) def _compute_quantities(self): res = self._compute_quantities_dict() for template in self: From c8b87f66f8e280ee5a1f1f2a3e43b6eac36a8343 Mon Sep 17 00:00:00 2001 From: Benoit Aimont Date: Thu, 25 Apr 2019 06:28:05 +0000 Subject: [PATCH 4/5] [CLA] Add Benoit Aimont in Acsone CCLA --- doc/cla/corporate/acsone.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/cla/corporate/acsone.md b/doc/cla/corporate/acsone.md index d4ee1947927b4..25b0e1b1c8a08 100644 --- a/doc/cla/corporate/acsone.md +++ b/doc/cla/corporate/acsone.md @@ -27,3 +27,4 @@ Thomas Binsfeld thomas.binsfeld@acsone.eu https://github.com/ThomasBinsfeld Benjamin Willig benjamin.willig@acsone.eu https://github.com/benwillig François Honoré francois.honore@acsone.eu https://github.com/acsonefho Denis Robinet denis.robinet@acsone.eu https://github.com/RobinetDenisAcsone +Benoit Aimont benoit.aimont@acsone.eu https://github.com/baimont From 01020e18e911e582b4d93d029e90e2c2929bae2f Mon Sep 17 00:00:00 2001 From: Benoit Aimont Date: Wed, 24 Apr 2019 13:45:23 +0000 Subject: [PATCH 5/5] [FIX] hr_expense: prepare method for move values There was no way to inherit properly action_move_create method. opw:1974069 closes odoo/odoo#33488 Signed-off-by: Nicolas Martinelli (nim) --- addons/hr_expense/models/hr_expense.py | 37 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 62326f734e4de..a4dd234f9d4a5 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -168,24 +168,33 @@ def _compute_expense_totals(self, company_currency, account_move_lines, move_dat total_currency -= line['amount_currency'] or line['price'] return total, total_currency, account_move_lines + @api.multi + def _prepare_move_values(self): + """ + This function prepares move values related to an expense + """ + self.ensure_one() + journal = self.sheet_id.bank_journal_id if self.payment_mode == 'company_account' else self.sheet_id.journal_id + acc_date = self.sheet_id.accounting_date or self.date + move_values = { + 'journal_id': journal.id, + 'company_id': self.env.user.company_id.id, + 'date': acc_date, + 'ref': self.sheet_id.name, + # force the name to the default value, to avoid an eventual 'default_name' in the context + # to set it to '' which cause no number to be given to the account.move when posted. + 'name': '/', + } + return move_values + @api.multi def action_move_create(self): ''' main function that is called when trying to create the accounting entries related to an expense ''' for expense in self: - journal = expense.sheet_id.bank_journal_id if expense.payment_mode == 'company_account' else expense.sheet_id.journal_id - #create the move that will contain the accounting entries - acc_date = expense.sheet_id.accounting_date or expense.date - move = self.env['account.move'].create({ - 'journal_id': journal.id, - 'company_id': self.env.user.company_id.id, - 'date': acc_date, - 'ref': expense.sheet_id.name, - # force the name to the default value, to avoid an eventual 'default_name' in the context - # to set it to '' which cause no number to be given to the account.move when posted. - 'name': '/', - }) + # create the move that will contain the accounting entries + move = self.env['account.move'].create(expense._prepare_move_values()) company_currency = expense.company_id.currency_id diff_currency_p = expense.currency_id != company_currency #one account.move.line per expense (+taxes..) @@ -193,7 +202,7 @@ def action_move_create(self): #create one more move line, a counterline for the total on payable account payment_id = False - total, total_currency, move_lines = expense._compute_expense_totals(company_currency, move_lines, acc_date) + total, total_currency, move_lines = expense._compute_expense_totals(company_currency, move_lines, move.date) if expense.payment_mode == 'company_account': if not expense.sheet_id.bank_journal_id.default_credit_account_id: raise UserError(_("No credit account found for the %s journal, please configure one.") % (expense.sheet_id.bank_journal_id.name)) @@ -226,7 +235,7 @@ def action_move_create(self): 'name': aml_name, 'price': total, 'account_id': emp_account, - 'date_maturity': acc_date, + 'date_maturity': move.date, 'amount_currency': diff_currency_p and total_currency or False, 'currency_id': diff_currency_p and expense.currency_id.id or False, 'payment_id': payment_id,