Migrate to 6.0
This commit is contained in:
parent
6429ee7182
commit
dd476c7a51
72
locale/es.po
72
locale/es.po
|
@ -2,59 +2,59 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Cannot change state of UL \"%s\" due to its last moves come from \"%s\"."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_state_origin"
|
||||
msgid "Cannot change state of UL \"%(unit_load)s\" due to its last moves come from \"%(origin)s\"."
|
||||
msgstr ""
|
||||
"No puede cambiar el estado de la UdC \"%s\" porque sus últimos movimientos "
|
||||
"tienen como origen \"%s\"."
|
||||
"No puede cambiar el estado de la UdC \"%(unit_load)s\" porque sus últimos movimientos "
|
||||
"tienen como origen \"%(origin)s\"."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Cannot find current location of UL \"%s\" from its moves."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_missing_location"
|
||||
msgid "Cannot find current location of UL \"%(unit_load)s\" from its moves."
|
||||
msgstr ""
|
||||
"No ha sido posible encontrar la ubicación actual de la UdC \"%s\" en base a sus movimientos."
|
||||
"No ha sido posible encontrar la ubicación actual de la UdC \"%(unit_load)s\" en base a sus movimientos."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Cannot move unit load \"%s\" at date \"%s\" because later moves exist."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_wrong_move_date"
|
||||
msgid "Cannot move unit load \"%(unit_load)s\" at date \"%(date)s\" because later moves exist."
|
||||
msgstr ""
|
||||
"No puede mover la UdC \"%s\" en la fecha \"%s\" porque hay movimientos "
|
||||
"No puede mover la UdC \"%(unit_load)s\" en la fecha \"%(date)s\" porque hay movimientos "
|
||||
"posteriores."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Cannot move unit load \"%s\" to Location \"%s\". Check its movements."
|
||||
msgstr "No puede mover la UdC \"%s\" a la ubicación \"%s\". Revise sus movimientos."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_wrong_move_location"
|
||||
msgid "Cannot move unit load \"%(unit_load)s\" to Location \"%(location)s\". Check its movements."
|
||||
msgstr "No puede mover la UdC \"%(unit_load)s\" a la ubicación \"%(location)s\". Revise sus movimientos."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_missing_return_location"
|
||||
msgid ""
|
||||
"Cannot set location in returning move of product \"%s\" of UL \"%s\" during "
|
||||
"Cannot set location in returning move of product \"%(product)s\" of UL \"%(unit_load)s\" during "
|
||||
"its dropping process."
|
||||
msgstr ""
|
||||
"No se puede establecer ubicación de retorno para el producto \"%s\" de la UdC \"%s\" durante el proceso de volcado."
|
||||
"No se puede establecer ubicación de retorno para el producto \"%(product)s\" de la UdC \"%(unit_load)s\" durante el proceso de volcado."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Unit load \"%s\" must be in Done state before moving."
|
||||
msgstr "Unidad de carga \"%s\" debe estar en estado Realizado para ser movida."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_wrong_state"
|
||||
msgid "Unit load \"%(unit_load)s\" must be in Done state before moving."
|
||||
msgstr "Unidad de carga \"%(unit_load)s\" debe estar en estado Realizado para ser movida."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Cannot drop more quantity (%s) than total quantity (%s) in UL \"%s\"."
|
||||
msgstr "No puede volcar más cantidad (%s) que la total (%s) en la UdC \"%s\"."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_wrong_dropped_qty"
|
||||
msgid "Cannot drop more quantity (%(dropped_qty)s) than total quantity (%(quantity)s) in UL \"%(unit_load)s\"."
|
||||
msgstr "No puede volcar más cantidad (%(dropped_qty)s) que la total (%(quantity)s) en la UdC \"%(unit_load)s\"."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Unit load \"%s\" is not available."
|
||||
msgstr "La Unidad de carga \"%s\" no está disponible."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_ul_not_available"
|
||||
msgid "Unit load \"%(unit_load)s\" is not available."
|
||||
msgstr "La Unidad de carga \"%(unit_load)s\" no está disponible."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Unit load \"%s\" is done."
|
||||
msgstr "La Unidad de carga \"%s\" está finalizada."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_ul_done"
|
||||
msgid "Unit load \"%(unit_load)s\" is done."
|
||||
msgstr "La Unidad de carga \"%(unit_load)s\" está finalizada."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgid "Cannot delete the Unit load \"%s\" on done production state."
|
||||
msgstr "No es posible eliminar la Unidad de carga \"%s\" en estado de producción finalizada."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_delete_done"
|
||||
msgid "Cannot delete the Unit load \"%(unit_load)s\" on done production state."
|
||||
msgstr "No es posible eliminar la Unidad de carga \"%(unit_load)s\" en estado de producción finalizada."
|
||||
|
||||
msgctxt "error:stock.unit_load:"
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_check_qty_pos"
|
||||
msgid "UL quantity must be positive"
|
||||
msgstr "La cantidad de la unidad de carga debe ser positiva."
|
||||
|
||||
msgctxt "error:stock.move:"
|
||||
msgctxt "model:ir.message,text:msg_stock_move_ul_time_required"
|
||||
msgid "Time in Unit load moves is required."
|
||||
msgstr "Los movimientos de UdC deben tener Hora efectiva."
|
||||
|
||||
|
@ -822,9 +822,9 @@ msgctxt "view:stock.unit_load:"
|
|||
msgid "Last moves will be deleted."
|
||||
msgstr "El último movimiento de UdC será eliminado."
|
||||
|
||||
msgctxt "error:stock.unit_load.do_drop:"
|
||||
msgid "Cannot find Unit load \"%s\"."
|
||||
msgstr "No se ha podido encontrar la UdC \"%s\"."
|
||||
msgctxt "model:ir.message,text:msg_stock_unit_load_do_drop_invalid_ul"
|
||||
msgid "Cannot find Unit load \"%(unit_load)s\"."
|
||||
msgstr "No se ha podido encontrar la UdC \"%(unit_load)s\"."
|
||||
|
||||
msgctxt "field:res.user,ul_drop_location:"
|
||||
msgid "UL drop location"
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?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.move -->
|
||||
<record model="ir.message" id="msg_stock_move_ul_time_required">
|
||||
<field name="text">Time in Unit load moves is required.</field>
|
||||
</record>
|
||||
|
||||
<!-- stock.unit_load -->
|
||||
<record model="ir.message" id="msg_stock_unit_load_wrong_move_date">
|
||||
<field name="text">Cannot move unit load "%(unit_load)s" at date "%(date)s" because later moves exist.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_wrong_state">
|
||||
<field name="text">Unit load "%(unit_load)s" must be in Done state before moving.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_wrong_move_location">
|
||||
<field name="text">Cannot move unit load "%(unit_load)s" to Location "%(location)s". Check its movements.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_missing_return_location">
|
||||
<field name="text">Cannot set location in returning move of product "%(product)s" of UL "%(unit_load)s" during its dropping process.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_wrong_dropped_qty">
|
||||
<field name="text">Cannot drop more quantity (%(dropped_qty)s) than total quantity (%(quantity)s) in UL "%(unit_load)s".</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_state_origin">
|
||||
<field name="text">Cannot change state of UL "%(unit_load)s" due to its last moves come from "%(origin)s".</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_missing_location">
|
||||
<field name="text">Cannot find current location of UL "%(unit_load)s" from its moves.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_ul_not_available">
|
||||
<field name="text">Unit load "%(unit_load)s" is not available.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_delete_done">
|
||||
<field name="text">Cannot delete the Unit load "%(unit_load)s" on done production state.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_ul_done">
|
||||
<field name="text">Unit load "%(unit_load)s" is done.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_stock_unit_load_check_qty_pos">
|
||||
<field name="text">UL quantity must be positive</field>
|
||||
</record>
|
||||
|
||||
<!-- stock.unit_load.do_drop -->
|
||||
<record model="ir.message" id="msg_stock_unit_load_do_drop_invalid_ul">
|
||||
<field name="text">Cannot find Unit load "%(unit_load)s".</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
10
shipment.py
10
shipment.py
|
@ -100,10 +100,9 @@ class ShipmentOut(ShipmentUnitLoadMixin, metaclass=PoolMeta):
|
|||
return ['inventory_moves', 'outgoing_moves']
|
||||
|
||||
@classmethod
|
||||
def _sync_inventory_to_outgoing(cls, shipments, create=True, write=True):
|
||||
def _sync_inventory_to_outgoing(cls, shipments, quantity=True):
|
||||
shipments = [s for s in shipments if not s.unit_loads]
|
||||
super()._sync_inventory_to_outgoing(shipments, create=create,
|
||||
write=write)
|
||||
super()._sync_inventory_to_outgoing(shipments, quantity=quantity)
|
||||
|
||||
|
||||
class ShipmentInternal(ShipmentUnitLoadMixin, metaclass=PoolMeta):
|
||||
|
@ -180,9 +179,8 @@ class ShipmentOutReturn(ShipmentUnitLoadMixin, metaclass=PoolMeta):
|
|||
moves.extend(new_moves)
|
||||
self.incoming_moves = moves
|
||||
|
||||
@classmethod
|
||||
def _get_inventory_moves(cls, incoming_move):
|
||||
move = super()._get_inventory_moves(incoming_move)
|
||||
def _get_inventory_move(self, incoming_move):
|
||||
move = super()._get_inventory_move(incoming_move)
|
||||
if move and incoming_move.unit_load:
|
||||
move.unit_load = incoming_move.unit_load
|
||||
return move
|
||||
|
|
11
stock.py
11
stock.py
|
@ -7,6 +7,8 @@ from trytond.model import fields, ModelView, Workflow
|
|||
from trytond.pyson import PYSONEncoder, Date, Bool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, Button, StateAction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from itertools import groupby
|
||||
|
||||
__all__ = ['Move', 'UnitLoadsByLocationsStart',
|
||||
|
@ -59,13 +61,8 @@ class Move(metaclass=PoolMeta):
|
|||
super(Move, cls).validate(records)
|
||||
for record in records:
|
||||
if record.unit_load and record.time_ is None:
|
||||
cls.raise_user_error('ul_time_required')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Move, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'ul_time_required': 'Time in Unit load moves is required.'})
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_move_ul_time_required'))
|
||||
|
||||
@classmethod
|
||||
@set_unit_load_state
|
||||
|
|
|
@ -37,15 +37,14 @@ Create main product::
|
|||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> product.save()
|
||||
|
||||
Create another product::
|
||||
|
@ -53,15 +52,14 @@ Create another product::
|
|||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> aux_product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Aux. product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('0')
|
||||
>>> template.cost_price = Decimal('2')
|
||||
>>> template.save()
|
||||
>>> aux_product.template = template
|
||||
>>> aux_product, = template.products
|
||||
>>> aux_product.cost_price = Decimal('2')
|
||||
>>> aux_product.save()
|
||||
|
||||
Get stock locations::
|
||||
|
@ -105,6 +103,7 @@ Add moves::
|
|||
>>> output_move.quantity = Decimal('4')
|
||||
>>> output_move.from_location = production_loc
|
||||
>>> output_move.to_location = new_stor
|
||||
>>> output_move.unit_price = aux_product.cost_price
|
||||
>>> unit_load.save()
|
||||
>>> len(unit_load.production_moves)
|
||||
3
|
||||
|
@ -139,6 +138,7 @@ Add moves::
|
|||
>>> output_move.quantity = Decimal('4')
|
||||
>>> output_move.from_location = production_loc
|
||||
>>> output_move.to_location = new_stor
|
||||
>>> output_move.unit_price = aux_product.cost_price
|
||||
>>> unit_load2.save()
|
||||
>>> len(unit_load2.production_moves)
|
||||
3
|
||||
|
|
|
@ -33,15 +33,14 @@ Create main product::
|
|||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> product.save()
|
||||
|
||||
Create another product::
|
||||
|
@ -49,15 +48,14 @@ Create another product::
|
|||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> aux_product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Aux. product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('0')
|
||||
>>> template.cost_price = Decimal('2')
|
||||
>>> template.save()
|
||||
>>> aux_product.template = template
|
||||
>>> aux_product, = template.products
|
||||
>>> aux_product.cost_price = Decimal('2')
|
||||
>>> aux_product.save()
|
||||
|
||||
Get stock locations::
|
||||
|
@ -101,6 +99,7 @@ Add moves::
|
|||
>>> output_move.quantity = Decimal('4')
|
||||
>>> output_move.from_location = production_loc
|
||||
>>> output_move.to_location = new_stor
|
||||
>>> output_move.unit_price = aux_product.cost_price
|
||||
>>> unit_load.save()
|
||||
>>> len(unit_load.production_moves)
|
||||
3
|
||||
|
@ -271,6 +270,7 @@ Add moves::
|
|||
>>> output_move.quantity = Decimal('4')
|
||||
>>> output_move.from_location = production_loc
|
||||
>>> output_move.to_location = new_stor
|
||||
>>> output_move.unit_price = aux_product.cost_price
|
||||
>>> unit_load.warehouse = warehouse_loc
|
||||
>>> unit_load.save()
|
||||
>>> unit_load.click('assign')
|
||||
|
@ -341,6 +341,7 @@ Add moves::
|
|||
>>> output_move.quantity = Decimal('4')
|
||||
>>> output_move.from_location = production_loc
|
||||
>>> output_move.to_location = new_stor
|
||||
>>> output_move.unit_price = aux_product.cost_price
|
||||
>>> unit_load.click('assign')
|
||||
>>> unit_load.click('do')
|
||||
|
||||
|
@ -390,6 +391,7 @@ Create new unit load and moves::
|
|||
>>> output_move2.quantity = Decimal('4')
|
||||
>>> output_move2.from_location = production_loc
|
||||
>>> output_move2.to_location = new_stor
|
||||
>>> output_move2.unit_price = aux_product.cost_price
|
||||
>>> unit_load2.warehouse = warehouse_loc
|
||||
>>> unit_load2.save()
|
||||
>>> unit_load2.click('assign')
|
||||
|
@ -453,6 +455,7 @@ Create new unit load and moves::
|
|||
>>> output_move.quantity = Decimal('4')
|
||||
>>> output_move.from_location = production_loc
|
||||
>>> output_move.to_location = new_stor
|
||||
>>> output_move.unit_price = aux_product.cost_price
|
||||
>>> unit_load3.warehouse = warehouse_loc
|
||||
>>> unit_load3.save()
|
||||
>>> unit_load3.click('assign')
|
||||
|
|
|
@ -13,6 +13,7 @@ Imports::
|
|||
... get_company
|
||||
>>> now = datetime.datetime.now()
|
||||
>>> tomorrow = now + relativedelta(days=1)
|
||||
>>> from trytond.modules.stock.exceptions import MoveFutureWarning
|
||||
|
||||
|
||||
Install unit load Module::
|
||||
|
@ -31,15 +32,14 @@ Create product::
|
|||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> product.save()
|
||||
|
||||
|
||||
|
@ -111,6 +111,16 @@ Add unit load to shipment::
|
|||
>>> shipment_in_return.click('wait')
|
||||
>>> shipment_in_return.click('assign_try')
|
||||
True
|
||||
>>> try:
|
||||
... shipment_in_return.click('done')
|
||||
... except MoveFutureWarning as warning:
|
||||
... _, (key, *_) = warning.args
|
||||
... raise
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
trytond.modules.stock.exceptions.MoveFutureWarning: The moves "35u Product" have effective dates in the future. -
|
||||
>>> Warning = Model.get('res.user.warning')
|
||||
>>> Warning(user=config.user, name=key).save()
|
||||
>>> shipment_in_return.click('done')
|
||||
|
||||
|
||||
|
|
|
@ -37,15 +37,14 @@ Create product::
|
|||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> product.save()
|
||||
|
||||
Get stock locations::
|
||||
|
@ -77,10 +76,10 @@ Create an unit load::
|
|||
>>> unit_load.cases_quantity = 5
|
||||
>>> len(unit_load.production_moves)
|
||||
0
|
||||
>>> unit_load.save() # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
>>> unit_load.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
UserError: ...
|
||||
trytond.model.modelstorage.DomainValidationError: The value for field "Production location" in "Unit load" is not valid according to its domain. -
|
||||
>>> unit_load.production_location = production_loc
|
||||
>>> unit_load.save()
|
||||
>>> unit_load.code != None
|
||||
|
|
|
@ -32,15 +32,14 @@ Create product::
|
|||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> product.save()
|
||||
|
||||
Get stock locations::
|
||||
|
@ -71,7 +70,7 @@ Create an unit load::
|
|||
>>> unit_load.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
trytond.exceptions.UserError: The value of the field "Production location" on "Unit load" is not valid according to its domain. -
|
||||
trytond.model.modelstorage.DomainValidationError: The value for field "Production location" in "Unit load" is not valid according to its domain. -
|
||||
|
||||
>>> unit_load.production_location = production_loc
|
||||
>>> unit_load.save()
|
||||
|
@ -244,6 +243,7 @@ Add Unit load::
|
|||
True
|
||||
>>> shipment_out.click('assign_try')
|
||||
True
|
||||
>>> shipment_out.click('pick')
|
||||
>>> shipment_out.click('pack')
|
||||
>>> shipment_out.click('done')
|
||||
|
||||
|
@ -297,7 +297,7 @@ Check report::
|
|||
>>> ext
|
||||
'odt'
|
||||
>>> name
|
||||
'Label'
|
||||
'Label-1'
|
||||
|
||||
Check report case_label::
|
||||
|
||||
|
@ -306,4 +306,4 @@ Check report case_label::
|
|||
>>> ext
|
||||
'odt'
|
||||
>>> name
|
||||
'Case Label'
|
||||
'Case Label-1'
|
||||
|
|
|
@ -16,3 +16,4 @@ xml:
|
|||
stock.xml
|
||||
shipment.xml
|
||||
res.xml
|
||||
message.xml
|
||||
|
|
131
unit_load.py
131
unit_load.py
|
@ -22,6 +22,7 @@ from trytond.modules.stock_move_time.stock import DATE_FORMAT
|
|||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond.rpc import RPC
|
||||
from trytond.cache import Cache
|
||||
from trytond.i18n import gettext
|
||||
|
||||
__all__ = ['UnitLoad', 'UnitLoadMove', 'MoveUnitLoad',
|
||||
'MoveUnitLoadStart', 'UnitLoadLabel', 'DropUnitLoadData',
|
||||
|
@ -231,41 +232,14 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
t = cls.__table__()
|
||||
cls._sql_constraints += [
|
||||
('check_qty_pos', Check(t, t.internal_quantity >= 0),
|
||||
'UL quantity must be positive'),
|
||||
'stock_unit_load.msg_stock_unit_load_check_qty_pos'),
|
||||
]
|
||||
cls._error_messages.update({
|
||||
'missing_location':
|
||||
'Cannot find current location of UL "%s" from its moves.',
|
||||
'wrong_move_location':
|
||||
'Cannot move unit load "%s" to Location "%s". '
|
||||
'Check its movements.',
|
||||
'wrong_move_date':
|
||||
'Cannot move unit load "%s" at date "%s" because later '
|
||||
'moves exist.',
|
||||
'wrong_state':
|
||||
'Unit load "%s" must be in Done state before moving.',
|
||||
'state_origin':
|
||||
'Cannot change state of UL "%s" due to its last moves '
|
||||
'come from "%s".',
|
||||
'missing_return_location':
|
||||
'Cannot set location in returning move of product "%s" '
|
||||
'of UL "%s" during its dropping process.',
|
||||
'wrong_dropped_qty':
|
||||
'Cannot drop more quantity (%s) than total quantity (%s) '
|
||||
'in UL "%s".',
|
||||
'ul_not_available':
|
||||
'Unit load "%s" is not available.',
|
||||
'ul_done':
|
||||
'Unit load "%s" is done.',
|
||||
'delete_done':
|
||||
'Cannot delete the Unit load "%s" on done production state.'
|
||||
})
|
||||
|
||||
cls._buttons.update({
|
||||
'move_try': {
|
||||
'icon': 'tryton-forward',
|
||||
'invisible': (Eval('state') != 'done') | (~Eval('available')) |
|
||||
Eval('dropped'),
|
||||
'invisible': ((Eval('state') != 'done') | (~Eval('available'))
|
||||
| Eval('dropped')),
|
||||
'depends': ['state', 'available', 'dropped']
|
||||
},
|
||||
'assign': {
|
||||
|
@ -450,13 +424,18 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
def _check_deny_modify_done(cls, records):
|
||||
for record in records:
|
||||
if record.production_state == 'done':
|
||||
cls.raise_user_error('ul_done', record.rec_name)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_ul_done',
|
||||
unit_load=record.rec_name))
|
||||
|
||||
@classmethod
|
||||
def _check_deny_modify_not_available(cls, records):
|
||||
for record in records:
|
||||
if record.production_state == 'done' and not record.available:
|
||||
cls.raise_user_error('ul_not_available', record.rec_name)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_ul_not_available',
|
||||
unit_load=record.rec_name))
|
||||
|
||||
|
||||
def get_rec_name(self, name):
|
||||
if Transaction().context.get('ul_extended_rec_name', False):
|
||||
|
@ -913,12 +892,18 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
if not from_location:
|
||||
self.raise_user_error('missing_location', self.rec_name)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_missing_location',
|
||||
unit_load=self.rec_name))
|
||||
if self.state != 'done':
|
||||
self.raise_user_error('wrong_state', self.rec_name)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_wrong_state',
|
||||
unit_load=self.rec_name))
|
||||
if to_location.id == from_location.id:
|
||||
self.raise_user_error('wrong_move_location',
|
||||
(self.rec_name, to_location.rec_name))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_wrong_move_location',
|
||||
unit_load=self.rec_name,
|
||||
location=to_location.rec_name))
|
||||
_max_date = max(m.end_date for m in self.last_moves)
|
||||
|
||||
if from_location.type == 'storage' and \
|
||||
|
@ -936,7 +921,10 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
|
||||
ftdate = at_date.replace(tzinfo=szone).astimezone(
|
||||
lzone).replace(tzinfo=None)
|
||||
self.raise_user_error('wrong_move_date', (self.rec_name, ftdate))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_wrong_move_date',
|
||||
unit_load=self.rec_name,
|
||||
date=ftdate))
|
||||
|
||||
def _get_new_moves(self, default_values={}, location_type=None,
|
||||
cases_quantity=None, **kwargs):
|
||||
|
@ -1190,7 +1178,9 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
Move = pool.get('stock.move')
|
||||
for record in records:
|
||||
if record.production_state == 'done':
|
||||
cls.raise_user_error('delete_done', record.rec_name)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_delete_done',
|
||||
unit_load=record.rec_name))
|
||||
Move.cancel([m for r in records for m in r.moves])
|
||||
Move.delete([m for r in records for m in r.moves])
|
||||
super(UnitLoad, cls).delete(records)
|
||||
|
@ -1209,8 +1199,10 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
if m.state in ['cancelled', 'assigned']]
|
||||
for move in moves:
|
||||
if not cls.check_move_origin(move):
|
||||
cls.raise_user_error('state_origin', (
|
||||
move.unit_load.rec_name, move.origin.rec_name))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_state_origin',
|
||||
unit_load=move.unit_load.rec_name,
|
||||
origin=move.origin.rec_name))
|
||||
if moves:
|
||||
Move.draft(moves)
|
||||
|
||||
|
@ -1227,8 +1219,10 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
moves = cls.get_moves_to_cancel(records)
|
||||
for move in moves:
|
||||
if not cls.check_move_origin(move):
|
||||
cls.raise_user_error('state_origin', (
|
||||
move.unit_load.rec_name, move.origin.rec_name))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_state_origin',
|
||||
unit_load=move.unit_load.rec_name,
|
||||
origin=move.origin.rec_name))
|
||||
if moves:
|
||||
Move.cancel(moves)
|
||||
Move.delete(moves)
|
||||
|
@ -1250,8 +1244,10 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
if m.state in ('draft', 'assigned')]
|
||||
for move in origin_moves:
|
||||
if not cls.check_move_origin(move):
|
||||
cls.raise_user_error('state_origin', (
|
||||
move.unit_load.rec_name, move.origin.rec_name))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_state_origin',
|
||||
unit_load=move.unit_load.rec_name,
|
||||
origin=move.origin.rec_name))
|
||||
cls.check_dates(records)
|
||||
|
||||
cls._assing_ul_moves(records)
|
||||
|
@ -1267,8 +1263,10 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
cls.check_dates(records)
|
||||
for move in moves:
|
||||
if not cls.check_move_origin(move):
|
||||
cls.raise_user_error('state_origin', (move.unit_load.rec_name,
|
||||
move.origin.rec_name))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_state_origin',
|
||||
unit_load=move.unit_load.rec_name,
|
||||
origin=move.origin.rec_name))
|
||||
if moves:
|
||||
Move.do(moves)
|
||||
cls.set_drop_state(records)
|
||||
|
@ -1314,8 +1312,11 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
continue
|
||||
qty = record._get_dropped_quantity(done=True)
|
||||
if (qty - record.quantity) > 1.0:
|
||||
cls.raise_user_error('wrong_dropped_qty', (
|
||||
qty, record.quantity, record.rec_name))
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_wrong_dropped_qty',
|
||||
dropped_qty=qty,
|
||||
quantity=record.quantity,
|
||||
unit_load=record.rec_name))
|
||||
if abs(record.internal_quantity - qty) < 1.0 and \
|
||||
not record.dropped:
|
||||
to_drop.append(record)
|
||||
|
@ -1426,6 +1427,7 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
to_location=self.warehouse.storage_location
|
||||
if self.warehouse else None,
|
||||
product=self.product,
|
||||
unit_price=self.product and self.product.cost_price or 0,
|
||||
quantity=self.quantity,
|
||||
planned_date=self.start_date.date(),
|
||||
effective_date=self.start_date.date(),
|
||||
|
@ -1539,8 +1541,10 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
if not loc:
|
||||
loc = self._get_return_location(move.product)
|
||||
if not loc:
|
||||
self.raise_user_error('missing_return_location',
|
||||
move.product.rec_name, self.rec_name)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_missing_return_location',
|
||||
product=move.product.rec_name,
|
||||
unit_load=self.rec_name))
|
||||
move.to_location = loc
|
||||
return return_moves
|
||||
|
||||
|
@ -1670,7 +1674,9 @@ class UnitLoad(ModelSQL, ModelView):
|
|||
extra_params={'done_moves': True})
|
||||
return [ul.code for ul in uls]
|
||||
else:
|
||||
UnitLoad.raise_user_error('invalid_ul', ul_code)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_do_drop_invalid_ul',
|
||||
unit_load=ul_code))
|
||||
|
||||
@property
|
||||
def has_pallet(self):
|
||||
|
@ -1725,7 +1731,7 @@ class UnitLoadMove(ModelSQL, ModelView):
|
|||
where &= (move.unit_load == unit_load)
|
||||
date_column = (Coalesce(move.effective_date,
|
||||
move.planned_date) + move.time_)
|
||||
if backend.name() == 'sqlite':
|
||||
if backend.name == 'sqlite':
|
||||
date_column = Concat(Coalesce(move.effective_date,
|
||||
move.planned_date), Concat(' ', move.time_))
|
||||
return move.join(ul, condition=(
|
||||
|
@ -1941,13 +1947,6 @@ class DropUnitLoad(Wizard):
|
|||
Button('OK', 'force', 'tryton-ok', default=True)])
|
||||
force = StateTransition()
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(DropUnitLoad, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'invalid_ul': 'Cannot find Unit load "%s".'
|
||||
})
|
||||
|
||||
@property
|
||||
def current_ul(self):
|
||||
pool = Pool()
|
||||
|
@ -1958,7 +1957,9 @@ class DropUnitLoad(Wizard):
|
|||
ul = Unitload.search([
|
||||
('code', '=', self._get_ul_code())], limit=1)
|
||||
if not ul:
|
||||
self.raise_user_error('invalid_ul', self.unit_load.ul_code)
|
||||
raise UserError(gettext(
|
||||
'stock_unit_load.msg_stock_unit_load_do_drop_invalid_ul',
|
||||
unit_load=self.unit_load.ul_code))
|
||||
return ul[0]
|
||||
|
||||
def _get_ul_code(self):
|
||||
|
@ -2220,9 +2221,9 @@ class BatchDropUnitLoadData(ModelView):
|
|||
domain=[('end_date', '>=', Eval('start_date'))],
|
||||
depends=['start_date'])
|
||||
delay_ = fields.TimeDelta('Delay')
|
||||
unit_loads = fields.One2Many('stock.unit_load', 'None', 'Unit loads',
|
||||
required=True,
|
||||
domain=[('available', '=', True)])
|
||||
unit_loads = fields.One2Many('stock.unit_load', None, 'Unit loads',
|
||||
required=True,
|
||||
domain=[('available', '=', True)])
|
||||
|
||||
@fields.depends('unit_loads', 'start_date', 'end_date')
|
||||
def on_change_with_delay_(self):
|
||||
|
@ -2241,8 +2242,8 @@ class BatchDropUnitLoadConfirm(ModelView):
|
|||
"""Batch dropping UL confirm"""
|
||||
__name__ = 'stock.unit_load.batch_drop.confirm'
|
||||
|
||||
unit_loads = fields.One2Many('stock.unit_load', 'None', 'Unit loads',
|
||||
readonly=True)
|
||||
unit_loads = fields.One2Many('stock.unit_load', None, 'Unit loads',
|
||||
readonly=True)
|
||||
|
||||
|
||||
class BatchDropUnitLoad(Wizard):
|
||||
|
|
|
@ -117,12 +117,13 @@
|
|||
</record>
|
||||
|
||||
<record model="ir.rule.group" id="rule_group_unit_load">
|
||||
<field name="name">User in companies</field>
|
||||
<field name="model" search="[('model', '=', 'stock.unit_load')]"/>
|
||||
<field name="global_p" eval="True"/>
|
||||
</record>
|
||||
<record model="ir.rule" id="rule_unit_load">
|
||||
<field name="domain"
|
||||
eval="[('company', '=', Eval('user', {}).get('company', None))]"
|
||||
eval="[('company', 'in', Eval('companies', []))]"
|
||||
pyson="1"/>
|
||||
<field name="rule_group" ref="rule_group_unit_load"/>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue