Migrate to 6.0
This commit is contained in:
parent
f01afd72de
commit
2133a3ca94
|
@ -2,7 +2,7 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:stock.product.category.location:"
|
||||
msgctxt "model:ir.message,text:msg_category_location_unique_key"
|
||||
msgid "Category and location must be unique."
|
||||
msgstr "Categoria y ubicación deben ser únicos."
|
||||
|
||||
|
|
27
location.py
27
location.py
|
@ -4,6 +4,8 @@ from trytond.model import ModelView, ModelSQL, fields
|
|||
from trytond.pyson import Eval, Bool, Not, Equal
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from sql.aggregate import Max
|
||||
|
||||
|
||||
|
@ -34,16 +36,11 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
|||
], depends=['warehouse'])
|
||||
sequence = fields.Integer('Sequence')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ProductCategoryLocation, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'unique_key': 'Category and location must be unique.'})
|
||||
|
||||
@staticmethod
|
||||
def _compute_sequence_where(table, record):
|
||||
return ((table.category == record['category']) &
|
||||
(table.warehouse == record['warehouse']))
|
||||
return (
|
||||
(table.category == record['category'])
|
||||
& (table.warehouse == record['warehouse']))
|
||||
|
||||
@staticmethod
|
||||
def _compute_sequence(table, record):
|
||||
|
@ -63,7 +60,7 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
|||
if not values.get('sequence', None):
|
||||
values['sequence'] = cls._compute_sequence(
|
||||
cls.__table__(), values)
|
||||
return super(ProductCategoryLocation, cls).create(vlist)
|
||||
return super().create(vlist)
|
||||
|
||||
@classmethod
|
||||
def default_warehouse(cls):
|
||||
|
@ -88,16 +85,20 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
|||
for record in records:
|
||||
_uq = record._get_unique_key()
|
||||
if values.get(_uq):
|
||||
cls.raise_user_error('unique_key')
|
||||
raise UserError(gettext(
|
||||
'stock_product_category_location.'
|
||||
'msg_category_location_unique_key'))
|
||||
values.setdefault(_uq, 1)
|
||||
|
||||
others = cls.search([('id', 'not in', list(map(int, records)))])
|
||||
for other in others:
|
||||
_uq = other._get_unique_key()
|
||||
if values.get(_uq):
|
||||
cls.raise_user_error('unique_key')
|
||||
raise UserError(gettext(
|
||||
'stock_product_category_location.'
|
||||
'msg_category_location_unique_key'))
|
||||
|
||||
super(ProductCategoryLocation, cls).validate(records)
|
||||
super().validate(records)
|
||||
|
||||
|
||||
class Location(metaclass=PoolMeta):
|
||||
|
@ -118,6 +119,6 @@ class Location(metaclass=PoolMeta):
|
|||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return super(Location, cls).view_attributes() + [
|
||||
return super().view_attributes() + [
|
||||
('//page[@id="categories"]', 'states', {
|
||||
'invisible': ~Eval('type').in_(['warehouse', 'storage'])})]
|
||||
|
|
|
@ -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.product.category.location -->
|
||||
<record model="ir.message" id="msg_category_location_unique_key">
|
||||
<field name="text">Category and location must be unique.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
16
stock.py
16
stock.py
|
@ -9,7 +9,7 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||
__name__ = 'stock.shipment.out'
|
||||
|
||||
def _get_inventory_move(self, move):
|
||||
res = super(ShipmentOut, self)._get_inventory_move(move)
|
||||
res = super()._get_inventory_move(move)
|
||||
if not res or hasattr(res, 'unit_load'):
|
||||
return res
|
||||
for c in res.product.categories:
|
||||
|
@ -27,14 +27,13 @@ class ShipmentOut(metaclass=PoolMeta):
|
|||
class ShipmentOutReturn(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.out.return'
|
||||
|
||||
@classmethod
|
||||
def _get_inventory_moves(cls, incoming_move):
|
||||
res = super(ShipmentOutReturn, cls)._get_inventory_moves(incoming_move)
|
||||
def _get_inventory_move(self, incoming_move):
|
||||
res = super()._get_inventory_move(incoming_move)
|
||||
if not res:
|
||||
return res
|
||||
for c in res.product.categories:
|
||||
_to_location = c.get_default_location(
|
||||
**cls._get_default_location_params(incoming_move))
|
||||
**self._get_default_location_params(incoming_move))
|
||||
if _to_location:
|
||||
res.to_location = _to_location
|
||||
break
|
||||
|
@ -48,14 +47,13 @@ class ShipmentOutReturn(metaclass=PoolMeta):
|
|||
class ShipmentIn(metaclass=PoolMeta):
|
||||
__name__ = 'stock.shipment.in'
|
||||
|
||||
@classmethod
|
||||
def _get_inventory_moves(cls, incoming_move):
|
||||
res = super(ShipmentIn, cls)._get_inventory_moves(incoming_move)
|
||||
def _get_inventory_move(self, incoming_move):
|
||||
res = super()._get_inventory_move(incoming_move)
|
||||
if not res:
|
||||
return res
|
||||
for c in res.product.categories:
|
||||
_to_location = c.get_default_location(
|
||||
**cls._get_default_location_params(incoming_move))
|
||||
**self._get_default_location_params(incoming_move))
|
||||
if _to_location:
|
||||
res.to_location = _to_location
|
||||
break
|
||||
|
|
|
@ -11,3 +11,4 @@ extras_depend:
|
|||
xml:
|
||||
location.xml
|
||||
product.xml
|
||||
message.xml
|
Loading…
Reference in New Issue