diff --git a/addons/account/account.py b/addons/account/account.py index 4d9baf36a17..3537c4f4c55 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -30,7 +30,7 @@ from openerp import SUPERUSER_ID from openerp import tools from openerp.osv import fields, osv, expression from openerp.tools.translate import _ -from openerp.tools.float_utils import float_round +from openerp.tools.float_utils import float_round as round import openerp.addons.decimal_precision as dp @@ -1937,15 +1937,15 @@ class account_tax(osv.osv): # 'base_code_id': fields.many2one('account.tax.code', 'Account Base Code', help="Use this code for the tax declaration."), 'tax_code_id': fields.many2one('account.tax.code', 'Account Tax Code', help="Use this code for the tax declaration."), - 'base_sign': fields.float('Base Code Sign', help="Usually 1 or -1."), - 'tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), + 'base_sign': fields.float('Base Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), + 'tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), # Same fields for refund invoices 'ref_base_code_id': fields.many2one('account.tax.code', 'Refund Base Code', help="Use this code for the tax declaration."), 'ref_tax_code_id': fields.many2one('account.tax.code', 'Refund Tax Code', help="Use this code for the tax declaration."), - 'ref_base_sign': fields.float('Refund Base Code Sign', help="Usually 1 or -1."), - 'ref_tax_sign': fields.float('Refund Tax Code Sign', help="Usually 1 or -1."), + 'ref_base_sign': fields.float('Refund Base Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), + 'ref_tax_sign': fields.float('Refund Tax Code Sign', help="Usually 1 or -1.", digits_compute=get_precision_tax()), 'include_base_amount': fields.boolean('Included in base amount', help="Indicates if the amount of tax must be included in the base amount for the computation of the next taxes"), 'company_id': fields.many2one('res.company', 'Company', required=True), 'description': fields.char('Tax Code'), @@ -2143,7 +2143,7 @@ class account_tax(osv.osv): tax_compute_precision = precision if taxes and taxes[0].company_id.tax_calculation_rounding_method == 'round_globally': tax_compute_precision += 5 - totalin = totalex = float_round(price_unit * quantity, precision) + totalin = totalex = round(price_unit * quantity, precision) tin = [] tex = [] for tax in taxes: diff --git a/addons/account_check_writing/account_voucher.py b/addons/account_check_writing/account_voucher.py index e4933708f7a..c3abe28eef0 100644 --- a/addons/account_check_writing/account_voucher.py +++ b/addons/account_check_writing/account_voucher.py @@ -41,6 +41,23 @@ class account_voucher(osv.osv): 'number': fields.char('Number', size=32), } + def _amount_to_text(self, cr, uid, amount, currency_id, context=None): + # Currency complete name is not available in res.currency model + # Exceptions done here (EUR, USD, BRL) cover 75% of cases + # For other currencies, display the currency code + currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context) + if currency.name.upper() == 'EUR': + currency_name = 'Euro' + elif currency.name.upper() == 'USD': + currency_name = 'Dollars' + elif currency.name.upper() == 'BRL': + currency_name = 'reais' + else: + currency_name = currency.name + #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed + #amount_in_word = amount_to_text(amount, context=context) + return amount_to_text(amount, currency=currency_name) + def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None): """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """ if not context: @@ -48,22 +65,7 @@ class account_voucher(osv.osv): default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context) if 'value' in default: amount = 'amount' in default['value'] and default['value']['amount'] or amount - - # Currency complete name is not available in res.currency model - # Exceptions done here (EUR, USD, BRL) cover 75% of cases - # For other currencies, display the currency code - currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context) - if currency.name.upper() == 'EUR': - currency_name = 'Euro' - elif currency.name.upper() == 'USD': - currency_name = 'Dollars' - elif currency.name.upper() == 'BRL': - currency_name = 'reais' - else: - currency_name = currency.name - #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed - #amount_in_word = amount_to_text(amount, context=context) - amount_in_word = amount_to_text(amount, currency=currency_name) + amount_in_word = self._amount_to_text(cr, uid, amount, currency_id, context=context) default['value'].update({'amount_in_word':amount_in_word}) if journal_id: allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing @@ -92,6 +94,19 @@ class account_voucher(osv.osv): }, 'nodestroy': True } + def create(self, cr, uid, vals, context=None): + if vals.get('amount') and vals.get('journal_id') and 'amount_in_word' not in vals: + vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], vals.get('currency_id') or \ + self.pool['account.journal'].browse(cr, uid, vals['journal_id'], context=context).currency.id or \ + self.pool['res.company'].browse(cr, uid, vals['company_id']).currency_id.id, context=context) + return super(account_voucher, self).create(cr, uid, vals, context=context) + + def write(self, cr, uid, ids, vals, context=None): + if vals.get('amount') and vals.get('journal_id') and 'amount_in_word' not in vals: + vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], vals.get('currency_id') or \ + self.pool['account.journal'].browse(cr, uid, vals['journal_id'], context=context).currency.id or \ + self.pool['res.company'].browse(cr, uid, vals['company_id']).currency_id.id, context=context) + return super(account_voucher, self).write(cr, uid, ids, vals, context=context) def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): """ diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index ca4a15bca6e..71008e0855b 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -463,14 +463,12 @@ def process_data(cr, uid, pool, res_ids, model, method, old_values=None, new_val # if at least one modification has been found for model_id, resource_id in lines: line_model = pool.get('ir.model').browse(cr, SUPERUSER_ID, model_id).model - name = pool.get(line_model).name_get(cr, uid, [resource_id])[0][1] vals = { 'method': method, 'object_id': model_id, 'user_id': uid, 'res_id': resource_id, - 'name': name, } if (model_id, resource_id) not in old_values and method not in ('copy', 'read'): # the resource was not existing so we are forcing the method to 'create' @@ -481,7 +479,11 @@ def process_data(cr, uid, pool, res_ids, model, method, old_values=None, new_val # the resource is not existing anymore so we are forcing the method to 'unlink' # (because it could also come with the value 'write' if we are deleting the # record through a one2many field) + name = old_values[(model_id, resource_id)]['value'].get('name',False) vals.update({'method': 'unlink'}) + else : + name = pool[line_model].name_get(cr, uid, [resource_id])[0][1] + vals.update({'name': name}) # create the audittrail log in super admin mode, only if a change has been detected if lines[(model_id, resource_id)]: log_id = pool.get('audittrail.log').create(cr, SUPERUSER_ID, vals) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 784358dceed..3dc1fa75b8d 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -456,7 +456,7 @@ class calendar_alarm_manager(osv.AbstractModel): bFound = False LastFound = False for one_date in self.pool.get('calendar.event').get_recurrent_date_by_event(cr, uid, curEvent, context=context): - in_date_format = datetime.strptime(one_date, '%Y-%m-%d %H:%M:%S') + in_date_format = one_date.replace(tzinfo=None) LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, cron_interval, notif=False, context=context) if LastFound: for alert in LastFound: @@ -490,7 +490,7 @@ class calendar_alarm_manager(osv.AbstractModel): bFound = False LastFound = False for one_date in self.pool.get("calendar.event").get_recurrent_date_by_event(cr, uid, curEvent, context=context): - in_date_format = datetime.strptime(one_date, '%Y-%m-%d %H:%M:%S') + in_date_format = one_date.replace(tzinfo=None) LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner.calendar_last_notif_ack, mail=False, context=context) if LastFound: for alert in LastFound: @@ -680,19 +680,23 @@ class calendar_event(osv.Model): return [d.astimezone(pytz.UTC) for d in rset1] def _get_recurrency_end_date(self, data, context=None): - if data.get('recurrency') and data.get('end_type') in ('count', unicode('count')): - data_date_deadline = datetime.strptime(data.get('date_deadline'), '%Y-%m-%d %H:%M:%S') - if data.get('rrule_type') in ('daily', unicode('count')): - rel_date = relativedelta(days=data.get('count') + 1) - elif data.get('rrule_type') in ('weekly', unicode('weekly')): - rel_date = relativedelta(days=(data.get('count') + 1) * 7) - elif data.get('rrule_type') in ('monthly', unicode('monthly')): - rel_date = relativedelta(months=data.get('count') + 1) - elif data.get('rrule_type') in ('yearly', unicode('yearly')): - rel_date = relativedelta(years=data.get('count') + 1) - end_date = data_date_deadline + rel_date - else: - end_date = data.get('end_date') + if not data.get('recurrency'): + return False + + end_type = data.get('end_type') + end_date = data.get('end_date') + + if end_type == 'count' and all(data.get(key) for key in ['count', 'rrule_type', 'date_deadline']): + count = data['count'] + 1 + delay, mult = { + 'daily': ('days', 1), + 'weekly': ('days', 7), + 'monthly': ('months', 1), + 'yearly': ('years', 1), + }[data['rrule_type']] + + deadline = datetime.strptime(data['date_deadline'], tools.DEFAULT_SERVER_DATETIME_FORMAT) + return deadline + relativedelta(**{delay: count * mult}) return end_date def _find_my_attendee(self, cr, uid, meeting_ids, context=None): @@ -774,7 +778,11 @@ class calendar_event(osv.Model): result[event] = "" return result + # retro compatibility function def _rrule_write(self, cr, uid, ids, field_name, field_value, args, context=None): + return self._set_rulestring(self, cr, uid, ids, field_name, field_value, args, context=context) + + def _set_rulestring(self, cr, uid, ids, field_name, field_value, args, context=None): if not isinstance(ids, list): ids = [ids] data = self._get_empty_rrule_data() @@ -812,7 +820,7 @@ class calendar_event(osv.Model): 'class': fields.selection([('public', 'Public'), ('private', 'Private'), ('confidential', 'Public for Employees')], 'Privacy', states={'done': [('readonly', True)]}), 'location': fields.char('Location', help="Location of Event", track_visibility='onchange', states={'done': [('readonly', True)]}), 'show_as': fields.selection([('free', 'Free'), ('busy', 'Busy')], 'Show Time as', states={'done': [('readonly', True)]}), - 'rrule': fields.function(_get_rulestring, type='char', fnct_inv=_rrule_write, store=True, string='Recurrent Rule'), + 'rrule': fields.function(_get_rulestring, type='char', fnct_inv=_set_rulestring, store=True, string='Recurrent Rule'), 'rrule_type': fields.selection([('daily', 'Day(s)'), ('weekly', 'Week(s)'), ('monthly', 'Month(s)'), ('yearly', 'Year(s)')], 'Recurrency', states={'done': [('readonly', True)]}, help="Let the event automatically repeat at that interval"), 'recurrency': fields.boolean('Recurrent', help="Recurrent Meeting"), 'recurrent_id': fields.integer('Recurrent ID'), @@ -1169,7 +1177,7 @@ class calendar_event(osv.Model): #repeat monthly by nweekday ((weekday, weeknumber), ) if r._bynweekday: data['week_list'] = day_list[r._bynweekday[0][0]].upper() - data['byday'] = r._bynweekday[0][1] + data['byday'] = str(r._bynweekday[0][1]) data['month_by'] = 'day' data['rrule_type'] = 'monthly' @@ -1423,7 +1431,7 @@ class calendar_event(osv.Model): # set end_date for calendar searching if values.get('recurrency', True) and values.get('end_type', 'count') in ('count', unicode('count')) and \ (values.get('rrule_type') or values.get('count') or values.get('date') or values.get('date_deadline')): - for data in self.read(cr, uid, ids, ['date', 'date_deadline', 'recurrency', 'rrule_type', 'count', 'end_type'], context=context): + for data in self.read(cr, uid, ids, ['end_date', 'date_deadline', 'recurrency', 'rrule_type', 'count', 'end_type'], context=context): end_date = self._get_recurrency_end_date(data, context=context) super(calendar_event, self).write(cr, uid, [data['id']], {'end_date': end_date}, context=context) @@ -1454,11 +1462,12 @@ class calendar_event(osv.Model): if not 'user_id' in vals: # Else bug with quick_create when we are filter on an other user vals['user_id'] = uid - if vals.get('recurrency', True) and vals.get('end_type', 'count') in ('count', unicode('count')) and \ - (vals.get('rrule_type') or vals.get('count') or vals.get('date') or vals.get('date_deadline')): - vals['end_date'] = self._get_recurrency_end_date(vals, context=context) - res = super(calendar_event, self).create(cr, uid, vals, context=context) + + data = self.read(cr, uid, [res], ['end_date', 'date_deadline', 'recurrency', 'rrule_type', 'count', 'end_type'], context=context)[0] + end_date = self._get_recurrency_end_date(data, context=context) + self.write(cr, uid, [res], {'end_date': end_date}, context=context) + self.create_attendees(cr, uid, [res], context=context) return res diff --git a/addons/calendar/test/calendar_test.yml b/addons/calendar/test/calendar_test.yml index 1454a635a4f..44290d8166f 100644 --- a/addons/calendar/test/calendar_test.yml +++ b/addons/calendar/test/calendar_test.yml @@ -65,3 +65,20 @@ - !python {model: calendar.event}: | self.write(cr, uid, [ref("calendar_event_alldaytestevent0")], {'alarm_ids': [(6,0,[ref("res_alarm_daybeforeeventstarts0")])]}) +- + I create a recuring rule for my event +- + !record {model: calendar.event, id: calendar.event_sprintreview1}: + name: Begin of month meeting + date: !eval time.strftime('%Y-%m-%d 12:00:00') + recurrency: true + rrule: FREQ=MONTHLY;INTERVAL=1;COUNT=12;BYDAY=1MO +- + I check that the attributes are set correctly +- + !assert {model: calendar.event, id: calendar.event_sprintreview1}: + - rrule_type == 'monthly' + - count == 12 + - month_by == 'day' + - byday == '1' + - week_list == 'MO' diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index fd9462d9c34..4da0a509ed1 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -313,7 +313,10 @@ class crm_lead(format_address, osv.osv): stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context=context) if not stage.on_change: return {'value': {}} - return {'value': {'probability': stage.probability}} + vals = {'probability': stage.probability} + if stage.probability >= 100 or (stage.probability == 0 and stage.sequence > 1): + vals['date_closed'] = fields.datetime.now() + return {'value': vals} def on_change_partner_id(self, cr, uid, ids, partner_id, context=None): values = {} @@ -407,7 +410,7 @@ class crm_lead(format_address, osv.osv): 'probability = 0 %, select "Change Probability Automatically".\n' 'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.')) for stage_id, lead_ids in stages_leads.items(): - self.write(cr, uid, lead_ids, {'stage_id': stage_id, 'date_closed': fields.datetime.now()}, context=context) + self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context) return True def case_mark_won(self, cr, uid, ids, context=None): @@ -428,7 +431,7 @@ class crm_lead(format_address, osv.osv): 'probability = 100 % and select "Change Probability Automatically".\n' 'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.')) for stage_id, lead_ids in stages_leads.items(): - self.write(cr, uid, lead_ids, {'stage_id': stage_id, 'date_closed': fields.datetime.now()}, context=context) + self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context) return True def case_escalate(self, cr, uid, ids, context=None): diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index d054e956ed6..a33b215fb8f 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -95,7 +95,6 @@
or - Discard + Discard diff --git a/addons/website/views/themes.xml b/addons/website/views/themes.xml index f56ab2b5dd7..82f5105adcd 100644 --- a/addons/website/views/themes.xml +++ b/addons/website/views/themes.xml @@ -206,6 +206,7 @@ @@ -218,48 +219,56 @@ @@ -272,6 +281,7 @@ diff --git a/addons/website_mail/models/mail_message.py b/addons/website_mail/models/mail_message.py index c708d9c3e33..12c35f3e83f 100644 --- a/addons/website_mail/models/mail_message.py +++ b/addons/website_mail/models/mail_message.py @@ -54,7 +54,7 @@ class MailMessage(osv.Model): args = ['&', ('website_published', '=', True)] + list(args) return super(MailMessage, self)._search(cr, uid, args, offset=offset, limit=limit, order=order, - context=context, count=False, access_rights_uid=access_rights_uid) + context=context, count=count, access_rights_uid=access_rights_uid) def check_access_rule(self, cr, uid, ids, operation, context=None): """ Add Access rules of mail.message for non-employee user: diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index d8a314ad609..2d84c95119f 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -603,7 +603,7 @@ class Ecommerce(http.Controller): if tx: acquirer_ids = [tx.acquirer_id.id] else: - acquirer_ids = payment_obj.search(cr, SUPERUSER_ID, [('website_published', '=', True)], context=context) + acquirer_ids = payment_obj.search(cr, SUPERUSER_ID, [('website_published', '=', True), '|', ('company_id', '=', order.company_id.id), ('company_id', '=', False)], context=context) values['acquirers'] = payment_obj.browse(cr, uid, acquirer_ids, context=context) render_ctx = dict(context, submit_class='btn btn-primary', submit_txt='Pay Now') for acquirer in values['acquirers']: diff --git a/addons/website_sale/static/src/css/website_sale.css b/addons/website_sale/static/src/css/website_sale.css index d9880bd7025..3e5e692304e 100644 --- a/addons/website_sale/static/src/css/website_sale.css +++ b/addons/website_sale/static/src/css/website_sale.css @@ -54,10 +54,9 @@ bottom: 0; overflow: hidden; padding: 0 15px 24px 0; - max-height: 110px; min-height: 56px; border-top: 1px solid rgba(255, 255, 255, 0.2); - background: rgba(100, 100, 100, 0.1); + background: rgba(255, 255, 255, 0.75); z-index: 5; } .oe_product .product_price { @@ -72,9 +71,8 @@ } .oe_product .oe_subdescription { font-size: 0.8em; - max-height: 42px; overflow: hidden; - margin-bottom: 30px; + margin-bottom: 10px; } .oe_mycart .input-group-addon { diff --git a/addons/website_sale/static/src/css/website_sale.sass b/addons/website_sale/static/src/css/website_sale.sass index 7c5bde43509..128b1a25d43 100644 --- a/addons/website_sale/static/src/css/website_sale.sass +++ b/addons/website_sale/static/src/css/website_sale.sass @@ -48,10 +48,9 @@ bottom: 0 overflow: hidden padding: 0 15px 24px 0 - max-height: 110px min-height: 56px border-top: 1px solid rgba(255,255,255,0.2) - background: rgba(100, 100, 100, 0.1) + background: rgba(255, 255, 255, 0.75) z-index: 5 .product_price padding: 5px 0 @@ -63,9 +62,8 @@ height: 100% .oe_subdescription font-size: 0.8em - max-height: 42px overflow: hidden - margin-bottom: 30px + margin-bottom: 10px .oe_mycart .input-group-addon diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index f0c14ee1573..b870a676cc9 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -193,7 +193,7 @@ - +