Skip to content

Commit

Permalink
[MERGE] forward port branch saas-11 up to b844d93
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Jan 2, 2017
2 parents d3538db + b844d93 commit 81f59ce
Show file tree
Hide file tree
Showing 46 changed files with 619 additions and 435 deletions.
4 changes: 2 additions & 2 deletions addons/account/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,11 @@ def _default_tax_group(self):
def unlink(self):
company_id = self.env.user.company_id.id
ir_values = self.env['ir.values']
supplier_taxes_id = set(ir_values.get_default('product.template', 'supplier_taxes_id', company_id=company_id))
supplier_taxes_id = set(ir_values.get_default('product.template', 'supplier_taxes_id', company_id=company_id) or [])
deleted_sup_tax = self.filtered(lambda tax: tax.id in supplier_taxes_id)
if deleted_sup_tax:
ir_values.sudo().set_default('product.template', "supplier_taxes_id", list(supplier_taxes_id - set(deleted_sup_tax.ids)), for_all_users=True, company_id=company_id)
taxes_id = set(self.env['ir.values'].get_default('product.template', 'taxes_id', company_id=company_id))
taxes_id = set(self.env['ir.values'].get_default('product.template', 'taxes_id', company_id=company_id) or [])
deleted_tax = self.filtered(lambda tax: tax.id in taxes_id)
if deleted_tax:
ir_values.sudo().set_default('product.template', "taxes_id", list(taxes_id - set(deleted_tax.ids)), for_all_users=True, company_id=company_id)
Expand Down
7 changes: 4 additions & 3 deletions addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,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 @@ -921,6 +921,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 @@ -206,15 +206,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 @@ -1343,6 +1343,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/models/ir_config_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ def init(self, force=False):
super(IrConfigParameter, self).init(force=force)
if force:
oauth_oe = self.env.ref('auth_oauth.provider_openerp')
if not oauth_oe:
return
dbuuid = self.sudo().get_param('database.uuid')
oauth_oe.write({'client_id': dbuuid})
8 changes: 4 additions & 4 deletions addons/calendar/models/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,15 @@ def todate(date):
def _get_recurrency_end_date(self):
""" Return the last date a recurring event happens, according to its end_type. """
self.ensure_one()
data = self.read(['final_date', 'recurrency', 'rrule_type', 'count', 'end_type', 'stop'])[0]
data = self.read(['final_date', 'recurrency', 'rrule_type', 'count', 'end_type', 'stop', 'interval'])[0]

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 @@ -1134,7 +1134,7 @@ def _rrule_parse(self, rule_str, data, date_start):
data['rrule_type'] = 'monthly'

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

Expand Down
3 changes: 2 additions & 1 deletion addons/event_sale/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ 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_ok", "=", True)], default=_default_product_id)
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'))
deadline = fields.Date(string="Sales End")
Expand Down
4 changes: 2 additions & 2 deletions addons/google_calendar/models/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ class GoogleCalendar(models.AbstractModel):

def generate_data(self, event, isCreating=False):
if event.allday:
start_date = fields.Datetime.context_timestamp(self, fields.Datetime.from_string(event.start)).isoformat('T').split('T')[0]
final_date = fields.Datetime.context_timestamp(self, fields.Datetime.from_string(event.stop) + timedelta(days=1)).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/models/hr_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from odoo import api, fields, models
from odoo.exceptions import UserError, AccessError, ValidationError
from openerp.tools import float_compare
from odoo.tools.translate import _

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -249,7 +250,8 @@ def _check_holidays(self):
if holiday.holiday_type != 'employee' or holiday.type != 'remove' or not holiday.employee_id or holiday.holiday_status_id.limit:
continue
leave_days = holiday.holiday_status_id.get_days(holiday.employee_id.id)[holiday.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:
raise ValidationError(_('The number of remaining leaves is not sufficient for this leave type.\n'
'Please verify also the leaves waiting for validation.'))

Expand Down
10 changes: 7 additions & 3 deletions addons/hr_payroll/models/hr_payroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from datetime import datetime, timedelta
from dateutil import relativedelta

import babel

from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError, ValidationError
from odoo.tools.safe_eval import safe_eval
Expand Down Expand Up @@ -545,9 +547,10 @@ def onchange_employee_id(self, date_from, date_to, employee_id=False, contract_i
return res
ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d")))
employee = self.env['hr.employee'].browse(employee_id)
locale = self.env.context.get('lang', 'en_US')
res['value'].update({
'name': _('Salary Slip of %s for %s') % (employee.name, tools.ustr(ttyme.strftime('%B-%Y'))),
'company_id': employee.company_id.id
'name': _('Salary Slip of %s for %s') % (employee.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=locale))),
'company_id': employee.company_id.id,
})

if not self.env.context.get('contract'):
Expand Down Expand Up @@ -593,7 +596,8 @@ 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.name, tools.ustr(ttyme.strftime('%B-%Y')))
locale = self.env.context.get('lang', 'en_US')
self.name = _('Salary Slip of %s for %s') % (employee.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=locale)))
self.company_id = employee.company_id

if not self.env.context.get('contract') or not self.contract_id:
Expand Down
7 changes: 3 additions & 4 deletions addons/hr_timesheet/project_timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ def _get_subtask_count(self):
task.subtask_count = self.search_count([('id', 'child_of', task.id), ('id', '!=', task.id)])

@api.depends('timesheet_ids.unit_amount', 'planned_hours', 'child_ids.stage_id',
'child_ids.planned_hours', 'child_ids.effective_hours', 'child_ids.children_hours')
'child_ids.planned_hours', 'child_ids.effective_hours', 'child_ids.children_hours', 'child_ids.timesheet_ids.unit_amount')
def _hours_get(self):
for task in self:

for task in self.sorted(key='id', reverse=True):
for child_task in task.child_ids:
if child_task.stage_id and child_task.stage_id.fold:
if child_task.stage_id and not child_task.stage_id.fold:
task.children_hours += child_task.effective_hours + child_task.children_hours
else:
task.children_hours += max(child_task.planned_hours, child_task.effective_hours + child_task.children_hours)
Expand Down
Loading

0 comments on commit 81f59ce

Please sign in to comment.