From b97578f689bb8be6e86de9885dd7613f37a0a7ac Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 16 Mar 2015 09:10:01 +0100 Subject: [PATCH 01/10] [FIX] view_form: sequence at item creation The sequence for new items in some models is simply set to a constant 10. Hence if 3 items had after reordering sequences 10, 11 and 12. If a new item is added, it would get after saving at the second position. This fix set the sequence of a new item to the maximum+1 or minimum-1 sequence of current items sequences (max if tree has editable="bottom", min if tree has editable="top"). opw-627830 --- addons/web/static/src/js/view_form.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 52065001693..83faa5e8626 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -855,6 +855,16 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } } } + // Heuristic to assign a proper sequence number for new records that + // are added in a dataset containing other lines with existing sequence numbers + if (!self.datarecord.id && self.fields.sequence && + !_.has(values, 'sequence') && !_.isEmpty(self.dataset.cache)) { + // Find current max or min sequence (editable top/bottom) + var current = _[prepend_on_create ? "min" : "max"]( + _.map(self.dataset.cache, function(o){return o.values.sequence}) + ); + values['sequence'] = prepend_on_create ? current - 1 : current + 1; + } if (form_invalid) { self.set({'display_invalid_fields': true}); first_invalid_field.focus(); From 52649934e33d8721db2632498f1c10e853ba9ce1 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 19 Mar 2015 11:33:04 +0100 Subject: [PATCH 02/10] [FIX] mrp: constraints capacity_per_cycle to be strictly positive A capacity per cycle only makes sense if it is strictly positive. This also prevents to divide by zero in _bom_explode. --- addons/mrp/mrp.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index a5d57114c37..2167f04190e 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -73,6 +73,16 @@ class mrp_workcenter(osv.osv): value = {'costs_hour': cost.standard_price} return {'value': value} + def _check_capacity_per_cycle(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if obj.capacity_per_cycle <= 0.0: + return False + return True + + _constraints = [ + (_check_capacity_per_cycle, 'The capacity per cycle must be strictly positive.', ['capacity_per_cycle']), + ] + mrp_workcenter() From 1b2c400fc13d85318a71ae9cb49b46bfeccadf23 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 18 Mar 2015 13:33:47 +0100 Subject: [PATCH 03/10] [FIX] account_voucher: consistency between exchange rate account and company In the accounting settings, we prevent having gain and loss accounts that are linked to a different company than the one selected for the chart of account. opw: 630494 --- addons/account_voucher/account_voucher.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 25046a68ed6..66da370e2f7 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -70,13 +70,13 @@ class account_config_settings(osv.osv_memory): type='many2one', relation='account.account', string="Gain Exchange Rate Account", - domain="[('type', '=', 'other')]"), + domain="[('type', '=', 'other'), ('company_id', '=', company_id)]"), 'expense_currency_exchange_account_id': fields.related( 'company_id', 'expense_currency_exchange_account_id', type="many2one", relation='account.account', string="Loss Exchange Rate Account", - domain="[('type', '=', 'other')]"), + domain="[('type', '=', 'other'), ('company_id', '=', company_id)]"), } def onchange_company_id(self, cr, uid, ids, company_id, context=None): res = super(account_config_settings, self).onchange_company_id(cr, uid, ids, company_id, context=context) @@ -89,6 +89,23 @@ class account_config_settings(osv.osv_memory): 'expense_currency_exchange_account_id': False}) return res + def _check_account_gain(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if obj.income_currency_exchange_account_id.company_id and obj.company_id != obj.income_currency_exchange_account_id.company_id: + return False + return True + + def _check_account_loss(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if obj.expense_currency_exchange_account_id.company_id and obj.company_id != obj.expense_currency_exchange_account_id.company_id: + return False + return True + + _constraints = [ + (_check_account_gain, 'The company of the gain exchange rate account must be the same than the company selected.', ['income_currency_exchange_account_id']), + (_check_account_loss, 'The company of the loss exchange rate account must be the same than the company selected.', ['expense_currency_exchange_account_id']), + ] + class account_voucher(osv.osv): def _check_paid(self, cr, uid, ids, name, args, context=None): res = {} From aac5c4798018e17fcd2d21cc56be381a1cd219b6 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 19 Mar 2015 10:34:22 +0100 Subject: [PATCH 04/10] [FIX] l10n_be_invoice_bba: only check BBA when modified The BBA communication is now only checked when provided as input (created or modified). Avoids useless check for uniqueness when it's not modified, and prevent errors when several invoices are modified in batch. opw: 629649 Closes #5700 --- addons/l10n_be_invoice_bba/invoice.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index 499e6e6c4ac..de28a544ecd 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -190,13 +190,10 @@ class account_invoice(osv.osv): reference_type = vals['reference_type'] else: reference_type = inv.reference_type or '' - if reference_type == 'bba': - if vals.has_key('reference'): - bbacomm = vals['reference'] - else: - bbacomm = inv.reference or '' - if self.check_bbacomm(bbacomm): - reference = re.sub('\D', '', bbacomm) + + if reference_type == 'bba' and 'reference' in vals: + if self.check_bbacomm(vals['reference']): + reference = re.sub('\D', '', vals['reference']) vals['reference'] = '+++' + reference[0:3] + '/' + reference[3:7] + '/' + reference[7:] + '+++' same_ids = self.search(cr, uid, [('id', '!=', inv.id), ('type', '=', 'out_invoice'), From 0c16c20c68ba12b5a2e7c35c3b87609ed6d846e4 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 23 Mar 2015 12:34:00 +0100 Subject: [PATCH 05/10] [FIX] hr_timesheet: timezone of anayltic sheets in sheet summary The timezone of hr_analytic_sheet should be the timezone of the employee as well, so sheet analytic lines and attendances lines are grouped within the same timezone, the timezone of the employees, so the time difference between the analytic lines and the attendances lines can be properly computed. Fixes #5809 Fixes #5379 Related to rev. 3bf1615ad40f23212a0fff23eeb506f3bcc69043 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 4fd0ecbdca7..ceb661f2bb6 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -549,7 +549,7 @@ class hr_timesheet_sheet_sheet_day(osv.osv): (( select min(hrt.id) as id, - 'UTC' as timezone, + p.tz as timezone, l.date::date as name, s.id as sheet_id, sum(l.unit_amount) as total_timesheet, @@ -559,6 +559,10 @@ class hr_timesheet_sheet_sheet_day(osv.osv): hr_analytic_timesheet hrt JOIN account_analytic_line l ON l.id = hrt.line_id LEFT JOIN hr_timesheet_sheet_sheet s ON s.id = hrt.sheet_id + JOIN hr_employee e ON s.employee_id = e.id + JOIN resource_resource r ON e.resource_id = r.id + LEFT JOIN res_users u ON r.user_id = u.id + LEFT JOIN res_partner p ON u.partner_id = p.id group by l.date::date, s.id, timezone ) union ( select From 3235eda7819a162a390ed5b31eeb2b5063c7a111 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 23 Mar 2015 15:20:36 +0100 Subject: [PATCH 06/10] [FIX] mail: notify parent message on message auto subscribe. When auto subscribing to a message (For instance, change the ```user_id``` field on a record, like an invoice) The new user is notified of the last message of the thread. He must be notified of the parent message as well, to have access to the first message of the thread, to prevent access rights issues to the thread. This mechanism is applied in the _notify method of model ```mail.message``` as well, for the same reasons. opw-630286 --- addons/mail/mail_thread.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 8a336f7cd01..0a233fe82a0 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1376,6 +1376,7 @@ class mail_thread(osv.AbstractModel): """ subtype_obj = self.pool.get('mail.message.subtype') follower_obj = self.pool.get('mail.followers') + notification_obj = self.pool.get('mail.notification') new_followers = dict() # fetch auto_follow_fields: res.users relation fields whose changes are tracked for subscription @@ -1446,7 +1447,16 @@ class mail_thread(osv.AbstractModel): ('model', '=', self._name), ('res_id', '=', record_id)], limit=1, context=context) if msg_ids: - self.pool.get('mail.notification')._notify(cr, uid, msg_ids[0], partners_to_notify=user_pids, context=context) + notification_obj._notify(cr, uid, msg_ids[0], partners_to_notify=user_pids, context=context) + message = message_obj.browse(cr, uid, msg_ids[0], context=context) + if message.parent_id: + partner_ids_to_parent_notify = set(user_pids).difference(partner.id for partner in message.parent_id.notified_partner_ids) + for partner_id in partner_ids_to_parent_notify: + notification_obj.create(cr, uid, { + 'message_id': message.parent_id.id, + 'partner_id': partner_id, + 'is_read': True, + }, context=context) return True From 132afa981ba08a1fba39112360d82403f08c326b Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 23 Mar 2015 15:46:32 +0100 Subject: [PATCH 07/10] [FIX] mail: is_read is the column name in 8.0. The column 'read' has been renamed 'is_read' in Odoo 8.0. --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 0a233fe82a0..fa6e55a1af3 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1455,7 +1455,7 @@ class mail_thread(osv.AbstractModel): notification_obj.create(cr, uid, { 'message_id': message.parent_id.id, 'partner_id': partner_id, - 'is_read': True, + 'read': True, }, context=context) return True From a36396b19206970e935fa7bc3e4415fcc0914cfb Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Sun, 22 Mar 2015 18:34:47 +0100 Subject: [PATCH 08/10] [FIX] sale: based amount to compute advanced invoices The based amount to compute advanced invoices must be the amount_untaxed. opw:630975 --- addons/sale/wizard/sale_make_invoice_advance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index c4798cc44d4..750d450e3be 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -105,7 +105,7 @@ class sale_advance_payment_inv(osv.osv_memory): raise osv.except_osv(_('Incorrect Data'), _('The value of Advance Amount must be positive.')) if wizard.advance_payment_method == 'percentage': - inv_amount = sale.amount_total * wizard.amount / 100 + inv_amount = sale.amount_untaxed * wizard.amount / 100 if not res.get('name'): res['name'] = self._translate_advance(cr, uid, percentage=True, context=dict(context, lang=sale.partner_id.lang)) % (wizard.amount) else: From a93ef48a7072f62e4b9dd728d54ddad901c92db4 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 24 Mar 2015 18:13:56 +0100 Subject: [PATCH 09/10] [FIX] base: access to preferences menu for portal users Since revs 53582c2ea6c165a03d03cbb52bd8525eff444d90 & f65c9130279cdd03e8bef928036bdff356ea2feb, this was no more possible for portal users to read groups on purpose, for privacy reasons. fields_get of res.users model is overriden, for the access rights form view features (The groups selections and checkboxes). At each call to fields_get, which happens at each call to fields_view_get on the res.users model, operations are done on the model res.groups (basically, to build the selection groups and checkboxes). So, each time a view of model res.users is displayed, whatever the view, operations on res.group model were performed. The thing is, these operations on res.groups are actually needed only for the user access rights view, or at least only for users having the group Administration > Access rights. These group operations aren't needed for the preferences view, nor for portal users. We therefore avoid to do these if the user is not part of the Administration > Access rights group, which lead to performances improvment, and solves the fact portal users couldn't access their user preferences view. opw-627391 --- openerp/addons/base/res/res_users.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index 65fb0499d35..1dcae1f657e 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -860,6 +860,8 @@ class users_view(osv.osv): def fields_get(self, cr, uid, allfields=None, context=None, write_access=True): res = super(users_view, self).fields_get(cr, uid, allfields, context, write_access) # add reified groups fields + if uid != SUPERUSER_ID and not self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager'): + return res for app, kind, gs in self.pool.get('res.groups').get_groups_by_application(cr, uid, context): if kind == 'selection': # selection group field From 881c10b8ec9ca56f7b748fc0ac382614d5adab9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BELLIER?= Date: Thu, 19 Mar 2015 16:13:12 +0100 Subject: [PATCH 10/10] [FIX] mrp: group attribute position group_mrp_properties is intended for the property_ids field only, not the other parts in the "Properties" page (probably wrongly named) --- addons/mrp/mrp_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 7e072d9d9ee..40d608b2a0f 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -389,7 +389,7 @@ - + @@ -404,8 +404,8 @@ - - + +