From 1acf76bfc2b89af50ffe7f3e41c0b1c984ee418f Mon Sep 17 00:00:00 2001 From: Ravi Gohil Date: Mon, 9 Jun 2014 12:47:54 +0530 Subject: [PATCH 01/10] [FIX] purchase_analytic_plans: keep reference to analytic distribution Purchase orders created with invoice policy 'Based on incoming shipments' were not keeping the reference to the account analytic distribution when invoiced. opw 607577 --- .../purchase_analytic_plans/purchase_analytic_plans.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/purchase_analytic_plans/purchase_analytic_plans.py b/addons/purchase_analytic_plans/purchase_analytic_plans.py index c80beddd20f..ae359f64b1a 100644 --- a/addons/purchase_analytic_plans/purchase_analytic_plans.py +++ b/addons/purchase_analytic_plans/purchase_analytic_plans.py @@ -42,4 +42,14 @@ class purchase_order(osv.osv): purchase_order() +class stock_picking(osv.osv): + _name='stock.picking' + _inherit='stock.picking' + + def _prepare_invoice_line(self, cr, uid, group, picking, move_line, invoice_id, invoice_vals, context=None): + res = super(stock_picking, self)._prepare_invoice_line(cr, uid, group, picking, move_line, invoice_id, invoice_vals, context=context) + if move_line.purchase_line_id and move_line.purchase_line_id.analytics_id: + res['analytics_id'] = move_line.purchase_line_id.analytics_id.id + return res + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 951a51df3f7696bf69a5bb0f3fc82a802219bf19 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 24 Jul 2014 12:21:34 +0200 Subject: [PATCH 02/10] [IMP] account: do not offer closed analytic accounts on invoices lp:1223922, opw 609656 --- addons/account/account_invoice_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 2c768115e2a..f353877dd21 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -61,7 +61,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -200,7 +200,7 @@ domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/> + domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/> @@ -357,7 +357,7 @@ domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/> + domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/> From a5531c1d291786e76974e6bd6c2481fa5483e803 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 24 Jul 2014 20:42:21 +0200 Subject: [PATCH 03/10] [FIX] stock: do not set user_id on prepare_invoice_group The user_id is already set by the prepare_invoice method, which is called before the prepare_invoice_group (the user_id is already set, thus) Besides, _prepare_invoice is overriden in sale_stock, to set the picking sale order salesman as user_id, and, without this correct, grouping invoicse by partner re-set the user_id to uid, which is wrong. --- addons/stock/stock.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index c14819f9f5f..d363275b7fa 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1011,7 +1011,6 @@ class stock_picking(osv.osv): 'origin': (invoice.origin or '') + ', ' + (picking.name or '') + (picking.origin and (':' + picking.origin) or ''), 'comment': (comment and (invoice.comment and invoice.comment + "\n" + comment or comment)) or (invoice.comment and invoice.comment or ''), 'date_invoice': context.get('date_inv', False), - 'user_id': uid, } def _prepare_invoice(self, cr, uid, picking, partner, inv_type, journal_id, context=None): From 93127099c9b90964ab1d1b1e99c7fe1532365570 Mon Sep 17 00:00:00 2001 From: dsabrinarg Date: Thu, 24 Jul 2014 22:31:12 -0500 Subject: [PATCH 04/10] [ADD] base_vat: add VAT validation for Peruvian localization. --- addons/base_vat/base_vat.py | 38 ++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 374e910e6e6..5ecb321d3ba 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -63,6 +63,7 @@ _ref_vat = { 'mx': 'MXABC123456T1B', 'nl': 'NL123456782B90', 'no': 'NO123456785', + 'pe': 'PER10254824220 or PED10254824220', 'pl': 'PL1234567883', 'pt': 'PT123456789', 'ro': 'RO1234567897', @@ -219,7 +220,7 @@ class res_partner(osv.osv): return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8]) return False - # Mexican VAT verification, contributed by + # Mexican VAT verification, contributed by Vauxoo # and Panos Christeas __check_vat_mx_re = re.compile(r"(?P[A-Za-z\xd1\xf1&]{3,4})" \ r"[ \-_]?" \ @@ -276,6 +277,41 @@ class res_partner(osv.osv): return False return check == int(vat[8]) + # Peruvian VAT validation, contributed by Vauxoo + def check_vat_pe(self, vat): + + vat_type,vat = vat and len(vat)>=2 and (vat[0], vat[1:]) or (False, False) + + if vat_type and vat_type.upper() == 'D': + #DNI + return True + elif vat_type and vat_type.upper() == 'R': + #verify RUC + factor = '5432765432' + sum = 0 + dig_check = False + if len(vat) != 11: + return False + try: + int(vat) + except ValueError: + return False + + for f in range(0,10): + sum += int(factor[f]) * int(vat[f]) + + subtraction = 11 - (sum % 11) + if subtraction == 10: + dig_check = 0 + elif subtraction == 11: + dig_check = 1 + else: + dig_check = subtraction + + return int(vat[10]) == dig_check + else: + return False + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 133becd966ba1789f323487c4c2c67530965b1e5 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 25 Jul 2014 11:53:30 +0200 Subject: [PATCH 05/10] [FIX] ir_fields: allow accent on selection import If the selection label (not value) had accents, it wasn't possible to import it using the label having accents --- openerp/addons/base/ir/ir_fields.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_fields.py b/openerp/addons/base/ir/ir_fields.py index 0ed2cb3bf4e..f8a93730430 100644 --- a/openerp/addons/base/ir/ir_fields.py +++ b/openerp/addons/base/ir/ir_fields.py @@ -11,7 +11,8 @@ import pytz from openerp.osv import orm from openerp.tools.translate import _ from openerp.tools.misc import DEFAULT_SERVER_DATE_FORMAT,\ - DEFAULT_SERVER_DATETIME_FORMAT + DEFAULT_SERVER_DATETIME_FORMAT,\ + ustr from openerp.tools import html_sanitize REFERENCING_FIELDS = set([None, 'id', '.id']) @@ -256,6 +257,7 @@ class ir_fields_converter(orm.Model): # Or just copy context & remove lang? selection = selection(model, cr, uid, context=None) for item, label in selection: + label = ustr(label) labels = self._get_translations( cr, uid, ('selection', 'model', 'code'), label, context=context) labels.append(label) @@ -264,8 +266,8 @@ class ir_fields_converter(orm.Model): raise ValueError( _(u"Value '%s' not found in selection field '%%(field)s'") % ( value), { - 'moreinfo': [label or unicode(item) for item, label in selection - if label or item] + 'moreinfo': [_label or unicode(item) for item, _label in selection + if _label or item] }) From 46ef1356d6de734b96ab3f1d8a0892044989b5f9 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 25 Jul 2014 13:00:17 +0200 Subject: [PATCH 06/10] [ADD] safe_eval: UNPACK_SEQUENCE and Exception Allowing UNPACK_SEQUENCE allows the use of the "multi" assignation: a, b = [1,2] for a,b in items --- openerp/tools/safe_eval.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openerp/tools/safe_eval.py b/openerp/tools/safe_eval.py index 76987e278e6..0b9b2e7a8a3 100644 --- a/openerp/tools/safe_eval.py +++ b/openerp/tools/safe_eval.py @@ -67,7 +67,7 @@ _SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [ # New in Python 2.7 - http://bugs.python.org/issue4715 : 'JUMP_IF_FALSE_OR_POP', 'JUMP_IF_TRUE_OR_POP', 'POP_JUMP_IF_FALSE', 'POP_JUMP_IF_TRUE', 'SETUP_EXCEPT', 'END_FINALLY', - 'LOAD_FAST', 'STORE_FAST', 'DELETE_FAST', + 'LOAD_FAST', 'STORE_FAST', 'DELETE_FAST', 'UNPACK_SEQUENCE', 'LOAD_GLOBAL', # Only allows access to restricted globals ] if x in opmap)) @@ -278,7 +278,8 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal 'filter': filter, 'round': round, 'len': len, - 'set' : set + 'set' : set, + 'Exception': Exception, } ) try: From ced585214405a62a06aba27ea4c5817914301bf8 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 25 Jul 2014 14:45:48 +0200 Subject: [PATCH 07/10] [FIX] hr_holidays: do not allow reduce remaining leaves In the Employee form, a remaining legal leaves field is available, which shows remaining validated leaves from allocation requests As this is not allowed to delete a validated allocation requets, it shouldn't be possible to reduce the validated remaining leaves of an employee. To reduce the remaining leaves of an employee, the user should cancel and remove the allocation request --- addons/hr_holidays/hr_holidays.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 793ab247a2d..fbe72a1898c 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -491,7 +491,7 @@ class hr_employee(osv.osv): if diff > 0: leave_id = holiday_obj.create(cr, uid, {'name': _('Allocation for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context) elif diff < 0: - leave_id = holiday_obj.create(cr, uid, {'name': _('Leave Request for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'remove', 'holiday_type': 'employee', 'number_of_days_temp': abs(diff)}, context=context) + raise osv.except_osv(_('Warning!'), _('You cannot reduce validated allocation requests')) else: return False wf_service = netsvc.LocalService("workflow") From 3fe508f200963122f1ee61072516c84b2022aa48 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 10 Jul 2014 15:25:01 -0430 Subject: [PATCH 08/10] [FIX] account: no journal items on consolidation accounts As for the view accounts, the consolidation accounts should not allow to create journal items. Fixes #1090 --- addons/account/account_move_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index bdc1941238d..b3f21eb1525 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -574,7 +574,7 @@ class account_move_line(osv.osv): def _check_no_view(self, cr, uid, ids, context=None): lines = self.browse(cr, uid, ids, context=context) for l in lines: - if l.account_id.type == 'view': + if l.account_id.type in ('view', 'consolidation'): return False return True @@ -626,7 +626,7 @@ class account_move_line(osv.osv): return True _constraints = [ - (_check_no_view, 'You cannot create journal items on an account of type view.', ['account_id']), + (_check_no_view, 'You cannot create journal items on an account of type view or consolidation.', ['account_id']), (_check_no_closed, 'You cannot create journal items on closed account.', ['account_id']), (_check_company_id, 'Account and Period must belong to the same company.', ['company_id']), (_check_date, 'The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal.', ['date']), From cd013aa09a780291931323430f0c3c97ea6ab55d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 28 Jul 2014 14:35:44 +0200 Subject: [PATCH 09/10] Revert 3dec090 "[FIX] ir_values: fallback when no condition" An ir.value without condition should not match when searching with a condition. When a field with change_default on it is modified, the method get_defaults is called with the new value. This means that manually modifying a field with this trigger would put back the default value (opw 611193). --- openerp/addons/base/ir/ir_values.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_values.py b/openerp/addons/base/ir/ir_values.py index 953d1aad0d4..bf0128dffd6 100644 --- a/openerp/addons/base/ir/ir_values.py +++ b/openerp/addons/base/ir/ir_values.py @@ -310,10 +310,10 @@ class ir_values(osv.osv): (SELECT company_id from res_users where id = %%s) ) %s - ORDER BY v.user_id, u.company_id, v.key2""" + ORDER BY v.user_id, u.company_id""" params = ('default', model, uid, uid) if condition: - query %= 'AND (v.key2 = %s OR v.key2 IS NULL)' + query %= 'AND v.key2 = %s' params += (condition[:200],) else: query %= 'AND v.key2 is NULL' From b91a75f7eff85edd5d51a91d10d6e3be8a409030 Mon Sep 17 00:00:00 2001 From: Ravi Gohil Date: Fri, 25 Jul 2014 12:45:40 +0530 Subject: [PATCH 10/10] [IMP] base_vat: differenciate VIES and classical VAT error Display a different error message so that users are aware if the test failed with VIES enabled or not (opw 609823) --- addons/base_vat/base_vat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 5ecb321d3ba..8ba25748317 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -150,6 +150,8 @@ class res_partner(osv.osv): vat_no = "'CC##' (CC=Country Code, ##=VAT Number)" if default_vat_check(vat_country, vat_number): vat_no = _ref_vat[vat_country] if vat_country in _ref_vat else vat_no + if self.pool['res.users'].browse(cr, uid, uid).company_id.vat_check_vies: + return '\n' + _('This VAT number either failed the VIES VAT validation check or did not respect the expected format %s.') % vat_no return '\n' + _('This VAT number does not seem to be valid.\nNote: the expected format is %s') % vat_no _constraints = [(check_vat, _construct_constraint_msg, ["vat"])]