Migrate to 6.0

This commit is contained in:
Sergio Morillo 2021-09-25 16:48:51 +02:00
parent f264024ba5
commit 56d9eb03e6
5 changed files with 27 additions and 16 deletions

View File

@ -1,12 +1,12 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.pool import Pool
from .location import Location, LocationCombined, Combined
from . import location
def register():
Pool.register(
Combined,
Location,
LocationCombined,
location.Combined,
location.Location,
location.LocationCombined,
module='stock_location_combined', type_='model')

View File

@ -2,9 +2,9 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.location.combined:"
msgid "Locations in Combined location \"%s\" must be of same type."
msgstr "Las ubicaciones de la Combinación \"%s\" deben ser del mismo tipo."
msgctxt "model:ir.message,text:msg_stock_location_combined_location_type"
msgid "Locations in Combined location \"%(a)s\" must be of same type."
msgstr "Las ubicaciones de la Combinación \"%(a)s\" deben ser del mismo tipo."
msgctxt "field:stock.location,combined:"
msgid "Combined locations"

View File

@ -3,8 +3,8 @@
from trytond.model import ModelSQL, ModelView, fields, DeactivableMixin
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval
__all__ = ['Combined', 'LocationCombined', 'Location']
from trytond.exceptions import UserError
from trytond.i18n import gettext
class Combined(DeactivableMixin, ModelView, ModelSQL):
@ -29,8 +29,6 @@ class Combined(DeactivableMixin, ModelView, ModelSQL):
Location = pool.get('stock.location')
super(Combined, cls).__setup__()
cls._error_messages.update({
'location_type': 'Locations in Combined location "%s" must be of same type.'})
if not cls.type._field.selection:
cls.type._field.selection.extend(Location.type.selection)
cls.locations.domain.append(
@ -57,7 +55,9 @@ class Combined(DeactivableMixin, ModelView, ModelSQL):
values = [l.type for l in record.locations]
_types.setdefault(record.id, set(values))
if len(_types[record.id]) > 1:
cls.raise_user_error('location_type', record.rec_name)
raise UserError(gettext(
'stock_location_combined.msg_location_combined_type',
location=record.rec_name))
class LocationCombined(ModelView, ModelSQL):
@ -79,13 +79,12 @@ class Location(metaclass=PoolMeta):
@classmethod
def validate(cls, records):
pool = Pool()
Combined = pool.get('stock.location.combined')
super(Location, cls).validate(records)
for record in records:
if not record.combined:
continue
for _combined in record.combined:
if any(l.type != record.type for l in _combined.locations):
Combined.raise_user_error('location_type', _combined.rec_name)
raise UserError(gettext(
'stock_location_combined.msg_location_combined_type',
location=_combined.rec_name))

11
message.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tryton>
<data grouped="1">
<!-- stock.location.combined -->
<record model="ir.message" id="msg_location_combined_type">
<field name="text">Locations in Combined location "%(location)s" must be of same type.</field>
</record>
</data>
</tryton>

View File

@ -7,3 +7,4 @@ depends:
xml:
location.xml
message.xml