diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 5aadd90b40f..0e84b278191 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -62,13 +62,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) @@ -81,6 +81,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 = {} diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index e4dd426c6c3..fd085d394eb 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -543,7 +543,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, @@ -553,6 +553,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 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'), diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 79a07f6c370..1baf41b5783 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1737,6 +1737,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 @@ -1807,7 +1808,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, + 'read': True, + }, context=context) return True diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 0a2a8a7136c..614da5933ee 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -72,6 +72,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']), + ] + class mrp_routing(osv.osv): diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index d145bbeb847..f59e05bb6e5 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -389,7 +389,7 @@ - + @@ -404,8 +404,8 @@ - - + +
diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 0690223b8ff..a2398b8330f 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: diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 321611dd398..1fc1297ee03 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -866,6 +866,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(); diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index 992ff85e3b4..f8c0290fd9b 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -878,6 +878,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['res.groups'].get_groups_by_application(cr, uid, context): if kind == 'selection': # selection group field