diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index f02ac96b6fc..c68307641ff 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -110,6 +110,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): "AND account.active ", params) self.partner_ids = [res['partner_id'] for res in self.cr.dictfetchall()] objects = obj_partner.browse(self.cr, self.uid, self.partner_ids) + objects.sort(key=lambda x: (x.ref, x.name)) return super(third_party_ledger, self).set_context(objects, data, self.partner_ids, report_type) def lines(self, partner): diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index fe4d0ee5630..05256bbce1c 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -297,6 +297,7 @@ class hr_expense_expense(osv.osv): if not taxes: continue tax_l = [] + base_tax_amount = line.total_amount #Calculating tax on the line and creating move? for tax in tax_obj.compute_all(cr, uid, taxes, line.unit_amount , @@ -312,10 +313,10 @@ class hr_expense_expense(osv.osv): ## We need to deduce the price for the tax res[-1]['price'] = res[-1]['price'] - (tax['amount'] * tax['base_sign'] or 0.0) # tax amount countains base amount without the tax - tax_amount = (line.total_amount - tax['amount']) * tax['base_sign'] + base_tax_amount = (base_tax_amount - tax['amount']) * tax['base_sign'] else: - tax_amount = line.total_amount * tax['base_sign'] - res[-1]['tax_amount'] = cur_obj.compute(cr, uid, exp.currency_id.id, company_currency, tax_amount, context={'date': exp.date_confirm}) + base_tax_amount = base_tax_amount * tax['base_sign'] + assoc_tax = { 'type':'tax', 'name':tax['name'], @@ -327,6 +328,8 @@ class hr_expense_expense(osv.osv): 'tax_amount': tax['amount'] * tax['base_sign'], } tax_l.append(assoc_tax) + + res[-1]['tax_amount'] = cur_obj.compute(cr, uid, exp.currency_id.id, company_currency, base_tax_amount, context={'date': exp.date_confirm}) res += tax_l return res diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 879614f9e3e..026585f8ec4 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -23,7 +23,7 @@ import time from datetime import date, datetime, timedelta from openerp.osv import fields, osv -from openerp.tools import config, float_compare +from openerp.tools import float_compare, float_is_zero from openerp.tools.translate import _ class hr_payslip(osv.osv): @@ -104,6 +104,8 @@ class hr_payslip(osv.osv): } for line in slip.details_by_salary_rule_category: amt = slip.credit_note and -line.total or line.total + if float_is_zero(amt, precision_digits=precision): + continue partner_id = line.salary_rule_id.register_id.partner_id and line.salary_rule_id.register_id.partner_id.id or default_partner_id debit_account_id = line.salary_rule_id.account_debit.id credit_account_id = line.salary_rule_id.account_credit.id @@ -175,6 +177,7 @@ class hr_payslip(osv.osv): 'credit': 0.0, }) line_ids.append(adjust_debit) + move.update({'line_id': line_ids}) move_id = move_pool.create(cr, uid, move, context=context) self.write(cr, uid, [slip.id], {'move_id': move_id, 'period_id' : period_id}, context=context) diff --git a/addons/im_livechat/im_livechat.py b/addons/im_livechat/im_livechat.py index be005ed92dc..f455e38e6f9 100644 --- a/addons/im_livechat/im_livechat.py +++ b/addons/im_livechat/im_livechat.py @@ -55,7 +55,7 @@ class im_livechat_channel(osv.Model): def _script_external(self, cr, uid, ids, name, arg, context=None): values = { - "url": self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'), + "url": self.pool.get('ir.config_parameter').get_param(cr, openerp.SUPERUSER_ID, 'web.base.url'), "dbname":cr.dbname } res = {} @@ -66,7 +66,7 @@ class im_livechat_channel(osv.Model): def _script_internal(self, cr, uid, ids, name, arg, context=None): values = { - "url": self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'), + "url": self.pool.get('ir.config_parameter').get_param(cr, openerp.SUPERUSER_ID 'web.base.url'), "dbname":cr.dbname } res = {} @@ -78,7 +78,7 @@ class im_livechat_channel(osv.Model): def _web_page(self, cr, uid, ids, name, arg, context=None): res = {} for record in self.browse(cr, uid, ids, context=context): - res[record.id] = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') + \ + res[record.id] = self.pool.get('ir.config_parameter').get_param(cr, openerp.SUPERUSER_ID, 'web.base.url') + \ "/im_livechat/support/%s/%i" % (cr.dbname, record.id) return res diff --git a/addons/product/product.py b/addons/product/product.py index 763d139e7c5..da17e9532ce 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -26,7 +26,7 @@ from _common import ceiling from openerp import SUPERUSER_ID from openerp import tools -from openerp.osv import osv, fields +from openerp.osv import osv, fields, expression from openerp.tools.translate import _ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT import psycopg2 @@ -1031,10 +1031,13 @@ class product_product(osv.osv): if not args: args = [] if name: - ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context) - if not ids: - ids = self.search(cr, user, [('ean13','=',name)]+ args, limit=limit, context=context) - if not ids: + positive_operators = ['=', 'ilike', '=ilike', 'like', '=like'] + ids = [] + if operator in positive_operators: + ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context) + if not ids: + ids = self.search(cr, user, [('ean13','=',name)]+ args, limit=limit, context=context) + if not ids and operator not in expression.NEGATIVE_TERM_OPERATORS: # Do not merge the 2 next lines into one single search, SQL search performance would be abysmal # on a database with thousands of matching products, due to the huge merge+unique needed for the # OR operator (and given the fact that the 'name' lookup results come from the ir.translation table @@ -1045,7 +1048,9 @@ class product_product(osv.osv): limit2 = (limit - len(ids)) if limit else False ids.update(self.search(cr, user, args + [('name', operator, name)], limit=limit2, context=context)) ids = list(ids) - if not ids: + elif not ids and operator in expression.NEGATIVE_TERM_OPERATORS: + ids = self.search(cr, user, args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit, context=context) + if not ids and operator in positive_operators: ptrn = re.compile('(\[(.*?)\])') res = ptrn.search(name) if res: diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 97f7e52105b..d3b1e043881 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -30,6 +30,7 @@ from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp from openerp.osv.orm import browse_record_list, browse_record, browse_null from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP +from openerp.tools.float_utils import float_compare class purchase_order(osv.osv): @@ -1112,13 +1113,14 @@ class purchase_order_line(osv.osv): supplierinfo = False + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Unit of Measure') for supplier in product.seller_ids: if partner_id and (supplier.name.id == partner_id): supplierinfo = supplier if supplierinfo.product_uom.id != uom_id: res['warning'] = {'title': _('Warning!'), 'message': _('The selected supplier only sells this product by %s') % supplierinfo.product_uom.name } min_qty = product_uom._compute_qty(cr, uid, supplierinfo.product_uom.id, supplierinfo.min_qty, to_uom_id=uom_id) - if (qty or 0.0) < min_qty: # If the supplier quantity is greater than entered from user, set minimal. + if float_compare(min_qty , qty, precision_digits=precision) == 1: # If the supplier quantity is greater than entered from user, set minimal. if qty: res['warning'] = {'title': _('Warning!'), 'message': _('The selected supplier has a minimal quantity set to %s %s, you should not purchase less.') % (supplierinfo.min_qty, supplierinfo.product_uom.name)} qty = min_qty