Skip to content

Commit

Permalink
[MERGE] forward port of branch saas-6 up to 63e92cb
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Jul 22, 2015
2 parents d74e0c3 + 63e92cb commit 2cf91d1
Show file tree
Hide file tree
Showing 493 changed files with 18,736 additions and 14,338 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ recursive-include openerp *.jpg
recursive-include openerp *.js
recursive-include openerp *.less
recursive-include openerp *.md
recursive-include openerp *.mp3
recursive-include openerp *.ogg
recursive-include openerp *.png
recursive-include openerp *.po
recursive-include openerp *.rml
Expand Down
1 change: 1 addition & 0 deletions addons/account/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"static/src/xml/account_reconciliation.xml",
"static/src/xml/account_payment.xml",
"static/src/xml/account_report_backend.xml",
'test/analytic_hierarchy.yml',
],
'installable': True,
'application': True,
Expand Down
4 changes: 3 additions & 1 deletion addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,9 @@ def action_move_create(self):
ctx['company_id'] = inv.company_id.id
ctx['dont_create_taxes'] = True
ctx['invoice_id'] = inv.move_name and inv or False
move = account_move.with_context(ctx).create(move_vals)
ctx_nolang = ctx.copy()
ctx_nolang.pop('lang', None)
move = account_move.with_context(ctx_nolang).create(move_vals)
# make the invoice point to that move
vals = {
'move_id': move.id,
Expand Down
8 changes: 5 additions & 3 deletions addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ def _check_lock_date(self):
def assert_balanced(self):
if not self.ids:
return True
prec = self.env['decimal.precision'].precision_get('Account')

self._cr.execute("""\
SELECT move_id
FROM account_move_line
WHERE move_id in %s
GROUP BY move_id
HAVING abs(sum(debit) - sum(credit)) > 0.00001
""", (tuple(self.ids),))
HAVING abs(sum(debit) - sum(credit)) > %s
""", (tuple(self.ids), 10 ** (-max(5, prec))))
if len(self._cr.fetchall()) != 0:
raise UserError(_("Cannot create unbalanced journal entry."))
return True
Expand Down Expand Up @@ -1086,7 +1088,7 @@ def _prepare_analytic_line(self):
'journal_id': self.journal_id.analytic_journal_id.id,
'ref': self.ref,
'move_id': self.id,
'user_id': self._uid,
'user_id': self.invoice_id.user_id.id or self._uid,
}

@api.model
Expand Down
56 changes: 56 additions & 0 deletions addons/account/test/analytic_hierarchy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-
We create a simple hierarchy like this
Toplevel view account
├ Real analytic account 1
└ Real analytic account 2
-
!record {model: account.analytic.account, id: analytic_account_view1}:
name: 'Toplevel view account'
type: 'view'
-
!record {model: account.analytic.account, id: analytic_account1}:
name: 'Real analytic account 1'
type: 'normal'
parent_id: analytic_account_view1
-
!record {model: account.analytic.account, id: analytic_account2}:
name: 'Real analytic account 2'
type: 'normal'
parent_id: analytic_account_view1
-
We add analytic lines in real accounts and journal
-
!record {model: account.analytic.journal, id: analytic_journal1}:
name: 'Analytic journal'
-
!record {model: account.analytic.line, id: analytic_line1}:
name: 'Analytic line 1'
account_id: analytic_account1
journal_id: analytic_journal1
general_account_id: account.a_expense
-
!record {model: account.analytic.line, id: analytic_line2}:
name: 'Analytic line 2'
account_id: analytic_account2
journal_id: analytic_journal1
general_account_id: account.a_expense
-
Now we copy the toplevel account
-
!function {model: account.analytic.account, name: copy, id: analytic_account_view1}:
- eval: "ref('analytic_account_view1')"
-
!python {model: account.analytic.account}: |
# the toplevel account has been copied with the (copy) suffix
accounts = self.search(cr, uid, [('name', 'like', '%Toplevel view account%')])
assert len(accounts) == 2, 'The toplevel account has not been copied'
accounts = self.search(cr, uid, [('name', '=', 'Toplevel view account')])
assert len(accounts) == 1, 'The toplevel account copy has a bad name'
# the sub-accounts and sub-accounts have been copied without the (copy) suffix
accounts = self.search(cr, uid, [('name', '=', 'Real analytic account 1')])
assert len(accounts) == 2, 'The sub-account has not been copied'
accounts = self.search(cr, uid, [('name', '=', 'Real analytic account 2')])
assert len(accounts) == 2, 'The sub-account has not been copied'
# the analytic lines should not be duplicated
lines = self.pool.get('account.analytic.line').search(cr, uid, [('name', 'like', '%Analytic line %')])
assert len(lines) == 2, "The analytic lines shouldn't have been copied"
6 changes: 2 additions & 4 deletions addons/account/tests/account_test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ def setUp(self):
self.account_type_model = self.env['account.account.type']
self.currency_euro = self.env.ref('base.EUR')

self.account_user = self.res_user_model.create(dict(
self.account_user = self.res_user_model.with_context({'no_reset_password': True}).create(dict(
name="Accountant",
company_id=self.main_company.id,
login="acc",
password="acc",
email="accountuser@yourcompany.com",
groups_id=[(6, 0, [res_users_account_user.id, partner_manager.id])]
))
self.account_manager = self.res_user_model.create(dict(
self.account_manager = self.res_user_model.with_context({'no_reset_password': True}).create(dict(
name="Adviser",
company_id=self.main_company.id,
login="fm",
password="fm",
email="accountmanager@yourcompany.com",
groups_id=[(6, 0, [res_users_account_manager.id, partner_manager.id])]
))
44 changes: 24 additions & 20 deletions addons/account_analytic_analysis/account_analytic_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,33 +684,37 @@ def _prepare_invoice_data(self, cr, uid, contract, context=None):
}
return invoice

def _prepare_invoice_line(self, cr, uid, line, fiscal_position, context=None):
fpos_obj = self.pool.get('account.fiscal.position')
res = line.product_id
account_id = res.property_account_income_id.id
if not account_id:
account_id = res.categ_id.property_account_income_categ_id.id
account_id = fpos_obj.map_account(cr, uid, fiscal_position, account_id)

taxes = res.taxes_id or False
tax_id = fpos_obj.map_tax(cr, uid, fiscal_position, taxes)
values = {
'name': line.name,
'account_id': account_id,
'account_analytic_id': line.analytic_account_id.id,
'price_unit': line.price_unit or 0.0,
'quantity': line.quantity,
'uos_id': line.uom_id.id or False,
'product_id': line.product_id.id or False,
'invoice_line_tax_ids': [(6, 0, tax_id)],
}
return values

def _prepare_invoice_lines(self, cr, uid, contract, fiscal_position_id, context=None):
fpos_obj = self.pool.get('account.fiscal.position')
fiscal_position = None
if fiscal_position_id:
fiscal_position = fpos_obj.browse(cr, uid, fiscal_position_id, context=context)
invoice_lines = []
for line in contract.recurring_invoice_line_ids:

res = line.product_id
account_id = res.property_account_income_id.id
if not account_id:
account_id = res.categ_id.property_account_income_categ_id.id
account_id = fpos_obj.map_account(cr, uid, fiscal_position, account_id)

taxes = res.taxes_id or False
tax_id = fpos_obj.map_tax(cr, uid, fiscal_position, taxes)

invoice_lines.append((0, 0, {
'name': line.name,
'account_id': account_id,
'account_analytic_id': contract.id,
'price_unit': line.price_unit or 0.0,
'quantity': line.quantity,
'uos_id': line.uom_id.id or False,
'product_id': line.product_id.id or False,
'invoice_line_tax_ids': [(6, 0, tax_id)],
}))
values = self._prepare_invoice_line(cr, uid, line, fiscal_position, context=context)
invoice_lines.append((0, 0, values))
return invoice_lines

def _prepare_invoice(self, cr, uid, contract, context=None):
Expand Down
2 changes: 2 additions & 0 deletions addons/account_budget/account_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ def _prac_amt(self, cr, uid, ids, context=None):
result = 0.0
if context is None:
context = {}
account_obj = self.pool.get('account.account')
for line in self.browse(cr, uid, ids, context=context):
acc_ids = [x.id for x in line.general_budget_id.account_ids]
if not acc_ids:
raise UserError(_("The Budget '%s' has no accounts!") % ustr(line.general_budget_id.name))
acc_ids = account_obj._get_children_and_consol(cr, uid, acc_ids, context=context)
date_to = line.date_to
date_from = line.date_from
if line.analytic_account_id.id:
Expand Down
2 changes: 0 additions & 2 deletions addons/account_voucher/test/account_voucher_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
company_id: base.main_company
name: Voucher Accountant
login: vacc
password: acc
email: accountant@yourcompany.com
-
I added groups to Accountant for account voucher.
Expand All @@ -21,7 +20,6 @@
company_id: base.main_company
name: Financial Manager for voucher
login: fmv
password: fmv
email: finmanager@yourcompany.com
-
I added groups to Financial Manager for account voucher.
Expand Down
11 changes: 8 additions & 3 deletions addons/analytic/models/analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def _currency(self, cr, uid, ids, field_name, arg, context=None):
'template_id': fields.many2one('account.analytic.account', 'Template of Contract'),
'description': fields.text('Description'),
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts', copy=True),
'child_complete_ids': fields.function(_child_compute, relation='account.analytic.account', string="Account Hierarchy", type='many2many'),
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'),
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries', copy=False),
'balance': fields.function(_debit_credit_bal_qtty, type='float', string='Balance', multi='debit_credit_bal_qtty', digits=0),
'debit': fields.function(_debit_credit_bal_qtty, type='float', string='Debit', multi='debit_credit_bal_qtty', digits=0),
'credit': fields.function(_debit_credit_bal_qtty, type='float', string='Credit', multi='debit_credit_bal_qtty', digits=0),
Expand Down Expand Up @@ -263,6 +263,8 @@ def name_create(self, cr, uid, name, context=None):
raise UserError(_("Quick account creation disallowed."))

def copy(self, cr, uid, id, default=None, context=None):
""" executed only on the toplevel copied object of the hierarchy.
Subobject are actually copied with copy_data"""
if not default:
default = {}
analytic = self.browse(cr, uid, id, context=context)
Expand Down Expand Up @@ -299,9 +301,12 @@ def name_search(self, cr, uid, name, args=None, operator='ilike', context=None,
dom = []
for name2 in name.split('/'):
name = name2.strip()
account_ids = self.search(cr, uid, dom + [('name', operator, name)] + args, limit=limit, context=context)
account_ids = self.search(cr, uid, dom + [('name', operator, name)], limit=limit, context=context)
if not account_ids: break
dom = [('parent_id','in',account_ids)]
if account_ids and args:
# final filtering according to domain (args)
account_ids = self.search(cr, uid, [('id', 'in', account_ids)] + args, limit=limit, context=context)
else:
account_ids = self.search(cr, uid, args, limit=limit, context=context)
return self.name_get(cr, uid, account_ids, context=context)
Expand Down
3 changes: 2 additions & 1 deletion addons/auth_ldap/users_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def query(self, conf, filter, retrieve_attributes=None):
try:
conn = self.connect(conf)
ldap_password = conf['ldap_password'] or ''
conn.simple_bind_s(conf['ldap_binddn'] or '', ldap_password.encode('utf-8'))
ldap_binddn = conf['ldap_binddn'] or ''
conn.simple_bind_s(ldap_binddn.encode('utf-8'), ldap_password.encode('utf-8'))
results = conn.search_st(conf['ldap_base'], ldap.SCOPE_SUBTREE,
filter, retrieve_attributes, timeout=60)
conn.unbind()
Expand Down
27 changes: 15 additions & 12 deletions addons/auth_oauth/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ def _auth_oauth_validate(self, cr, uid, provider, access_token, context=None):
validation.update(data)
return validation

def _generate_signup_values(self, cr, uid, provider, validation, params, context=None):
oauth_uid = validation['user_id']
email = validation.get('email', 'provider_%s_user_%s' % (provider, oauth_uid))
name = validation.get('name', email)
return {
'name': name,
'login': email,
'email': email,
'oauth_provider_id': provider,
'oauth_uid': oauth_uid,
'oauth_access_token': params['access_token'],
'active': True,
}

def _auth_oauth_signin(self, cr, uid, provider, validation, params, context=None):
""" retrieve and sign in the user corresponding to provider and validated access token
:param provider: oauth provider id (int)
Expand All @@ -70,18 +84,7 @@ def _auth_oauth_signin(self, cr, uid, provider, validation, params, context=None
return None
state = simplejson.loads(params['state'])
token = state.get('t')
oauth_uid = validation['user_id']
email = validation.get('email', 'provider_%s_user_%s' % (provider, oauth_uid))
name = validation.get('name', email)
values = {
'name': name,
'login': email,
'email': email,
'oauth_provider_id': provider,
'oauth_uid': oauth_uid,
'oauth_access_token': params['access_token'],
'active': True,
}
values = self._generate_signup_values(cr, uid, provider, validation, params, context=context)
try:
_, login, _ = self.signup(cr, uid, values, token, context=context)
return login
Expand Down
2 changes: 0 additions & 2 deletions addons/auth_signup/auth_signup_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<record id="default_template_user" model="res.users">
<field name="name">Template User</field>
<field name="login">portaltemplate</field>
<!-- No password: this template user doesn't need to log in -->
<field name="password"></field>
<field name="active" eval="False"/>
<!-- Avoid auto-including this user in any default group, just like a typical portal member -->
<field name="groups_id" eval="[(6, 0, [ref('base.group_portal')])]"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/auth_signup/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def reset_password(self, cr, uid, login, context=None):
if not user_ids:
user_ids = self.search(cr, uid, [('email', '=', login)], context=context)
if len(user_ids) != 1:
raise Exception('Reset password: invalid username or email')
raise Exception(_('Reset password: invalid username or email'))
return self.action_reset_password(cr, uid, user_ids, context=context)

def action_reset_password(self, cr, uid, ids, context=None):
Expand Down
14 changes: 12 additions & 2 deletions addons/barcodes/static/src/js/barcode_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var BarcodeParser = Class.extend({
// - value: the numerical value encoded in the barcode (0 if no value encoded)
// - base_code: the barcode in which numerical content is replaced by 0's
// - match: boolean
match_pattern: function (barcode, pattern){
match_pattern: function (barcode, pattern, encoding){
var match = {
value: 0,
base_code: barcode,
Expand Down Expand Up @@ -156,6 +156,16 @@ var BarcodeParser = Class.extend({
.replace("\{", "{")
.replace("\}","}")
.replace("\.",".");

var base_code = match.base_code.split('')
if (encoding === 'ean13') {
base_code[12] = '' + this.ean_checksum(match.base_code);
} else if (encoding === 'ean8') {
base_code[7] = '' + this.ean8_checksum(match.base_code);
} else if (encoding === 'upca') {
base_code[11] = '' + this.ean_checksum('0' + match.base_code);
}
match.base_code = base_code.join('')
}

if (base_pattern[0] !== '^') {
Expand Down Expand Up @@ -208,7 +218,7 @@ var BarcodeParser = Class.extend({
continue;
}

var match = this.match_pattern(cur_barcode,rules[i].pattern);
var match = this.match_pattern(cur_barcode, rules[i].pattern, rule.encoding);
if (match.match) {
if(rules[i].type === 'alias') {
barcode = rules[i].alias;
Expand Down
13 changes: 7 additions & 6 deletions addons/base_action_rule/base_action_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from collections import defaultdict
from datetime import datetime, timedelta
from datetime import datetime
from dateutil.relativedelta import relativedelta
import time
import logging

Expand All @@ -16,11 +17,11 @@
_logger = logging.getLogger(__name__)

DATE_RANGE_FUNCTION = {
'minutes': lambda interval: timedelta(minutes=interval),
'hour': lambda interval: timedelta(hours=interval),
'day': lambda interval: timedelta(days=interval),
'month': lambda interval: timedelta(months=interval),
False: lambda interval: timedelta(0),
'minutes': lambda interval: relativedelta(minutes=interval),
'hour': lambda interval: relativedelta(hours=interval),
'day': lambda interval: relativedelta(days=interval),
'month': lambda interval: relativedelta(months=interval),
False: lambda interval: relativedelta(0),
}

def get_datetime(date_str):
Expand Down
Loading

0 comments on commit 2cf91d1

Please sign in to comment.