Upgrade changes to 5.x

This commit is contained in:
Raimon Esteve 2019-04-03 16:47:24 +02:00
parent 69ed45eca8
commit 83f22ea491
6 changed files with 32 additions and 27 deletions

View file

@ -1,11 +1,7 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.location:"
msgid "You do not have permissions to move products from location \"%s\"."
msgstr "No teniu permisos per moure productes des de la ubicació \"%s\"."
msgctxt "field:stock.location,inputs_group:"
msgid "Inputs Group"
msgstr "Grup entrades"
@ -29,3 +25,7 @@ msgid ""
msgstr ""
"Si es defineix només els usuaris d'aquest grup podran realitzar moviments "
"des d'aquesta ubicació"
msgctxt "model:ir.message,text:msg_no_permissions_for_output_moves"
msgid "You do not have permissions to move products from location \"%(location)s\"."
msgstr "No teniu permisos per moure productes des de la ubicació \"%(location)s\"."

View file

@ -1,11 +1,7 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.location:"
msgid "You do not have permissions to move products from location \"%s\"."
msgstr "No tienes permisos para mover productos desde la ubicación \"%s\"."
msgctxt "field:stock.location,inputs_group:"
msgid "Inputs Group"
msgstr "Grupo entradas"
@ -29,3 +25,7 @@ msgid ""
msgstr ""
"Si se define, solo los usuarios de este grupo podrán realizar movimientos "
"desde esta ubiación"
msgctxt "model:ir.message,text:msg_no_permissions_for_output_moves"
msgid "You do not have permissions to move products from location \"%(location)s\"."
msgstr "No tienes permisos para mover productos desde la ubicación \"%(location)s\"."

10
message.xml Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data group="1">
<record model="ir.message" id="msg_no_permissions_for_output_moves">
<field name="text">You do not have permissions to move products from location "%(location)s".</field>
</record>
</data>
</tryton>

View file

@ -3,6 +3,8 @@
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.i18n import gettext
from trytond.exceptions import UserError
from trytond.modules.stock.location import STATES, DEPENDS
__all__ = ['Location', 'Move']
@ -19,15 +21,6 @@ class Location(metaclass=PoolMeta):
help='If defined only users from this group will be allowed to make '
'moves to this location')
@classmethod
def __setup__(cls):
super(Location, cls).__setup__()
cls._error_messages.update({
'no_permissions_for_output_moves': (
'You do not have permissions to move products from location '
'"%s".'),
})
@classmethod
def _check_location_group(cls, locations, type_):
pool = Pool()
@ -42,8 +35,9 @@ class Location(metaclass=PoolMeta):
if not group:
continue
if group not in groups:
cls.raise_user_error('no_permissions_for_output_moves',
location.rec_name)
raise UserError(
gettext('stock_location_group.msg_no_permissions_for_output_moves',
location=location.rec_name))
@classmethod
def check_location_outputs_group(cls, locations):

View file

@ -38,12 +38,12 @@ class TestCase(ModuleTestCase):
'name': 'Test location access',
'type': 'goods',
'list_price': Decimal(1),
'cost_price': Decimal(0),
'cost_price_method': 'fixed',
'default_uom': kg.id,
}])
product, = Product.create([{
'template': template.id,
'cost_price': Decimal(0),
}])
supplier, = Location.search([('code', '=', 'SUP')])
storage, = Location.search([('code', '=', 'STO')])
@ -69,12 +69,12 @@ class TestCase(ModuleTestCase):
Location.write([supplier], {'outputs_group': group.id})
# Unable to do output move
access_error = ('You do not have permisons to move products '
'from location "%s".')
access_error = ('You do not have permissions to move products '
'from location "%(location)s".')
with self.assertRaises(UserError) as cm:
do_move(supplier, storage)
self.assertEqual(cm.exception.message,
access_error % supplier.rec_name)
access_error % {'location': supplier.rec_name})
# No problem doing input move
do_move(storage, supplier)
@ -85,7 +85,7 @@ class TestCase(ModuleTestCase):
with self.assertRaises(UserError) as cm:
do_move(storage, customer)
self.assertEqual(cm.exception.message,
access_error % customer.rec_name)
access_error % {'location': customer.rec_name})
# No problem if user belongs to restricted group
User.write([User(Transaction().user)], {

View file

@ -1,6 +1,7 @@
[tryton]
version=4.1.0
version=5.1.0
depends:
stock
xml:
stock.xml
message.xml