Skip to content

Commit

Permalink
[MERGE] forward port branch 9.0 up to 3805eb6
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Jan 2, 2017
2 parents 26d1a38 + 3805eb6 commit b844d93
Show file tree
Hide file tree
Showing 47 changed files with 645 additions and 436 deletions.
7 changes: 4 additions & 3 deletions addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,10 @@ def compute_invoice_totals(self, company_currency, invoice_move_lines):
for line in invoice_move_lines:
if self.currency_id != company_currency:
currency = self.currency_id.with_context(date=self.date_invoice or fields.Date.context_today(self))
line['currency_id'] = currency.id
line['amount_currency'] = currency.round(line['price'])
line['price'] = currency.compute(line['price'], company_currency)
if not (line.get('currency_id') and line.get('amount_currency')):
line['currency_id'] = currency.id
line['amount_currency'] = currency.round(line['price'])
line['price'] = currency.compute(line['price'], company_currency)
else:
line['currency_id'] = False
line['amount_currency'] = False
Expand Down
8 changes: 8 additions & 0 deletions addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,14 @@ def _create_writeoff(self, vals):
if 'analytic_account_id' in first_line_dict:
del first_line_dict['analytic_account_id']
if 'tax_ids' in first_line_dict:
tax_ids = []
#vals['tax_ids'] is a list of commands [[4, tax_id, None], ...]
for tax_id in vals['tax_ids']:
tax_ids.append(tax_id[1])
amount = first_line_dict['credit'] - first_line_dict['debit']
amount_tax = self.env['account.tax'].browse(tax_ids).compute_all(amount)['total_included']
first_line_dict['credit'] = amount_tax > 0 and amount_tax or 0.0
first_line_dict['debit'] = amount_tax < 0 and abs(amount_tax) or 0.0
del first_line_dict['tax_ids']

# Writeoff line in specified writeoff account
Expand Down
14 changes: 8 additions & 6 deletions addons/account/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ class ResPartner(models.Model):
def _credit_debit_get(self):
tables, where_clause, where_params = self.env['account.move.line']._query_get()
where_params = [tuple(self.ids)] + where_params
self._cr.execute("""SELECT l.partner_id, act.type, SUM(l.amount_residual)
FROM account_move_line l
LEFT JOIN account_account a ON (l.account_id=a.id)
if where_clause:
where_clause = 'AND ' + where_clause
self._cr.execute("""SELECT account_move_line.partner_id, act.type, SUM(account_move_line.amount_residual)
FROM account_move_line
LEFT JOIN account_account a ON (account_move_line.account_id=a.id)
LEFT JOIN account_account_type act ON (a.user_type_id=act.id)
WHERE act.type IN ('receivable','payable')
AND l.partner_id IN %s
AND l.reconciled IS FALSE
AND account_move_line.partner_id IN %s
AND account_move_line.reconciled IS FALSE
""" + where_clause + """
GROUP BY l.partner_id, act.type
GROUP BY account_move_line.partner_id, act.type
""", where_params)
for pid, type, val in self._cr.fetchall():
partner = self.browse(pid)
Expand Down
1 change: 1 addition & 0 deletions addons/account/views/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,7 @@
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
<field name="debit" sum="Total Debit"/>
<field name="credit" sum="Total Credit"/>
<field name="date_maturity" required="0"/>
</tree>
</field>
<field name="narration" colspan="4" placeholder="Add an internal note..." nolabel="1" height="50"/>
Expand Down
2 changes: 2 additions & 0 deletions addons/auth_oauth/ir_configparameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ def init(self, cr, force=False):
if force:
IMD = self.pool['ir.model.data']
oauth_oe = IMD.xmlid_to_object(cr, SUPERUSER_ID, 'auth_oauth.provider_openerp')
if not oauth_oe:
return
dbuuid = self.get_param(cr, SUPERUSER_ID, 'database.uuid')
oauth_oe.write({'client_id': dbuuid})
12 changes: 6 additions & 6 deletions addons/calendar/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,15 @@ def todate(date):
return [d.astimezone(pytz.UTC) for d in rset1]

def _get_recurrency_end_date(self, cr, uid, id, context=None):
data = self.read(cr, uid, id, ['final_date', 'recurrency', 'rrule_type', 'count', 'end_type', 'stop'], context=context)
data = self.read(cr, uid, id, ['final_date', 'recurrency', 'rrule_type', 'count', 'end_type', 'stop', 'interval'], context=context)

if not data.get('recurrency'):
return False

end_type = data.get('end_type')
final_date = data.get('final_date')
if end_type == 'count' and all(data.get(key) for key in ['count', 'rrule_type', 'stop']):
count = data['count'] + 1
if end_type == 'count' and all(data.get(key) for key in ['count', 'rrule_type', 'stop', 'interval']):
count = (data['count'] + 1) * data['interval']
delay, mult = {
'daily': ('days', 1),
'weekly': ('days', 7),
Expand Down Expand Up @@ -973,12 +973,12 @@ def onchange_allday(self, cr, uid, ids, start=False, end=False, starttime=False,
startdatetime = startdatetime or start
if startdatetime:
start = datetime.strptime(startdatetime, DEFAULT_SERVER_DATETIME_FORMAT)
value['start_date'] = datetime.strftime(start, DEFAULT_SERVER_DATE_FORMAT)
value['start_date'] = fields.date.context_today(self, cr, uid, context=context, timestamp=start)

enddatetime = enddatetime or end
if enddatetime:
end = datetime.strptime(enddatetime, DEFAULT_SERVER_DATETIME_FORMAT)
value['stop_date'] = datetime.strftime(end, DEFAULT_SERVER_DATE_FORMAT)
value['stop_date'] = fields.date.context_today(self, cr, uid, context=context, timestamp=end)
else: # from date to datetime
user = self.pool['res.users'].browse(cr, uid, uid, context)
tz = pytz.timezone(user.tz) if user.tz else pytz.utc
Expand Down Expand Up @@ -1312,7 +1312,7 @@ def _parse_rrule(self, rule, data, date_start):
data['rrule_type'] = 'monthly'

if r._bymonthday:
data['day'] = r._bymonthday[0]
data['day'] = list(r._bymonthday)[0]
data['month_by'] = 'date'
data['rrule_type'] = 'monthly'

Expand Down
2 changes: 1 addition & 1 deletion addons/event_sale/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _default_product_id(self):
name = fields.Char(string='Name', required=True, translate=True)
event_id = fields.Many2one('event.event', string="Event", required=True, ondelete='cascade')
product_id = fields.Many2one('product.product', string='Product',
required=True, domain=[("event_type_id", "!=", False)],
required=True, domain=["|", ("event_type_id", "!=", False), ("event_ok", "=", True)],
default=_default_product_id)
registration_ids = fields.One2many('event.registration', 'event_ticket_id', string='Registrations')
price = fields.Float(string='Price', digits=dp.get_precision('Product Price'))
Expand Down
4 changes: 2 additions & 2 deletions addons/google_calendar/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def generate_data(self, cr, uid, event, isCreating=False, context=None):
if not context:
context = {}
if event.allday:
start_date = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.start, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context).isoformat('T').split('T')[0]
final_date = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.stop, tools.DEFAULT_SERVER_DATETIME_FORMAT) + timedelta(days=1), context=context).isoformat('T').split('T')[0]
start_date = event.start_date
final_date = (datetime.strptime(event.stop_date, tools.DEFAULT_SERVER_DATE_FORMAT) + timedelta(days=1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
type = 'date'
vstype = 'dateTime'
else:
Expand Down
4 changes: 3 additions & 1 deletion addons/hr_holidays/hr_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from openerp.exceptions import UserError, AccessError
from openerp import tools, SUPERUSER_ID
from openerp.osv import fields, osv
from openerp.tools import float_compare
from openerp.tools.translate import _

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -500,7 +501,8 @@ def check_holidays(self, cr, uid, ids, context=None):
if record.holiday_type != 'employee' or record.type != 'remove' or not record.employee_id or record.holiday_status_id.limit:
continue
leave_days = self.pool.get('hr.holidays.status').get_days(cr, uid, [record.holiday_status_id.id], record.employee_id.id, context=context)[record.holiday_status_id.id]
if leave_days['remaining_leaves'] < 0 or leave_days['virtual_remaining_leaves'] < 0:
if float_compare(leave_days['remaining_leaves'], 0, precision_digits=2) == -1 or \
float_compare(leave_days['virtual_remaining_leaves'], 0, precision_digits=2) == -1:
return False
return True

Expand Down
9 changes: 7 additions & 2 deletions addons/hr_holidays/report/holidays_summary_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from openerp.osv import osv
from openerp.osv import osv, fields
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT

Expand Down Expand Up @@ -44,6 +44,7 @@ def _get_leaves_summary(self, cr, uid, ids, start_date, empid, holiday_type, con
res = []
count = 0
start_date = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT)
start_date = fields.datetime.context_timestamp(cr, uid, start_date, context=context).date()
end_date = start_date + relativedelta(days=59)
for index in range(0, 60):
current = start_date + timedelta(index)
Expand All @@ -55,8 +56,12 @@ def _get_leaves_summary(self, cr, uid, ids, start_date, empid, holiday_type, con
holiday_type = ['confirm','validate'] if holiday_type == 'both' else ['confirm'] if holiday_type == 'Confirmed' else ['validate']
holidays_ids = holidays_obj.search(cr, uid, [('employee_id', '=', empid), ('state', 'in', holiday_type), ('type', '=', 'remove'), ('date_from', '<=', str(end_date)), ('date_to', '>=', str(start_date))], context=context)
for holiday in holidays_obj.browse(cr, uid, holidays_ids, context=context):
# Convert date to user timezone, otherwise the report will not be consistent with the
# value displayed in the interface.
date_from = datetime.strptime(holiday.date_from, DEFAULT_SERVER_DATETIME_FORMAT)
date_from = fields.datetime.context_timestamp(cr, uid, date_from, context=context).date()
date_to = datetime.strptime(holiday.date_to, DEFAULT_SERVER_DATETIME_FORMAT)
date_to = fields.datetime.context_timestamp(cr, uid, date_to, context=context).date()
for index in range(0, ((date_to - date_from).days + 1)):
if date_from >= start_date and date_from <= end_date:
res[(date_from-start_date).days]['color'] = holiday.holiday_status_id.color_name
Expand Down Expand Up @@ -114,4 +119,4 @@ def render_html(self, cr, uid, ids, data=None, context=None):
'get_data_from_report': self._get_data_from_report(cr, uid, ids, data['form'], context=context),
'get_holidays_status': self._get_holidays_status(cr, uid, ids, context=context),
}
return report_obj.render(cr, uid, ids, 'hr_holidays.report_holidayssummary', docargs, context=context)
return report_obj.render(cr, uid, ids, 'hr_holidays.report_holidayssummary', docargs, context=context)
5 changes: 3 additions & 2 deletions addons/hr_payroll/hr_payroll.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#-*- coding:utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import babel
import time
from datetime import date
from datetime import datetime
Expand Down Expand Up @@ -637,7 +638,7 @@ def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=Fal
ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d")))
employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
res['value'].update({
'name': _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
'name': _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=context.get('lang', 'en_US')))),
'company_id': employee_id.company_id.id
})

Expand Down Expand Up @@ -696,7 +697,7 @@ def onchange_employee(self):
date_to = self.date_to

ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d")))
self.name = _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y')))
self.name = _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=self.env.context.get('lang', 'en_US'))))
self.company_id = employee_id.company_id

if not self.env.context.get('contract') or not self.contract_id:
Expand Down
Loading

0 comments on commit b844d93

Please sign in to comment.