From 6101b856f0a7a18b94b3fc080cb686c40d5fc736 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 20 Jun 2016 11:35:39 +0200 Subject: [PATCH 1/4] [FIX] Wrong amount currency in account move line When computing the amount currency, the date must be set in the context to use the right currency rate. opw:680693 --- addons/account/models/account_move.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index a465c7567f1..376a75cedd0 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1075,8 +1075,11 @@ class AccountMoveLine(models.Model): } bank = self.env["account.bank.statement"].browse(vals.get('statement_id')) if bank.currency_id != bank.company_id.currency_id: + ctx = {} + if 'date' in vals: + ctx['date'] = vals['date'] temp['currency_id'] = bank.currency_id.id - temp['amount_currency'] = bank.company_id.currency_id.compute(tax_vals['amount'], bank.currency_id, round=True) + temp['amount_currency'] = bank.company_id.currency_id.with_context(ctx).compute(tax_vals['amount'], bank.currency_id, round=True) tax_lines_vals.append(temp) new_line = super(AccountMoveLine, self).create(vals) From c77745b9c5ccb641805c74dadc51d838b94ec077 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 20 Jun 2016 13:50:58 +0200 Subject: [PATCH 2/4] [FIX] sale, slae_stock, website_quote: get sale_delay in onchange_template_id Inspired from a706ada opw:681245, 681289, 681285 --- addons/sale/sale.py | 3 +++ addons/sale_stock/sale_stock.py | 6 ++++++ addons/website_quote/models/order.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 6cafd72510e..9ca0a33ac84 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -269,6 +269,9 @@ class sale_order(osv.osv): ] _order = 'date_order desc, id desc' + def _get_customer_lead(self, cr, uid, product_tmpl_id): + return False + # Form filling def unlink(self, cr, uid, ids, context=None): sale_orders = self.read(cr, uid, ids, ['state'], context=context) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index f869d157432..4c943325f6a 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -102,6 +102,12 @@ class sale_order(osv.osv): 'picking_policy': 'direct', 'order_policy': 'manual', } + + #FORWARDPORT UP TO SAAS-6 + def _get_customer_lead(self, cr, uid, product_tmpl_id): + super(sale_order, self)._get_customer_lead(cr, uid, product_tmpl_id) + return product_tmpl_id.sale_delay + def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context=None): val = {} if warehouse_id: diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index d6d78cc80a5..1120cc3ee6b 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -185,7 +185,7 @@ class sale_order(osv.osv): 'product_uom': line.product_uom_id.id, 'website_description': line.website_description, 'state': 'draft', - 'delay': line.product_id.sale_delay + 'delay': self.pool['sale.order']._get_customer_lead(cr, uid, line.product_id.product_tmpl_id) }) lines.append((0, 0, data)) options = [] From fe15829c1664c00bc64874af4f504eaffbe1c12f Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 13 Jun 2016 23:38:12 +0200 Subject: [PATCH 3/4] [IMP] stock: when applying a push rule the new move should not be linked to the same procurement anymore --- addons/stock/stock.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index f13a208e58c..40f3f4a2b43 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -3832,6 +3832,7 @@ class stock_location_path(osv.osv): 'propagate': rule.propagate, 'push_rule_id': rule.id, 'warehouse_id': rule.warehouse_id and rule.warehouse_id.id or False, + 'procurement_id': False, } def _apply(self, cr, uid, rule, move, context=None): From 0a2317d303e4ee0649f7baa1a35df405a63a2017 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 21 Jun 2016 11:23:18 +0200 Subject: [PATCH 4/4] [FIX] test_new_api,web: tests 9.0 adjustments Rev e37ba61 forward-ported 8.0 revision f02b230 from PR #12379. This patch introduces extra tests and views for o2m onchange behavior, including new fields in the test models. In 9.0 a new convert_to_onchange() mechanism had been introduced at 9f81c6d The combination of both requires some adaptation to the expected results of the new tests and adaptation of existing tests. The test models in `test_new_api` have an implicit depencies between models which cannot be express on ORM: messages depends on participants of their discussion. So, when editing a discussion, the field `participants` should be processed before field `messages`. This is not always done because field processing order depends of the iteration order of a `dict` (which is undefined in python). The testing tour `widget_x2many` worked by chance until now. Adapt the tour to save the participants before the messages. --- addons/web/static/test/x2many.js | 44 ++++++++++++++++--- .../test_new_api/tests/test_onchange.py | 22 ++++++++-- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/addons/web/static/test/x2many.js b/addons/web/static/test/x2many.js index f57b03bcb1d..f45df41334e 100644 --- a/addons/web/static/test/x2many.js +++ b/addons/web/static/test/x2many.js @@ -69,7 +69,42 @@ Tour.register({ waitFor: '.tab-pane:last tr:has(.oe_list_field_cell):not(:has(.oe_list_record_selector)):contains(user_test)', }, + // add ourself as participant + { + title: "change tab to Participants", + element: '[data-toggle="tab"]:contains(Participants)' + }, + { + title: "click to add participants", + element: '.tab-pane:eq(2).active .oe_form_field_x2many_list_row_add a' + }, + { + title: "select Admin", + element: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]' + }, + { + title: "save selected participants", + waitFor: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]:propChecked', + element: '.o_selectcreatepopup_search_select' + }, + + // save + { + title: "save discussion", + waitFor: '.oe_form_field_many2many tbody tr td.oe_list_field_char:containsExact(Administrator)', + element: 'button.oe_form_button_save' + }, + // edit + { + title: "edit discussion", + element: 'button.oe_form_button_edit' + }, + // add message a + { + title: "Select First Tab", + element: 'a[role=tab]:first', + }, { title: "create new message a", element: '.oe_form_field_x2many_list_row_add:first a' @@ -167,15 +202,10 @@ Tour.register({ }, { title: "click to add participants", - element: '.tab-pane:eq(1).active .oe_form_field_x2many_list_row_add a' - }, - { - title: "select Admin", - element: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]' + element: '.tab-pane:eq(2).active .oe_form_field_x2many_list_row_add a' }, { title: "select Demo User", - waitFor: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]:propChecked', element: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Demo User)) .oe_list_record_selector input[type="checkbox"]' }, { @@ -214,7 +244,7 @@ Tour.register({ element: 'button.oe_form_button_edit' }, { - title: "change tab to Participants", + title: "change tab to Messages", waitFor: '.oe_form_editable', element: '[data-toggle="tab"]:contains(Messages)' }, diff --git a/openerp/addons/test_new_api/tests/test_onchange.py b/openerp/addons/test_new_api/tests/test_onchange.py index 2916959ed20..adecda3e4aa 100644 --- a/openerp/addons/test_new_api/tests/test_onchange.py +++ b/openerp/addons/test_new_api/tests/test_onchange.py @@ -89,7 +89,7 @@ class TestOnChange(common.TransactionCase): self.assertEqual(field_onchange.get('messages'), '1') self.assertItemsEqual( strip_prefix('messages.', field_onchange), - ['author', 'body', 'name', 'size'], + ['author', 'body', 'name', 'size', 'important'], ) # modify discussion name @@ -105,6 +105,7 @@ class TestOnChange(common.TransactionCase): 'body': BODY, 'author': USER.id, 'size': len(BODY), + 'important': False, }), ], } @@ -118,12 +119,14 @@ class TestOnChange(common.TransactionCase): 'body': message.body, 'author': message.author.name_get()[0], 'size': message.size, + 'important': message.important, }), (0, 0, { 'name': "[%s] %s" % ("Foo", USER.name), 'body': BODY, 'author': USER.name_get()[0], 'size': len(BODY), + 'important': False, }), ]) @@ -248,6 +251,7 @@ class TestOnChange(common.TransactionCase): 'body': BODY, 'author': USER.id, 'important': False, + 'email_to': demo.email, }) # check if server-side cache is working correctly @@ -276,8 +280,18 @@ class TestOnChange(common.TransactionCase): # When one2many domain contains non-computed field, things are ok self.assertEqual(result['value']['important_messages'], - [(1, email.message.id, {'name': u'[Foo Bar] %s' % USER.name})]) + [(5,)] + [(4, msg.id) for msg in discussion.important_messages]) # But here with commit 5676d81, we get value of: [(2, email.id)] - self.assertEqual(result['value']['important_emails'], - [(1, email.id, {'name': u'[Foo Bar] %s' % USER.name})]) + self.assertEqual( + result['value']['important_emails'], + [(5,), + (1, email.id, { + 'name': u'[Foo Bar] %s' % USER.name, + 'body': email.body, + 'author': USER.name_get()[0], + 'important': True, + 'email_to': demo.email, + 'size': email.size, + })] + )