[MERGE] forward port of branch 7.0 up to b91a75f7ef
Conflicts: addons/base_vat/base_vat.py openerp/tools/safe_eval.py
This commit is contained in:
commit
6b1a804b29
|
@ -61,7 +61,7 @@
|
||||||
<group>
|
<group>
|
||||||
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)" groups="account.group_account_user"/>
|
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)" groups="account.group_account_user"/>
|
||||||
<field name="invoice_line_tax_id" context="{'type':parent.get('type')}" domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]" widget="many2many_tags"/>
|
<field name="invoice_line_tax_id" context="{'type':parent.get('type')}" domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]" widget="many2many_tags"/>
|
||||||
<field domain="[('type','<>','view'), ('company_id', '=', parent.company_id)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
<field domain="[('type','<>','view'), ('company_id', '=', parent.company_id)], ('state','not in',('close','cancelled'))]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||||
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
|
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name="account_id" groups="account.group_account_user"/>
|
<field name="account_id" groups="account.group_account_user"/>
|
||||||
<field name="account_analytic_id" domain="[('type','<>','view'), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/>
|
<field name="account_analytic_id" domain="[('type','<>','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled')]" groups="analytic.group_analytic_accounting"/>
|
||||||
<field name="manual"/>
|
<field name="manual"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<field name="base" readonly="0"/>
|
<field name="base" readonly="0"/>
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]"
|
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)"/>
|
on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
|
||||||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"
|
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"
|
||||||
domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
|
domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="uos_id" groups="product.group_uom"
|
<field name="uos_id" groups="product.group_uom"
|
||||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||||
|
@ -358,7 +358,7 @@
|
||||||
domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]"
|
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)"/>
|
on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
|
||||||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"
|
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"
|
||||||
domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
|
domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="uos_id" groups="product.group_uom"
|
<field name="uos_id" groups="product.group_uom"
|
||||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||||
|
|
|
@ -573,7 +573,7 @@ class account_move_line(osv.osv):
|
||||||
def _check_no_view(self, cr, uid, ids, context=None):
|
def _check_no_view(self, cr, uid, ids, context=None):
|
||||||
lines = self.browse(cr, uid, ids, context=context)
|
lines = self.browse(cr, uid, ids, context=context)
|
||||||
for l in lines:
|
for l in lines:
|
||||||
if l.account_id.type == 'view':
|
if l.account_id.type in ('view', 'consolidation'):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ class account_move_line(osv.osv):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_constraints = [
|
_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_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_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']),
|
(_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']),
|
||||||
|
|
|
@ -63,6 +63,7 @@ _ref_vat = {
|
||||||
'mx': 'MXABC123456T1B',
|
'mx': 'MXABC123456T1B',
|
||||||
'nl': 'NL123456782B90',
|
'nl': 'NL123456782B90',
|
||||||
'no': 'NO123456785',
|
'no': 'NO123456785',
|
||||||
|
'pe': 'PER10254824220 or PED10254824220',
|
||||||
'pl': 'PL1234567883',
|
'pl': 'PL1234567883',
|
||||||
'pt': 'PT123456789',
|
'pt': 'PT123456789',
|
||||||
'ro': 'RO1234567897',
|
'ro': 'RO1234567897',
|
||||||
|
@ -148,10 +149,11 @@ class res_partner(osv.osv):
|
||||||
return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
|
return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
|
||||||
vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
|
vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
|
||||||
vat_no = "'CC##' (CC=Country Code, ##=VAT Number)"
|
vat_no = "'CC##' (CC=Country Code, ##=VAT Number)"
|
||||||
|
error_partner = self.browse(cr, uid, ids, context=context)
|
||||||
if default_vat_check(vat_country, 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
|
vat_no = _ref_vat[vat_country] if vat_country in _ref_vat else vat_no
|
||||||
#Retrieve the current partner for wich the VAT is not valid
|
if self.pool['res.users'].browse(cr, uid, uid).company_id.vat_check_vies:
|
||||||
error_partner = self.browse(cr, uid, ids, context=context)
|
return '\n' + _('The VAT number [%s] for partner [%s] either failed the VIES VAT validation check or did not respect the expected format %s.') % (error_partner[0].vat, error_partner[0].name, vat_no)
|
||||||
return '\n' + _('The VAT number [%s] for partner [%s] does not seem to be valid. \nNote: the expected format is %s') % (error_partner[0].vat, error_partner[0].name, vat_no)
|
return '\n' + _('The VAT number [%s] for partner [%s] does not seem to be valid. \nNote: the expected format is %s') % (error_partner[0].vat, error_partner[0].name, vat_no)
|
||||||
|
|
||||||
_constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
|
_constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
|
||||||
|
@ -222,7 +224,7 @@ class res_partner(osv.osv):
|
||||||
return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8])
|
return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Mexican VAT verification, contributed by <moylop260@hotmail.com>
|
# Mexican VAT verification, contributed by Vauxoo
|
||||||
# and Panos Christeas <p_christ@hol.gr>
|
# and Panos Christeas <p_christ@hol.gr>
|
||||||
__check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
|
__check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
|
||||||
r"[ \-_]?" \
|
r"[ \-_]?" \
|
||||||
|
@ -279,5 +281,39 @@ class res_partner(osv.osv):
|
||||||
return False
|
return False
|
||||||
return check == int(vat[8])
|
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
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -504,7 +504,7 @@ class hr_employee(osv.osv):
|
||||||
if diff > 0:
|
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)
|
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:
|
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:
|
else:
|
||||||
return False
|
return False
|
||||||
holiday_obj.signal_confirm(cr, uid, [leave_id])
|
holiday_obj.signal_confirm(cr, uid, [leave_id])
|
||||||
|
|
|
@ -40,4 +40,14 @@ class purchase_order(osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -1005,7 +1005,6 @@ class stock_picking(osv.osv):
|
||||||
'origin': (invoice.origin or '') + ', ' + (picking.name or '') + (picking.origin and (':' + picking.origin) or ''),
|
'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 ''),
|
'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),
|
'date_invoice': context.get('date_inv', False),
|
||||||
'user_id': uid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _prepare_invoice(self, cr, uid, picking, partner, inv_type, journal_id, context=None):
|
def _prepare_invoice(self, cr, uid, picking, partner, inv_type, journal_id, context=None):
|
||||||
|
|
|
@ -12,7 +12,8 @@ import pytz
|
||||||
from openerp.osv import orm
|
from openerp.osv import orm
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.tools.misc import DEFAULT_SERVER_DATE_FORMAT,\
|
from openerp.tools.misc import DEFAULT_SERVER_DATE_FORMAT,\
|
||||||
DEFAULT_SERVER_DATETIME_FORMAT
|
DEFAULT_SERVER_DATETIME_FORMAT,\
|
||||||
|
ustr
|
||||||
from openerp.tools import html_sanitize
|
from openerp.tools import html_sanitize
|
||||||
|
|
||||||
REFERENCING_FIELDS = set([None, 'id', '.id'])
|
REFERENCING_FIELDS = set([None, 'id', '.id'])
|
||||||
|
@ -260,6 +261,7 @@ class ir_fields_converter(orm.Model):
|
||||||
# Or just copy context & remove lang?
|
# Or just copy context & remove lang?
|
||||||
selection = selection(model, cr, uid, context=None)
|
selection = selection(model, cr, uid, context=None)
|
||||||
for item, label in selection:
|
for item, label in selection:
|
||||||
|
label = ustr(label)
|
||||||
labels = self._get_translations(
|
labels = self._get_translations(
|
||||||
cr, uid, ('selection', 'model', 'code'), label, context=context)
|
cr, uid, ('selection', 'model', 'code'), label, context=context)
|
||||||
labels.append(label)
|
labels.append(label)
|
||||||
|
@ -268,8 +270,8 @@ class ir_fields_converter(orm.Model):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
_(u"Value '%s' not found in selection field '%%(field)s'") % (
|
_(u"Value '%s' not found in selection field '%%(field)s'") % (
|
||||||
value), {
|
value), {
|
||||||
'moreinfo': [label or unicode(item) for item, label in selection
|
'moreinfo': [_label or unicode(item) for item, _label in selection
|
||||||
if label or item]
|
if _label or item]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -303,10 +303,10 @@ class ir_values(osv.osv):
|
||||||
(SELECT company_id from res_users where id = %%s)
|
(SELECT company_id from res_users where id = %%s)
|
||||||
)
|
)
|
||||||
%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)
|
params = ('default', model, uid, uid)
|
||||||
if condition:
|
if condition:
|
||||||
query %= 'AND (v.key2 = %s OR v.key2 IS NULL)'
|
query %= 'AND v.key2 = %s'
|
||||||
params += (condition[:200],)
|
params += (condition[:200],)
|
||||||
else:
|
else:
|
||||||
query %= 'AND v.key2 is NULL'
|
query %= 'AND v.key2 is NULL'
|
||||||
|
|
|
@ -72,7 +72,7 @@ _SAFE_OPCODES = _EXPR_OPCODES.union(set(opmap[x] for x in [
|
||||||
# New in Python 2.7 - http://bugs.python.org/issue4715 :
|
# New in Python 2.7 - http://bugs.python.org/issue4715 :
|
||||||
'JUMP_IF_FALSE_OR_POP', 'JUMP_IF_TRUE_OR_POP', 'POP_JUMP_IF_FALSE',
|
'JUMP_IF_FALSE_OR_POP', 'JUMP_IF_TRUE_OR_POP', 'POP_JUMP_IF_FALSE',
|
||||||
'POP_JUMP_IF_TRUE', 'SETUP_EXCEPT', 'END_FINALLY',
|
'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
|
'LOAD_GLOBAL', # Only allows access to restricted globals
|
||||||
] if x in opmap))
|
] if x in opmap))
|
||||||
|
|
||||||
|
@ -300,6 +300,7 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal
|
||||||
'range': range,
|
'range': range,
|
||||||
'xrange': xrange,
|
'xrange': xrange,
|
||||||
'zip': zip,
|
'zip': zip,
|
||||||
|
'Exception': Exception,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if locals_builtins:
|
if locals_builtins:
|
||||||
|
|
Loading…
Reference in New Issue