diff --git a/addons/account/models/account.py b/addons/account/models/account.py index e8fdcb36466..cc2778a4701 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -284,6 +284,12 @@ class AccountAccount(models.Model): self.filtered(lambda r: not r.reconcile)._toggle_reconcile_to_true() else: self.filtered(lambda r: r.reconcile)._toggle_reconcile_to_false() + + if vals.get('currency_id'): + for account in self: + if self.env['account.move.line'].search_count([('account_id', '=', account.id), ('currency_id', 'not in', (False, vals['currency_id']))]): + raise UserError(_('You cannot set a currency on this account as it already has some journal entries having a different foreign currency.')) + return super(AccountAccount, self).write(vals) @api.multi @@ -1086,6 +1092,7 @@ class AccountTax(models.Model): 'refund_account_id': tax.refund_account_id.id, 'analytic': tax.analytic, 'price_include': tax.price_include, + 'tax_exigibility': tax.tax_exigibility, }) return { diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index e162b34ac1c..1920a88eabb 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1461,18 +1461,7 @@ class AccountInvoice(models.Model): new_invoices += refund_invoice return new_invoices - @api.multi - def pay_and_reconcile(self, pay_journal, pay_amount=None, date=None, writeoff_acc=None): - """ Create and post an account.payment for the invoice self, which creates a journal entry that reconciles the invoice. - - :param pay_journal: journal in which the payment entry will be created - :param pay_amount: amount of the payment to register, defaults to the residual of the invoice - :param date: payment date, defaults to fields.Date.context_today(self) - :param writeoff_acc: account in which to create a writeoff if pay_amount < self.residual, so that the invoice is fully paid - """ - if isinstance(pay_journal, pycompat.integer_types): - pay_journal = self.env['account.journal'].browse([pay_journal]) - assert len(self) == 1, "Can only pay one invoice at a time." + def _prepare_payment_vals(self, pay_journal, pay_amount=None, date=None, writeoff_acc=None, communication=None): payment_type = self.type in ('out_invoice', 'in_refund') and 'inbound' or 'outbound' if payment_type == 'inbound': payment_method = self.env.ref('account.account_payment_method_manual_in') @@ -1481,9 +1470,10 @@ class AccountInvoice(models.Model): payment_method = self.env.ref('account.account_payment_method_manual_out') journal_payment_methods = pay_journal.outbound_payment_method_ids - communication = self.type in ('in_invoice', 'in_refund') and self.reference or self.number - if self.origin: - communication = '%s (%s)' % (communication, self.origin) + if not communication: + communication = self.type in ('in_invoice', 'in_refund') and self.reference or self.number + if self.origin: + communication = '%s (%s)' % (communication, self.origin) payment_vals = { 'invoice_ids': [(6, 0, self.ids)], @@ -1498,7 +1488,22 @@ class AccountInvoice(models.Model): 'payment_difference_handling': writeoff_acc and 'reconcile' or 'open', 'writeoff_account_id': writeoff_acc and writeoff_acc.id or False, } + return payment_vals + @api.multi + def pay_and_reconcile(self, pay_journal, pay_amount=None, date=None, writeoff_acc=None): + """ Create and post an account.payment for the invoice self, which creates a journal entry that reconciles the invoice. + + :param pay_journal: journal in which the payment entry will be created + :param pay_amount: amount of the payment to register, defaults to the residual of the invoice + :param date: payment date, defaults to fields.Date.context_today(self) + :param writeoff_acc: account in which to create a writeoff if pay_amount < self.residual, so that the invoice is fully paid + """ + if isinstance(pay_journal, pycompat.integer_types): + pay_journal = self.env['account.journal'].browse([pay_journal]) + assert len(self) == 1, "Can only pay one invoice at a time." + + payment_vals = self._prepare_payment_vals(pay_journal, pay_amount=pay_amount, date=date, writeoff_acc=writeoff_acc) payment = self.env['account.payment'].create(payment_vals) payment.post() diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index 5399633367b..26e8fa3827e 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -779,7 +779,7 @@ var StatementModel = BasicModel.extend({ }).then(function (result) { if (result.length > 0) { var line = self.getLine(handle); - self.lines[handle].st_line.open_balance_account_id = line.amount < 0 ? result[0]['property_account_payable_id'][0] : result[0]['property_account_receivable_id'][0]; + self.lines[handle].st_line.open_balance_account_id = line.balance.amount < 0 ? result[0]['property_account_payable_id'][0] : result[0]['property_account_receivable_id'][0]; } }); }, @@ -836,6 +836,7 @@ var StatementModel = BasicModel.extend({ '__focus': false }); + prop.tax_exigible = tax.tax_exigibility === 'on_payment' ? true : undefined prop.amount = tax.base; prop.amount_str = field_utils.format.monetary(Math.abs(prop.amount), {}, formatOptions); prop.invalid = !self._isValid(prop); @@ -1129,6 +1130,7 @@ var StatementModel = BasicModel.extend({ name : prop.label, debit : amount > 0 ? amount : 0, credit : amount < 0 ? -amount : 0, + tax_exigible: prop.tax_exigible, analytic_tag_ids: [[6, null, _.pluck(prop.analytic_tag_ids, 'id')]] }; if (!isNaN(prop.id)) { @@ -1191,7 +1193,15 @@ var ManualModel = StatementModel.extend({ self.accounts = _.object(self.account_ids, _.pluck(accounts, 'code')); }); - return def_account.then(function () { + var def_reconcileModel = this._rpc({ + model: 'account.reconcile.model', + method: 'search_read', + }) + .then(function (reconcileModels) { + self.reconcileModels = reconcileModels; + }); + + return $.when(def_reconcileModel, def_account).then(function () { switch(context.mode) { case 'customers': case 'suppliers': @@ -1391,7 +1401,7 @@ var ManualModel = StatementModel.extend({ offset: 0, limitMoveLines: this.limitMoveLines, filter: "", - reconcileModels: [], + reconcileModels: this.reconcileModels, account_id: this._formatNameGet([data.account_id, data.account_name]), st_line: data, visible: true diff --git a/addons/base_address_extended/models/base_address_extended.py b/addons/base_address_extended/models/base_address_extended.py index 5d3ee07e342..766fac55a8b 100644 --- a/addons/base_address_extended/models/base_address_extended.py +++ b/addons/base_address_extended/models/base_address_extended.py @@ -33,6 +33,11 @@ class Partner(models.Model): street_number2 = fields.Char('Door', compute='_split_street', help="Door Number", inverse='_set_street', store=True) + @api.model + def _address_fields(self): + """Returns the list of address fields that are synced from the parent.""" + return super(Partner, self)._address_fields() + ['street_name', 'street_number', 'street_number2'] + def get_street_fields(self): """Returns the fields that can be used in a street format. Overwrite this function if you want to add your own fields.""" diff --git a/addons/base_geolocalize/models/res_partner.py b/addons/base_geolocalize/models/res_partner.py index 855b4d8bbd1..3594e1cb61b 100644 --- a/addons/base_geolocalize/models/res_partner.py +++ b/addons/base_geolocalize/models/res_partner.py @@ -1,23 +1,35 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import json +import logging import requests from odoo import api, fields, models, tools, _ from odoo.exceptions import UserError +_logger = logging.getLogger(__name__) -def geo_find(addr): + +def geo_find(addr, apikey=False): if not addr: return None - url = 'https://maps.googleapis.com/maps/api/geocode/json' + + if not apikey: + raise UserError(_('''API key for GeoCoding (Places) required.\n + Save this key in System Parameters with key: google.api_key_geocode, value: + Visit https://developers.google.com/maps/documentation/geocoding/get-api-key for more information. + ''')) + + url = "https://maps.googleapis.com/maps/api/geocode/json" try: - result = requests.get(url, params={'sensor': 'false', 'address': addr}).json() + result = requests.get(url, params={'sensor': 'false', 'address': addr, 'key': apikey}).json() except Exception as e: raise UserError(_('Cannot contact geolocation servers. Please make sure that your Internet connection is up and running (%s).') % e) if result['status'] != 'OK': + if result.get('error_message'): + _logger.error(result['error_message']) return None try: @@ -45,22 +57,26 @@ class ResPartner(models.Model): partner_longitude = fields.Float(string='Geo Longitude', digits=(16, 5)) date_localization = fields.Date(string='Geolocation Date') + @classmethod + def _geo_localize(cls, apikey, street='', zip='', city='', state='', country=''): + search = geo_query_address(street=street, zip=zip, city=city, state=state, country=country) + result = geo_find(search, apikey) + if result is None: + search = geo_query_address(city=city, state=state, country=country) + result = geo_find(search, apikey) + return result + @api.multi def geo_localize(self): # We need country names in English below + apikey = self.env['ir.config_parameter'].sudo().get_param('google.api_key_geocode') for partner in self.with_context(lang='en_US'): - result = geo_find(geo_query_address(street=partner.street, - zip=partner.zip, - city=partner.city, - state=partner.state_id.name, - country=partner.country_id.name)) - if result is None: - result = geo_find(geo_query_address( - city=partner.city, - state=partner.state_id.name, - country=partner.country_id.name - )) - + result = partner._geo_localize(apikey, + partner.street, + partner.zip, + partner.city, + partner.state_id.name, + partner.country_id.name) if result: partner.write({ 'partner_latitude': result[0], diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index c239de5515e..e2bcee1aa2e 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -632,6 +632,8 @@ class Meeting(models.Model): recurring_date = recurring_date.replace(tzinfo=None) else: recurring_date = todate(meeting.recurrent_id_date) + if date_field == "stop": + recurring_date += timedelta(hours=self.duration) rset1.exdate(recurring_date) invalidate = True return [d.astimezone(pytz.UTC) if d.tzinfo else d for d in rset1 if d.year < MAXYEAR] diff --git a/addons/calendar/tests/test_calendar_recurrent_event_case2.py b/addons/calendar/tests/test_calendar_recurrent_event_case2.py index 1f85dd83853..98b42f248b9 100644 --- a/addons/calendar/tests/test_calendar_recurrent_event_case2.py +++ b/addons/calendar/tests/test_calendar_recurrent_event_case2.py @@ -85,14 +85,23 @@ class TestRecurrentEvent(common.TransactionCase): for meeting in meetings: self.assertEqual(meeting.name, 'Sprint Review for google modules', 'Name not changed for id: %s' % meeting.id) + # I detach first occurrence to check it is not modified by changing recurrent event. + min(meetings, key=lambda m: m.start).detach_recurring_event() + # I change description of my weekly meeting Review code with programmer. idval = '%d-%s' % (self.calendar_event_sprint_review.id, '20110425124700') self.CalendarEvent.browse(idval).write({'description': 'Review code of the module: sync_google_calendar.'}) - # I check whether that all the records of this recurrence has been edited. - meetings = self.CalendarEvent.search([('recurrent_id', '=', self.calendar_event_sprint_review.id)]) - for meeting in meetings: - self.assertEqual(meeting.description, 'Review code of the module: sync_google_calendar.', 'Description not changed for id: %s' % meeting.id) + # I check that detached event has not been edited. + detached_meeting = self.CalendarEvent.search([('recurrent_id', '=', self.calendar_event_sprint_review.id)]) + self.assertEqual(detached_meeting.description, False, 'Detached event description changed for id: %s' % meeting.id) + + # I verify wether I find an event by date range when subsequent to a detached one. + last_meeting = max(meetings, key=lambda m: m.start) + meetings = self.CalendarEvent.with_context({'virtual_id': True}).search([ + ('start', '<=', last_meeting.stop), ('stop', '>=', last_meeting.start) + ]) + self.assertEqual(meetings.id, last_meeting.id, 'Last event should be found searching it by date range') # I update the description of two meetings, and check that both have been updated self.calendar_event_sprint_review.write({'description': "Some description"}) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index c0dade4c565..89ea7efcd43 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -938,7 +938,7 @@ class Lead(models.Model): email = '%s@%s' % (alias_record.alias_name, alias_record.alias_domain) email_link = "%s" % (email, email) sub_title = _('or send an email to %s') % (email_link) - return '

%s

%s

' % (help_title, sub_title) + return '

%s

%s

' % (help_title, sub_title) @api.multi def log_meeting(self, meeting_subject, meeting_date, duration): diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 036752a6e3f..79afb2e41f8 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -147,14 +147,14 @@ class HrExpense(models.Model): @api.model def get_empty_list_help(self, help_message): - if help_message: + if help_message and "oe_view_nocontent_smiling_face" not in help_message: use_mailgateway = self.env['ir.config_parameter'].sudo().get_param('hr_expense.use_mailgateway') alias_record = use_mailgateway and self.env.ref('hr_expense.mail_alias_expense') or False if alias_record and alias_record.alias_domain and alias_record.alias_name: link = "%(email)s" % { 'email': '%s@%s' % (alias_record.alias_name, alias_record.alias_domain) } - return '

%s

%s

' % ( + return '

%s

%s

' % ( _('Add a new expense,'), _('or send receipts by email to %s.') % (link),) return super(HrExpense, self).get_empty_list_help(help_message) diff --git a/addons/l10n_co/models/res_partner.py b/addons/l10n_co/models/res_partner.py index 2de03275412..d2b6d7fe6f0 100644 --- a/addons/l10n_co/models/res_partner.py +++ b/addons/l10n_co/models/res_partner.py @@ -45,7 +45,7 @@ class ResPartner(models.Model): except ValueError: partner.l10n_co_verification_code = False - @api.constrains('vat', 'commercial_partner_country_id', 'l10n_co_document_type') + @api.constrains('vat', 'country_id', 'l10n_co_document_type') def check_vat(self): # check_vat is implemented by base_vat which this localization # doesn't directly depend on. It is however automatically diff --git a/addons/mail/models/ir_actions.py b/addons/mail/models/ir_actions.py index bd4b03f3a4c..0f5cbb8708e 100644 --- a/addons/mail/models/ir_actions.py +++ b/addons/mail/models/ir_actions.py @@ -48,7 +48,11 @@ class ServerActions(models.Model): # TDE CLEANME: when going to new api with server action, remove action if not action.template_id or not self._context.get('active_id'): return False - action.template_id.send_mail(self._context.get('active_id'), force_send=False, raise_exception=False) + # Clean context from default_type to avoid making attachment + # with wrong values in subsequent operations + cleaned_ctx = dict(self.env.context) + cleaned_ctx.pop('default_type', None) + action.template_id.with_context(cleaned_ctx).send_mail(self._context.get('active_id'), force_send=False, raise_exception=False) return False @api.model diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index f7fd19d50a9..00b8c57216d 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -365,7 +365,9 @@ class MailThread(models.AbstractModel): 'email_link': email_link } } - return "%(static_help)s

%(dyn_help)s

" % { + # do not add alias two times if it was added previously + if "oe_view_nocontent_alias" not in help: + return "%(static_help)s

%(dyn_help)s

" % { 'static_help': help, 'dyn_help': _("Create a new %(document)s by sending an email to %(email_link)s") % { 'document': document_name, diff --git a/addons/mail/static/src/js/activity.js b/addons/mail/static/src/js/activity.js index fce7eb29f6f..6e66d73ea07 100644 --- a/addons/mail/static/src/js/activity.js +++ b/addons/mail/static/src/js/activity.js @@ -187,6 +187,28 @@ var Activity = AbstractActivityField.extend({ this.trigger_up('reload_mail_fields', fieldsToReload); }, + /** Binds a focusout handler on a bootstrap popover + * Useful to do some operations on the popover's HTML, + * like keeping the user's input for the feedback + * @param {JQuery} $popover_el: the element on which + * the popover() method has been called + */ + _bindPopoverFocusout: function ($popover_el) { + var self = this; + // Retrieve the actual popover's HTML + var $popover = $popover_el.data("bs.popover").tip(); + var activity_id = $popover_el.data('activity-id'); + $popover.off('focusout'); + $popover.focusout(function (e) { + // outside click of popover hides the popover + // e.relatedTarget is the element receiving the focus + self.feedbackValue[activity_id] = $popover.find('#activity_feedback').val().trim(); + if(!$popover.is(e.relatedTarget) && !$popover.find(e.relatedTarget).length) { + $popover_el.popover('hide'); + } + }); + }, + // handlers _onClickRedirect: function (ev) { var id = $(ev.target).data('oe-id'); @@ -236,19 +258,23 @@ var Activity = AbstractActivityField.extend({ }) .then(this._reload.bind(this, {activity: true})); }, + _onMarkActivityDone: function (event) { event.preventDefault(); var self = this; + this.feedbackValue = this.feedbackValue || {}; var $popover_el = $(event.currentTarget); var activity_id = $popover_el.data('activity-id'); var previous_activity_type_id = $popover_el.data('previous-activity-type-id'); if (!$popover_el.data('bs.popover')) { + this.feedbackValue[activity_id] = ""; $popover_el.popover({ title : _t('Feedback'), html: 'true', trigger:'click', content : function() { var $popover = $(QWeb.render("mail.activity_feedback_form", {'previous_activity_type_id': previous_activity_type_id})); + $popover.find('#activity_feedback').val(self.feedbackValue[activity_id]); $popover.on('click', '.o_activity_popover_done_next', function () { var feedback = _.escape($popover.find('#activity_feedback').val()); var previous_activity_type_id = $popover_el.data('previous-activity-type-id'); @@ -272,14 +298,7 @@ var Activity = AbstractActivityField.extend({ }).on("shown.bs.popover", function () { var $popover = $(this).data("bs.popover").tip(); $popover.find('#activity_feedback').focus(); - $popover.off('focusout'); - $popover.focusout(function (e) { - // outside click of popover hide the popover - // e.relatedTarget is the element receiving the focus - if(!$popover.is(e.relatedTarget) && !$popover.find(e.relatedTarget).length) { - $popover.popover('hide'); - } - }); + self._bindPopoverFocusout($(this)); }).popover('show'); } }, diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js index f1f6097cb97..f98cd1382a8 100644 --- a/addons/mail/static/tests/chatter_tests.js +++ b/addons/mail/static/tests/chatter_tests.js @@ -17,6 +17,8 @@ var createBusService = mailTestUtils.createBusService; var createAsyncView = testUtils.createAsyncView; var createView = testUtils.createView; +var Activity = require('mail.Activity'); + QUnit.module('mail', {}, function () { QUnit.module('Chatter', { @@ -72,6 +74,7 @@ QUnit.module('Chatter', { type: 'selection', selection: [['overdue', 'Overdue'], ['today', 'Today'], ['planned', 'Planned']], }, + note : { string: "Note", type: "char" }, }, }, 'mail.activity.type': { @@ -143,6 +146,73 @@ QUnit.test('basic rendering', function (assert) { form.destroy(); }); +QUnit.test('Activity Done keep feedback on blur', function (assert) { + assert.expect(3); + var done = assert.async(); + + this.data['mail.activity'].records = [ + {activity_type_id: 1, id: 1, user_id: 2, state: 'today', note: 'But I\'m talkin\' about Shaft'}, + ]; + this.data.partner.records[0].activity_ids = [1]; + + var shownDef = $.Deferred(); + var hiddenDef = $.Deferred(); + testUtils.patch(Activity, { + _bindPopoverFocusout: function () { + this._super.apply(this, arguments); + shownDef.resolve(); + }, + }); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + res_id: 2, + arch:'
' + + '
' + + '' + + '
' + + '
', + }); + + // sanity checks + var $activityEl = form.$('.o_mail_activity[name=activity_ids]'); + assert.strictEqual($activityEl.find('.o_thread_message').length, 1, + 'There should be one activity'); + assert.strictEqual($activityEl.find('.o_thread_message .o_thread_message_note').text().trim(), + 'But I\'m talkin\' about Shaft', 'The activity should have the right note'); + + var $popoverEl = $activityEl.find('.o_thread_message_tools .o_activity_done'); + $popoverEl.on('hidden.bs.popover', hiddenDef.resolve.bind(hiddenDef)); + + // open popover + $popoverEl.click(); + + shownDef.then(function () { + // write a feedback and focusout + var $feedbackPopover = $popoverEl.data('bs.popover').tip(); + $feedbackPopover.find('#activity_feedback').val('John Shaft').focusout(); + + hiddenDef.then(function () { + shownDef = $.Deferred(); + + // re-open popover + $popoverEl.click(); + + shownDef.then(function () { + var $feedbackPopover = $popoverEl.data('bs.popover').tip(); + assert.strictEqual($feedbackPopover.find('#activity_feedback').val(), 'John Shaft', + "feedback should have been kept"); + + form.destroy(); + testUtils.unpatch(Activity); + done(); + }); + }); + }); +}); + QUnit.test('chatter in create mode', function (assert) { assert.expect(9); diff --git a/addons/membership/models/partner.py b/addons/membership/models/partner.py index dbb8abb5ae9..4ac0cedb4b0 100644 --- a/addons/membership/models/partner.py +++ b/addons/membership/models/partner.py @@ -164,8 +164,10 @@ class Partner(models.Model): @api.model def _cron_update_membership(self): - # used to recompute 'membership_state'; should no longer be necessary - pass + partners = self.search([('membership_state', 'in', ['invoiced', 'paid'])]) + # mark the field to be recomputed, and recompute it + partners._recompute_todo(self._fields['membership_state']) + self.recompute() @api.multi def create_membership_invoice(self, product_id=None, datas=None): diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index eac470a8be5..9ee65f0df1d 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -77,6 +77,8 @@ class ChangeProductionQty(models.TransientModel): wo.qty_producing = quantity if wo.qty_produced < wo.qty_production and wo.state == 'done': wo.state = 'progress' + if wo.qty_produced == wo.qty_production and wo.state == 'progress': + wo.state = 'done' # assign moves; last operation receive all unassigned moves # TODO: following could be put in a function as it is similar as code in _workorders_create # TODO: only needed when creating new moves diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 16ceb465383..f27239936de 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -196,9 +196,13 @@ class PaymentAcquirer(models.Model): def _check_required_if_provider(self): """ If the field has 'required_if_provider=""' attribute, then it required if record.provider is . """ + empty_field = [] for acquirer in self: - if any(getattr(f, 'required_if_provider', None) == acquirer.provider and not acquirer[k] for k, f in self._fields.items()): - return False + for k, f in acquirer._fields.items(): + if getattr(f, 'required_if_provider', None) == acquirer.provider and not acquirer[k]: + empty_field.append(self.env['ir.model.fields'].search([('name', '=', k), ('model', '=', acquirer._name)]).field_description) + if empty_field: + raise ValidationError((', ').join(empty_field)) return True _constraints = [ diff --git a/addons/point_of_sale/views/pos_config_view.xml b/addons/point_of_sale/views/pos_config_view.xml index e70428b911b..fd33ecb2fd4 100644 --- a/addons/point_of_sale/views/pos_config_view.xml +++ b/addons/point_of_sale/views/pos_config_view.xml @@ -435,7 +435,7 @@ Operation type used to record product pickings
- +
diff --git a/addons/rating/views/rating_view.xml b/addons/rating/views/rating_view.xml index a7ec28584bb..61ed8f14d98 100644 --- a/addons/rating/views/rating_view.xml +++ b/addons/rating/views/rating_view.xml @@ -96,7 +96,7 @@ on - + diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml index 7e763917c4c..1b084c13cb0 100644 --- a/addons/sale/views/sale_views.xml +++ b/addons/sale/views/sale_views.xml @@ -384,7 +384,7 @@ - + diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 4a8a85ee606..07b9524d7b6 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -294,6 +294,13 @@ class SaleOrderLine(models.Model): }) return values + def _get_qty_procurement(self): + self.ensure_one() + qty = 0.0 + for move in self.move_ids.filtered(lambda r: r.state != 'cancel'): + qty += move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom, rounding_method='HALF-UP') + return qty + @api.multi def _action_launch_procurement_rule(self): """ @@ -306,9 +313,7 @@ class SaleOrderLine(models.Model): for line in self: if line.state != 'sale' or not line.product_id.type in ('consu','product'): continue - qty = 0.0 - for move in line.move_ids.filtered(lambda r: r.state != 'cancel'): - qty += move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom, rounding_method='HALF-UP') + qty = line._get_qty_procurement() if float_compare(qty, line.product_uom_qty, precision_digits=precision) >= 0: continue diff --git a/addons/sale_timesheet/models/account_invoice.py b/addons/sale_timesheet/models/account_invoice.py index 9a9e89cab36..b07f2990584 100644 --- a/addons/sale_timesheet/models/account_invoice.py +++ b/addons/sale_timesheet/models/account_invoice.py @@ -51,15 +51,19 @@ class AccountInvoice(models.Model): self._compute_timesheet_revenue() return result + def _get_compute_timesheet_revenue_domain(self, so_line_ids): + return [ + ('so_line', 'in', so_line_ids), + ('project_id', '!=', False), + ('timesheet_invoice_id', '=', False), + ('timesheet_invoice_type', 'in', ['billable_time', 'billable_fixed']) + ] + def _compute_timesheet_revenue(self): for invoice in self: for invoice_line in invoice.invoice_line_ids.filtered(lambda line: line.product_id.type == 'service').sorted(key=lambda inv_line: (inv_line.invoice_id, inv_line.id)): - uninvoiced_timesheet_lines = self.env['account.analytic.line'].sudo().search([ - ('so_line', 'in', invoice_line.sale_line_ids.ids), - ('project_id', '!=', False), - ('timesheet_invoice_id', '=', False), - ('timesheet_invoice_type', 'in', ['billable_time', 'billable_fixed']) - ]) + domain = self._get_compute_timesheet_revenue_domain(invoice_line.sale_line_ids.ids) + uninvoiced_timesheet_lines = self.env['account.analytic.line'].sudo().search(domain) # NOTE JEM : changing quantity (or unit price) of invoice line does not impact the revenue calculation. (FP specs) if uninvoiced_timesheet_lines: diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 8da096cb4bd..9a932d64e88 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -457,8 +457,9 @@ class Picking(models.Model): else: location_dest_id, supplierloc = self.env['stock.warehouse']._get_partner_locations() - self.location_id = location_id - self.location_dest_id = location_dest_id + if self.state == 'draft': + self.location_id = location_id + self.location_dest_id = location_dest_id # TDE CLEANME move into onchange_partner_id if self.partner_id and self.partner_id.picking_warn: if self.partner_id.picking_warn == 'no-message' and self.partner_id.parent_id: diff --git a/addons/stock/tests/test_packing_neg.py b/addons/stock/tests/test_packing_neg.py index afda606e9a6..9b05d998af5 100644 --- a/addons/stock/tests/test_packing_neg.py +++ b/addons/stock/tests/test_packing_neg.py @@ -24,23 +24,24 @@ class TestPackingNeg(TransactionCase): }) # Create an incoming picking for this product of 300 PCE from suppliers to stock - default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get())) - default_get_vals.update({ + vals = { 'name': 'Incoming picking (negative product)', 'partner_id': self.ref('base.res_partner_2'), 'picking_type_id': self.ref('stock.picking_type_in'), + 'location_id': self.ref('stock.stock_location_suppliers'), + 'location_dest_id': self.ref('stock.stock_location_stock'), 'move_lines': [(0, 0, { + 'name': 'NEG', 'product_id': product_neg.id, + 'product_uom': product_neg.uom_id.id, 'product_uom_qty': 300.00, 'location_id': self.ref('stock.stock_location_suppliers'), 'location_dest_id': self.ref('stock.stock_location_stock'), })], - }) - pick_neg = self.env['stock.picking'].new(default_get_vals) + } + pick_neg = self.env['stock.picking'].create(vals) pick_neg.onchange_picking_type() pick_neg.move_lines.onchange_product_id() - vals = pick_neg._convert_to_write(pick_neg._cache) - pick_neg = self.env['stock.picking'].create(vals) # Confirm and assign picking pick_neg.action_confirm() @@ -80,23 +81,24 @@ class TestPackingNeg(TransactionCase): pick_neg.action_done() # Make a delivery order of 300 pieces to the customer - default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get())) - default_get_vals.update({ + vals = { 'name': 'outgoing picking (negative product)', 'partner_id': self.ref('base.res_partner_4'), 'picking_type_id': self.ref('stock.picking_type_out'), + 'location_id': self.ref('stock.stock_location_stock'), + 'location_dest_id': self.ref('stock.stock_location_customers'), 'move_lines': [(0, 0, { + 'name': 'NEG', 'product_id': product_neg.id, + 'product_uom': product_neg.uom_id.id, 'product_uom_qty': 300.00, 'location_id': self.ref('stock.stock_location_stock'), 'location_dest_id': self.ref('stock.stock_location_customers'), })], - }) - delivery_order_neg = self.env['stock.picking'].new(default_get_vals) + } + delivery_order_neg = self.env['stock.picking'].create(vals) delivery_order_neg.onchange_picking_type() delivery_order_neg.move_lines.onchange_product_id() - vals = delivery_order_neg._convert_to_write(delivery_order_neg._cache) - delivery_order_neg = self.env['stock.picking'].create(vals) # Assign and confirm delivery_order_neg.action_confirm() @@ -136,23 +138,24 @@ class TestPackingNeg(TransactionCase): self.assertEqual(pallet_3_stock_qty, 50, "Should have 50 pieces in stock on pallet 3") # Create a picking for reconciling the negative quant - default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get())) - default_get_vals.update({ + vals = { 'name': 'reconciling_delivery', 'partner_id': self.ref('base.res_partner_4'), 'picking_type_id': self.ref('stock.picking_type_in'), + 'location_id': self.ref('stock.stock_location_suppliers'), + 'location_dest_id': self.ref('stock.stock_location_stock'), 'move_lines': [(0, 0, { + 'name': 'NEG', 'product_id': product_neg.id, + 'product_uom': product_neg.uom_id.id, 'product_uom_qty': 20.0, 'location_id': self.ref('stock.stock_location_suppliers'), 'location_dest_id': self.ref('stock.stock_location_stock'), })], - }) - delivery_reconcile = self.env['stock.picking'].new(default_get_vals) + } + delivery_reconcile = self.env['stock.picking'].create(vals) delivery_reconcile.onchange_picking_type() delivery_reconcile.move_lines.onchange_product_id() - vals = delivery_reconcile._convert_to_write(delivery_reconcile._cache) - delivery_reconcile = self.env['stock.picking'].create(vals) # Receive 20 products with lot neg in stock with a new incoming shipment that should be on pallet 2 delivery_reconcile.action_confirm() diff --git a/addons/stock/tests/test_proc_rule.py b/addons/stock/tests/test_proc_rule.py index 044236729c7..ff1f34e3cc4 100644 --- a/addons/stock/tests/test_proc_rule.py +++ b/addons/stock/tests/test_proc_rule.py @@ -27,26 +27,23 @@ class TestProcRule(TransactionCase): 'route_ids': [(4, product_route.id)]}) # Create Delivery Order of 10 `product.product_product_3` from Output -> Customer - default_get_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get())) - default_get_vals.update({ + product = self.env.ref('product.product_product_3') + vals = { 'name': 'Delivery order for procurement', 'partner_id': self.ref('base.res_partner_2'), 'picking_type_id': self.ref('stock.picking_type_out'), + 'location_id': self.ref('stock.stock_location_output'), + 'location_dest_id': self.ref('stock.stock_location_customers'), 'move_lines': [(0, 0, { - 'product_id': self.ref('product.product_product_3'), + 'name': '/', + 'product_id': product.id, + 'product_uom': product.uom_id.id, 'product_uom_qty': 10.00, 'procure_method': 'make_to_order', })], - }) - pick_output = self.env['stock.picking'].new(default_get_vals) - pick_output.onchange_picking_type() - pick_output.move_lines.onchange_product_id() - pick_output.update({ - 'location_id': self.ref('stock.stock_location_output'), - 'location_dest_id': self.ref('stock.stock_location_customers'), - }) - vals = pick_output._convert_to_write(pick_output._cache) + } pick_output = self.env['stock.picking'].create(vals) + pick_output.move_lines.onchange_product_id() # Confirm delivery order. pick_output.action_confirm() diff --git a/addons/stock/tests/test_wise_operator.py b/addons/stock/tests/test_wise_operator.py index 4b56fc21d27..f4864d81bc3 100644 --- a/addons/stock/tests/test_wise_operator.py +++ b/addons/stock/tests/test_wise_operator.py @@ -17,25 +17,25 @@ class TestWiseOperator(TransactionCase): 'uom_po_id': self.ref('uom.product_uom_unit'), }) - picking_default_vals = self.env['stock.picking'].default_get(list(self.env['stock.picking'].fields_get())) - # Create an incoming picking for this product of 10 PCE from suppliers to stock - vals = dict(picking_default_vals, **{ + vals = { 'name': 'Incoming picking (wise unit)', 'partner_id': self.ref('base.res_partner_2'), 'picking_type_id': self.ref('stock.picking_type_in'), + 'location_id': self.ref('stock.stock_location_suppliers'), + 'location_dest_id': self.ref('stock.stock_location_stock'), 'move_lines': [(0, 0, { + 'name': '/', 'product_id': product_wise.id, + 'product_uom': product_wise.uom_id.id, 'product_uom_qty': 10.00, 'location_id': self.ref('stock.stock_location_suppliers'), 'location_dest_id': self.ref('stock.stock_location_stock'), })], - }) - pick1_wise = self.env['stock.picking'].new(vals) + } + pick1_wise = self.env['stock.picking'].create(vals) pick1_wise.onchange_picking_type() pick1_wise.move_lines.onchange_product_id() - vals = pick1_wise._convert_to_write(pick1_wise._cache) - pick1_wise = self.env['stock.picking'].create(vals) # Confirm and assign picking and prepare partial pick1_wise.action_confirm() @@ -65,22 +65,24 @@ class TestWiseOperator(TransactionCase): self.assertEqual(len(records.ids), 3, "The number of quants created is not correct") # Make a delivery order of 5 pieces to the customer - vals = dict(picking_default_vals, **{ + vals = { 'name': 'outgoing picking 1 (wise unit)', 'partner_id': self.ref('base.res_partner_4'), 'picking_type_id': self.ref('stock.picking_type_out'), + 'location_id': self.ref('stock.stock_location_stock'), + 'location_dest_id': self.ref('stock.stock_location_customers'), 'move_lines': [(0, 0, { + 'name': '/', 'product_id': product_wise.id, + 'product_uom': product_wise.uom_id.id, 'product_uom_qty': 5.0, 'location_id': self.ref('stock.stock_location_stock'), 'location_dest_id': self.ref('stock.stock_location_customers'), })], - }) - delivery_order_wise1 = self.env['stock.picking'].new(vals) + } + delivery_order_wise1 = self.env['stock.picking'].create(vals) delivery_order_wise1.onchange_picking_type() delivery_order_wise1.move_lines.onchange_product_id() - vals = delivery_order_wise1._convert_to_write(delivery_order_wise1._cache) - delivery_order_wise1 = self.env['stock.picking'].create(vals) # Assign and confirm delivery_order_wise1.action_confirm() @@ -88,22 +90,24 @@ class TestWiseOperator(TransactionCase): self.assertEqual(delivery_order_wise1.state, 'assigned') # Make a delivery order of 5 pieces to the customer - vals = dict(picking_default_vals, **{ + vals = { 'name': 'outgoing picking 2 (wise unit)', 'partner_id': self.ref('base.res_partner_4'), 'picking_type_id': self.ref('stock.picking_type_out'), + 'location_id': self.ref('stock.stock_location_stock'), + 'location_dest_id': self.ref('stock.stock_location_customers'), 'move_lines': [(0, 0, { + 'name': '/', 'product_id': product_wise.id, + 'product_uom': product_wise.uom_id.id, 'product_uom_qty': 5.0, 'location_id': self.ref('stock.stock_location_stock'), 'location_dest_id': self.ref('stock.stock_location_customers'), })], - }) - delivery_order_wise2 = self.env['stock.picking'].new(vals) + } + delivery_order_wise2 = self.env['stock.picking'].create(vals) delivery_order_wise2.onchange_picking_type() delivery_order_wise2.move_lines.onchange_product_id() - vals = delivery_order_wise2._convert_to_write(delivery_order_wise2._cache) - delivery_order_wise2 = self.env['stock.picking'].create(vals) # Assign and confirm delivery_order_wise2.action_confirm() diff --git a/addons/stock_dropshipping/models/__init__.py b/addons/stock_dropshipping/models/__init__.py index c617a28246d..7d6f1be055f 100644 --- a/addons/stock_dropshipping/models/__init__.py +++ b/addons/stock_dropshipping/models/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import purchase \ No newline at end of file +from . import purchase +from . import sale diff --git a/addons/stock_dropshipping/models/sale.py b/addons/stock_dropshipping/models/sale.py new file mode 100644 index 00000000000..81f975cbce6 --- /dev/null +++ b/addons/stock_dropshipping/models/sale.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models, fields + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + purchase_line_ids = fields.One2many('purchase.order.line', 'sale_line_id') + + @api.multi + def _get_qty_procurement(self): + if not self.move_ids.filtered(lambda r: r.state != 'cancel') and self.purchase_line_ids.filtered(lambda r: r.state != 'cancel'): + qty = 0.0 + for po_line in self.purchase_line_ids.filtered(lambda r: r.state != 'cancel'): + qty += po_line.product_uom._compute_quantity(po_line.product_qty, self.product_uom, rounding_method='HALF-UP') + return qty + else: + return super(SaleOrderLine, self)._get_qty_procurement() + diff --git a/addons/stock_dropshipping/tests/__init__.py b/addons/stock_dropshipping/tests/__init__.py index c060ad7247b..990bd0591e3 100644 --- a/addons/stock_dropshipping/tests/__init__.py +++ b/addons/stock_dropshipping/tests/__init__.py @@ -6,4 +6,3 @@ from . import test_dropship from . import test_lifo_price from . import test_procurement_exception from . import test_stockvaluation - diff --git a/addons/stock_dropshipping/tests/test_dropship.py b/addons/stock_dropshipping/tests/test_dropship.py index 7f06c437fa3..9837d93f0af 100644 --- a/addons/stock_dropshipping/tests/test_dropship.py +++ b/addons/stock_dropshipping/tests/test_dropship.py @@ -5,6 +5,50 @@ from odoo.tests import common, Form from odoo.tools import mute_logger +class TestDropship(common.TransactionCase): + def test_change_qty(self): + # enable the dropship and MTO route on the product + prod = self.env.ref('product.product_product_8') + dropshipping_route = self.env.ref('stock_dropshipping.route_drop_shipping') + mto_route = self.env.ref('stock.route_warehouse0_mto') + prod.write({'route_ids': [(6, 0, [dropshipping_route.id, mto_route.id])]}) + + # add a vendor + vendor1 = self.env['res.partner'].create({'name': 'vendor1'}) + seller1 = self.env['product.supplierinfo'].create({ + 'name': vendor1.id, + 'price': 8, + }) + prod.write({'seller_ids': [(6, 0, [seller1.id])]}) + + # sell one unit of this product + cust = self.env['res.partner'].create({'name': 'customer1'}) + so = self.env['sale.order'].create({ + 'partner_id': cust.id, + 'partner_invoice_id': cust.id, + 'partner_shipping_id': cust.id, + 'order_line': [(0, 0, { + 'name': prod.name, + 'product_id': prod.id, + 'product_uom_qty': 1.00, + 'product_uom': prod.uom_id.id, + 'price_unit': 12, + })], + 'pricelist_id': self.env.ref('product.list0').id, + 'picking_policy': 'direct', + }) + so.action_confirm() + po = self.env['purchase.order'].search([('group_id', '=', so.procurement_group_id.id)]) + po_line = po.order_line + + # Check the qty on the P0 + self.assertAlmostEqual(po_line.product_qty, 1.00) + + # Update qty on SO and check PO + so.order_line.product_uom_qty = 2.00 + self.assertAlmostEqual(po_line.product_qty, 2.00) + + class TestDropship(common.TransactionCase): def test_00_dropship(self): diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js index bce77a352ea..45013858e1b 100644 --- a/addons/web/static/src/js/chrome/abstract_web_client.js +++ b/addons/web/static/src/js/chrome/abstract_web_client.js @@ -182,7 +182,9 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi // If it is not handled, we should display something clearer than the common crash_manager error dialog // since it won't show anything except "Script error." // This link will probably explain it better: https://blog.sentry.io/2016/05/17/what-is-script-error.html - if (message === "Script error." && !file && !line && !col && !error) { + if (!file && !line && !col) { + // Chrome and Opera set "Script error." on the `message` and hide the `error` + // Firefox handles the "Script error." directly. It sets the error thrown by the CORS file into `error` if (window.onOriginError) { window.onOriginError(); delete window.onOriginError; @@ -190,7 +192,7 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi crash_manager.show_error({ type: _t("Odoo Client Error"), message: _t("Unknown CORS error"), - data: {debug: _t("An unknown CORS error occured. The error probably originates from a JavaScript file served from a different origin.")}, + data: {debug: _t("An unknown CORS error occured. The error probably originates from a JavaScript file served from a different origin. (Opening your browser console might give you a hint on the error.)")}, }); } } else { diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js index 5d606324023..0328ff1e0e6 100644 --- a/addons/web/static/src/js/views/kanban/kanban_model.js +++ b/addons/web/static/src/js/views/kanban/kanban_model.js @@ -61,15 +61,11 @@ var KanbanModel = BasicModel.extend({ if (!groupByField || groupByField.type !== 'many2one') { return $.Deferred().reject(); // only supported when grouped on m2o } - // ignore action default which may be for another model - var context = _.pick(parent.context, function (value, key) { - return key.slice(0,8) !== 'default_'; - }); return this._rpc({ model: groupByField.relation, method: 'name_create', args: [name], - context: context, // todo: combine with view context + context: parent.context, // todo: combine with view context }) .then(function (result) { var newGroup = self._makeDataPoint({ diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js index 682b98f82fe..76ad3a82063 100644 --- a/addons/web/static/src/js/views/list/list_renderer.js +++ b/addons/web/static/src/js/views/list/list_renderer.js @@ -193,6 +193,7 @@ var ListRenderer = BasicRenderer.extend({ reject = columnInvisibleFields[c.attrs.name]; } if (!reject && c.attrs.widget === 'handle') { + self.hasHandle = true; self.handleField = c.attrs.name; } return reject; @@ -656,8 +657,6 @@ var ListRenderer = BasicRenderer.extend({ this._computeAggregates(); $table.toggleClass('o_list_view_grouped', is_grouped); $table.toggleClass('o_list_view_ungrouped', !is_grouped); - this.hasHandle = this.state.orderedBy.length === 0 || - this.state.orderedBy[0].name === this.handleField; if (is_grouped) { $table .append(this._renderHeader(true)) diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index e0bb22c0bb4..3a776a73a28 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -1907,7 +1907,7 @@ QUnit.module('ActionManager', { start: function () { var self = this; return this._super.apply(this, arguments).then(function () { - self.iframe.src = 'test: ' + self.iframe.getAttribute('src'); + self.iframe.src = 'test ' + self.iframe.getAttribute('src'); }); } }); @@ -1926,7 +1926,7 @@ QUnit.module('ActionManager', { if (route === '/report/check_wkhtmltopdf') { return $.when('broken'); } - if (route === 'test: /report/html/some_report') { + if (route === 'test /report/html/some_report') { return $.when(); } return this._super.apply(this, arguments); @@ -1947,7 +1947,7 @@ QUnit.module('ActionManager', { '/web/action/load', '/report/check_wkhtmltopdf', 'notification', - 'test: /report/html/some_report', // report client action's iframe + 'test /report/html/some_report', // report client action's iframe ]); actionManager.destroy(); diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js index 8c73dcc21e9..7680d8877b1 100644 --- a/addons/web/static/tests/views/kanban_tests.js +++ b/addons/web/static/tests/views/kanban_tests.js @@ -1157,43 +1157,6 @@ QUnit.module('Views', { kanban.destroy(); }); - QUnit.test('m2o group record created does not use action defaults', function (assert) { - assert.expect(1); - - var kanban = createView({ - View: KanbanView, - model: 'partner', - data: this.data, - arch: '' + - '' + - '
' + - '' + - '
' + - '
' + - '
', - groupBy: ['product_id'], - mockRPC: function (route, args) { - if (args.method === 'name_create') { - assert.notOk(_.has(args.kwargs.context, 'default_name'), - "default_* should be removed from context"); - } - return this._super.apply(this, arguments); - }, - viewOptions: { - context: { - default_name: 'default name partner', - }, - }, - }); - kanban.renderButtons(); - - kanban.$('.o_column_quick_create input').val('new product'); - kanban.$('.o_column_quick_create button.o_kanban_add').click(); - - kanban.destroy(); - }); - - QUnit.test('quick create record fail in grouped', function (assert) { assert.expect(7); diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 9f476a6f1c9..a6b28ed24e7 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -3235,76 +3235,6 @@ QUnit.module('Views', { list.destroy(); }); - QUnit.test('editable list, handle widget locks and unlocks on sort', function (assert) { - assert.expect(6); - - // we need another sortable field to lock/unlock the handle - this.data.foo.fields.amount.sortable = true; - // resequence makes sense on a sequence field, not on arbitrary fields - this.data.foo.records[0].int_field = 0; - this.data.foo.records[1].int_field = 1; - this.data.foo.records[2].int_field = 2; - this.data.foo.records[3].int_field = 3; - - var list = createView({ - View: ListView, - model: 'foo', - data: this.data, - arch: '' + - '' + - '' + - '', - }); - - assert.strictEqual(list.$('tbody').text(), '1200.00500.00300.000.00', - "default should be sorted by int_field"); - - // Drag and drop the fourth line in second position - testUtils.dragAndDrop( - list.$('.ui-sortable-handle').eq(3), - list.$('tbody tr').first(), - {position: 'bottom'} - ); - - // Handle should be unlocked at this point - assert.strictEqual(list.$('tbody').text(), '1200.000.00500.00300.00', - "drag and drop should have succeeded, as the handle is unlocked"); - - // Sorting by a field different for int_field should lock the handle - list.$('.o_column_sortable').eq(1).click(); - - assert.strictEqual(list.$('tbody').text(), '0.00300.00500.001200.00', - "should have been sorted by amount"); - - // Drag and drop the fourth line in second position (not) - testUtils.dragAndDrop( - list.$('.ui-sortable-handle').eq(3), - list.$('tbody tr').first(), - {position: 'bottom'} - ); - - assert.strictEqual(list.$('tbody').text(), '0.00300.00500.001200.00', - "drag and drop should have failed as the handle is locked"); - - // Sorting by int_field should unlock the handle - list.$('.o_column_sortable').eq(0).click(); - - assert.strictEqual(list.$('tbody').text(), '1200.000.00500.00300.00', - "records should be ordered as per the previous resequence"); - - // Drag and drop the fourth line in second position - testUtils.dragAndDrop( - list.$('.ui-sortable-handle').eq(3), - list.$('tbody tr').first(), - {position: 'bottom'} - ); - - assert.strictEqual(list.$('tbody').text(), '1200.00300.000.00500.00', - "drag and drop should have worked as the handle is unlocked"); - - list.destroy(); - }); - QUnit.test('editable list with handle widget with slow network', function (assert) { assert.expect(15); diff --git a/addons/web_settings_dashboard/static/src/js/dashboard.js b/addons/web_settings_dashboard/static/src/js/dashboard.js index 9f0ed3d7552..3b62be2228f 100644 --- a/addons/web_settings_dashboard/static/src/js/dashboard.js +++ b/addons/web_settings_dashboard/static/src/js/dashboard.js @@ -4,6 +4,7 @@ odoo.define('web_settings_dashboard', function (require) { var AbstractAction = require('web.AbstractAction'); var core = require('web.core'); var framework = require('web.framework'); +var session = require('web.session'); var Widget = require('web.Widget'); var QWeb = core.qweb; diff --git a/addons/web_settings_dashboard/static/tests/dashboard_tests.js b/addons/web_settings_dashboard/static/tests/dashboard_tests.js index c96087934d1..306ff7f363a 100644 --- a/addons/web_settings_dashboard/static/tests/dashboard_tests.js +++ b/addons/web_settings_dashboard/static/tests/dashboard_tests.js @@ -11,12 +11,12 @@ var Dashboard = webSettingsDashboard.Dashboard; function createDashboard(params) { var widget = new Widget(); var dashboard = new Dashboard(widget); - dashboard.all_dashboards = ['invitations']; // test only user invitations + dashboard.all_dashboards = params.dashboards || ['invitations']; // test only user invitations testUtils.addMockEnvironment(widget, params); var originalDestroy = Dashboard.prototype.destroy; - Dashboard.destroy = function () { + dashboard.destroy = function () { dashboard.destroy = originalDestroy; widget.destroy(); }; diff --git a/addons/website_crm_partner_assign/models/crm_lead.py b/addons/website_crm_partner_assign/models/crm_lead.py index b5f0c2d49c4..c9e76447d90 100644 --- a/addons/website_crm_partner_assign/models/crm_lead.py +++ b/addons/website_crm_partner_assign/models/crm_lead.py @@ -86,19 +86,10 @@ class CrmLead(models.Model): if lead.partner_latitude and lead.partner_longitude: continue if lead.country_id: - result = geo_find(geo_query_address(street=lead.street, - zip=lead.zip, - city=lead.city, - state=lead.state_id.name, - country=lead.country_id.name)) - - if result is None: - result = geo_find(geo_query_address( - city=lead.city, - state=lead.state_id.name, - country=lead.country_id.name - )) - + apikey = self.env['ir.config_parameter'].sudo().get_param('google.api_key_geocode') + result = self.env['res.partner']._geo_localize(apikey, + lead.street, lead.zip, lead.city, + lead.state_id.name, lead.country_id.name) if result: lead.write({ 'partner_latitude': result[0], diff --git a/addons/website_crm_partner_assign/tests/test_partner_assign.py b/addons/website_crm_partner_assign/tests/test_partner_assign.py index 3b4344e255f..83989c0a4d8 100644 --- a/addons/website_crm_partner_assign/tests/test_partner_assign.py +++ b/addons/website_crm_partner_assign/tests/test_partner_assign.py @@ -16,7 +16,7 @@ class TestPartnerAssign(TransactionCase): def setUp(self): super(TestPartnerAssign, self).setUp() - def geo_find(addr): + def geo_find(addr, apikey): return { 'Wavre, Belgium': (50.7158956, 4.6128075), 'Cannon Hill Park, B46 3AG Birmingham, United Kingdom': (52.45216, -1.898578), diff --git a/addons/website_quote/report/sale_order_templates.xml b/addons/website_quote/report/sale_order_templates.xml index ad67e5e9439..fa89626a186 100644 --- a/addons/website_quote/report/sale_order_templates.xml +++ b/addons/website_quote/report/sale_order_templates.xml @@ -3,6 +3,7 @@