diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 0d245aa929b..76ae3a04648 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -305,6 +305,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 , @@ -320,10 +321,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'], @@ -335,6 +336,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 ad8527fce43..a22c4fb4db6 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): @@ -110,6 +110,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 @@ -181,6 +183,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/product/product.py b/addons/product/product.py index 46ec85ccc83..25368e8f0c7 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, orm, fields +from openerp.osv import osv, orm, fields, expression from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp @@ -771,10 +771,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 @@ -785,7 +788,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 8595742e64f..8365739a3e9 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -31,6 +31,7 @@ from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp from openerp.osv.orm import 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): @@ -1019,13 +1020,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