Drag the lot of bulk to output product. Task 035549
This commit is contained in:
parent
6006ecaed1
commit
4f61e76750
|
@ -2,10 +2,12 @@
|
|||
# copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from . import production
|
||||
from . import bom
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
bom.BOMInput,
|
||||
production.Configuration,
|
||||
production.ConfigurationCompany,
|
||||
production.Production,
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields, Unique
|
||||
from trytond.wizard import Wizard, StateView, Button
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
|
||||
__all__ = ['BOMInput']
|
||||
|
||||
class BOMInput(metaclass=PoolMeta):
|
||||
__name__ = 'production.bom.input'
|
||||
use_lot = fields.Boolean('Use Lot')
|
||||
|
||||
@classmethod
|
||||
def validate(cls, boms):
|
||||
super(BOMInput, cls).validate(boms)
|
||||
for bom in boms:
|
||||
bom.check_unique_use_lot_in_bom()
|
||||
|
||||
def check_unique_use_lot_in_bom(self):
|
||||
inputs = self.search([
|
||||
('bom', '=', self.bom.id),
|
||||
('use_lot', '=', True)
|
||||
])
|
||||
if len(inputs) > 1:
|
||||
raise UserError(gettext('production_output_lot.unique_use_lot_in_bom'))
|
|
@ -0,0 +1,17 @@
|
|||
<?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>
|
||||
<record model="ir.ui.view" id="bom_input_view_form">
|
||||
<field name="model">production.bom.input</field>
|
||||
<field name="inherit" ref="production.bom_input_view_form"/>
|
||||
<field name="name">bom_input_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="bom_input_view_list">
|
||||
<field name="model">production.bom.input</field>
|
||||
<field name="inherit" ref="production.bom_input_view_list"/>
|
||||
<field name="name">bom_input_list</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
74
locale/ca.po
74
locale/ca.po
|
@ -1,22 +1,10 @@
|
|||
#
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:production:"
|
||||
msgid ""
|
||||
"The \"When Output Lot is created?\" or \"Output Lot Sequence\" Production "
|
||||
"configuration params are empty."
|
||||
msgstr ""
|
||||
"No s'han establert els paràmetres de la configuració de la producció \"Quan "
|
||||
"es creen els lots de sortida?\" o \"Seqüència lots de sortida\"."
|
||||
|
||||
msgctxt "error:stock.move:"
|
||||
msgid ""
|
||||
"There is not output lot sequence defined. Please define one in production "
|
||||
"configuration."
|
||||
msgstr ""
|
||||
"No s'ha definit cap seqüencia de lot de sortida. Si us plau, definiu-n'hi "
|
||||
"una a la configuració de produccions."
|
||||
msgctxt "field:production.bom.input,use_lot:"
|
||||
msgid "Use Lot"
|
||||
msgstr "Utilitzar lot"
|
||||
|
||||
msgctxt "field:production.configuration,output_lot_creation:"
|
||||
msgid "When Output Lot is created?"
|
||||
|
@ -30,18 +18,6 @@ msgctxt "field:production.configuration.company,company:"
|
|||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "field:production.configuration.company,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Data creació"
|
||||
|
||||
msgctxt "field:production.configuration.company,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuari creació"
|
||||
|
||||
msgctxt "field:production.configuration.company,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:production.configuration.company,output_lot_creation:"
|
||||
msgid "When Output Lot is created?"
|
||||
msgstr "Quan es creen els lots de sortida?"
|
||||
|
@ -50,18 +26,6 @@ msgctxt "field:production.configuration.company,output_lot_sequence:"
|
|||
msgid "Output Lot Sequence"
|
||||
msgstr "Seqüència lots de sortida"
|
||||
|
||||
msgctxt "field:production.configuration.company,rec_name:"
|
||||
msgid "Name"
|
||||
msgstr "Nom"
|
||||
|
||||
msgctxt "field:production.configuration.company,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Data modificació"
|
||||
|
||||
msgctxt "field:production.configuration.company,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuari modificació"
|
||||
|
||||
msgctxt "help:production.configuration,output_lot_creation:"
|
||||
msgid ""
|
||||
"The Production's state in which the Output Lot will be created "
|
||||
|
@ -71,6 +35,32 @@ msgstr ""
|
|||
"L'estat de la producció en el qual es crearan els lots de sortida per "
|
||||
"aquells productes configurats per requerir lot a la producció."
|
||||
|
||||
msgctxt "model:ir.message,text:missing_output_lot_creation_config"
|
||||
msgid ""
|
||||
"The \"When Output Lot is created?\" or \"Output Lot Sequence\" Production "
|
||||
"configuration params are empty."
|
||||
msgstr ""
|
||||
"Els paràmetres de configuració de producció \"Quan es crea el lot de "
|
||||
"sortida?\" o \"Seqüència de lot de sortida\" estan buits."
|
||||
|
||||
msgctxt "model:ir.message,text:more_than_one_input_lots"
|
||||
msgid "There is more than one lot in inputs. Please check input moves."
|
||||
msgstr ""
|
||||
"Hi ha més d'un lot en les entrades. Si us plau verifiqui els moviments "
|
||||
"d'entrada."
|
||||
|
||||
msgctxt "model:ir.message,text:no_sequence"
|
||||
msgid ""
|
||||
"There is not output lot sequence defined. Please define one in production "
|
||||
"configuration."
|
||||
msgstr ""
|
||||
"No hi ha seqüència de lot de sortida definida. Si us plau defineixi una en "
|
||||
"la configuració de producció."
|
||||
|
||||
msgctxt "model:ir.message,text:unique_use_lot_in_bom"
|
||||
msgid "Only one input product can have the option to use lot marked."
|
||||
msgstr "Només un producte d'entrada pot tenir l'opció d'usar el lot marcat."
|
||||
|
||||
msgctxt "model:production.configuration.company,name:"
|
||||
msgid "Production Configuration by Company"
|
||||
msgstr "Configuración de la producció per empresa"
|
||||
|
@ -83,10 +73,6 @@ msgctxt "selection:production.configuration,output_lot_creation:"
|
|||
msgid "Production is Done"
|
||||
msgstr "Producció realitzada"
|
||||
|
||||
msgctxt "selection:production.configuration.company,output_lot_creation:"
|
||||
msgid ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:production.configuration.company,output_lot_creation:"
|
||||
msgid "Production in Running"
|
||||
msgstr "Producció en curs"
|
||||
|
|
75
locale/es.po
75
locale/es.po
|
@ -1,22 +1,10 @@
|
|||
#
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:production:"
|
||||
msgid ""
|
||||
"The \"When Output Lot is created?\" or \"Output Lot Sequence\" Production "
|
||||
"configuration params are empty."
|
||||
msgstr ""
|
||||
"No se han establecido los parámetros de la configuración de la producción "
|
||||
"\"¿Cuando se crean los lotes de salida?\" o \"Secuencia lotes salida\"."
|
||||
|
||||
msgctxt "error:stock.move:"
|
||||
msgid ""
|
||||
"There is not output lot sequence defined. Please define one in production "
|
||||
"configuration."
|
||||
msgstr ""
|
||||
"No se ha definido ninguna secuencia de lotes de salida. Por favor, defina "
|
||||
"una en la configuración de producción. "
|
||||
msgctxt "field:production.bom.input,use_lot:"
|
||||
msgid "Use Lot"
|
||||
msgstr "Usar lote"
|
||||
|
||||
msgctxt "field:production.configuration,output_lot_creation:"
|
||||
msgid "When Output Lot is created?"
|
||||
|
@ -30,18 +18,6 @@ msgctxt "field:production.configuration.company,company:"
|
|||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "field:production.configuration.company,create_date:"
|
||||
msgid "Create Date"
|
||||
msgstr "Fecha creación"
|
||||
|
||||
msgctxt "field:production.configuration.company,create_uid:"
|
||||
msgid "Create User"
|
||||
msgstr "Usuario creación"
|
||||
|
||||
msgctxt "field:production.configuration.company,id:"
|
||||
msgid "ID"
|
||||
msgstr "Identificador"
|
||||
|
||||
msgctxt "field:production.configuration.company,output_lot_creation:"
|
||||
msgid "When Output Lot is created?"
|
||||
msgstr "¿Cuando se crean los lotes de salida?"
|
||||
|
@ -50,18 +26,6 @@ msgctxt "field:production.configuration.company,output_lot_sequence:"
|
|||
msgid "Output Lot Sequence"
|
||||
msgstr "Secuencia lotes de salida"
|
||||
|
||||
msgctxt "field:production.configuration.company,rec_name:"
|
||||
msgid "Name"
|
||||
msgstr "Nombre"
|
||||
|
||||
msgctxt "field:production.configuration.company,write_date:"
|
||||
msgid "Write Date"
|
||||
msgstr "Fecha modificación"
|
||||
|
||||
msgctxt "field:production.configuration.company,write_uid:"
|
||||
msgid "Write User"
|
||||
msgstr "Usuario modificación"
|
||||
|
||||
msgctxt "help:production.configuration,output_lot_creation:"
|
||||
msgid ""
|
||||
"The Production's state in which the Output Lot will be created "
|
||||
|
@ -72,6 +36,33 @@ msgstr ""
|
|||
"de salida, si el producto está configurado para requerir lotes en la "
|
||||
"producción."
|
||||
|
||||
msgctxt "model:ir.message,text:missing_output_lot_creation_config"
|
||||
msgid ""
|
||||
"The \"When Output Lot is created?\" or \"Output Lot Sequence\" Production "
|
||||
"configuration params are empty."
|
||||
msgstr ""
|
||||
"Los parámetros de configuración de producción \"¿Cuándo se crea el lote de "
|
||||
"salida?\" o \"Secuencia de lote de salida\" están vacíos."
|
||||
|
||||
msgctxt "model:ir.message,text:more_than_one_input_lots"
|
||||
msgid "There is more than one lot in inputs. Please check input moves."
|
||||
msgstr ""
|
||||
"Hay más de un lote en las entradas. Por favor verifique los movimientos de "
|
||||
"entrada."
|
||||
|
||||
msgctxt "model:ir.message,text:no_sequence"
|
||||
msgid ""
|
||||
"There is not output lot sequence defined. Please define one in production "
|
||||
"configuration."
|
||||
msgstr ""
|
||||
"No hay secuencia de lote de salida definida. Por favor defina una en la "
|
||||
"configuración de producción."
|
||||
|
||||
msgctxt "model:ir.message,text:unique_use_lot_in_bom"
|
||||
msgid "Only one input product can have the option to use lot marked."
|
||||
msgstr ""
|
||||
"Solo un producto de entrada puede tener la opción de usar el lote marcado."
|
||||
|
||||
msgctxt "model:production.configuration.company,name:"
|
||||
msgid "Production Configuration by Company"
|
||||
msgstr "Configuración producción por empresa"
|
||||
|
@ -84,10 +75,6 @@ msgctxt "selection:production.configuration,output_lot_creation:"
|
|||
msgid "Production is Done"
|
||||
msgstr "Producción realizada"
|
||||
|
||||
msgctxt "selection:production.configuration.company,output_lot_creation:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgctxt "selection:production.configuration.company,output_lot_creation:"
|
||||
msgid "Production in Running"
|
||||
msgstr "Producción en ejecución"
|
||||
|
|
18
message.xml
18
message.xml
|
@ -3,11 +3,17 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data grouped="1">
|
||||
<record model="ir.message" id="missing_output_lot_creation_config">
|
||||
<field name="text">The "When Output Lot is created?" or "Output Lot Sequence" Production configuration params are empty.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="no_sequence">
|
||||
<field name="text">There is not output lot sequence defined. Please define one in production configuration.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="missing_output_lot_creation_config">
|
||||
<field name="text">The "When Output Lot is created?" or "Output Lot Sequence" Production configuration params are empty.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="no_sequence">
|
||||
<field name="text">There is not output lot sequence defined. Please define one in production configuration.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="more_than_one_input_lots">
|
||||
<field name="text">There is more than one lot in inputs. Please check input moves.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="unique_use_lot_in_bom">
|
||||
<field name="text">Only one input product can have the option to use lot marked.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -47,7 +47,7 @@ class ConfigurationCompany(ModelSQL, CompanyValueMixin):
|
|||
'Production Configuration by Company'
|
||||
__name__ = 'production.configuration.company'
|
||||
|
||||
output_lot_creation = fields.Selection([(None, '')] + _OUTPUT_LOT_CREATION,
|
||||
output_lot_creation = fields.Selection(_OUTPUT_LOT_CREATION,
|
||||
'When Output Lot is created?')
|
||||
output_lot_sequence = fields.Many2One('ir.sequence',
|
||||
'Output Lot Sequence', domain=[
|
||||
|
@ -94,17 +94,36 @@ class Production(metaclass=PoolMeta):
|
|||
def create_output_lots(self):
|
||||
Config = Pool().get('production.configuration')
|
||||
config = Config(1)
|
||||
Lot = Pool().get('stock.lot')
|
||||
|
||||
if not config.output_lot_creation or not config.output_lot_sequence:
|
||||
raise UserError(gettext(
|
||||
'production_output_lot.missing_output_lot_creation_config'))
|
||||
|
||||
created_lots = []
|
||||
drag_lot = None
|
||||
|
||||
if self.bom:
|
||||
product, = [x for x in self.bom.inputs if x.use_lot == True]
|
||||
inputs = [x for x in self.inputs if x.lot
|
||||
and x.product == product.product]
|
||||
if len(inputs) != 1:
|
||||
raise UserError(gettext(
|
||||
'production_output_lot.more_than_one_input_lots'))
|
||||
drag_lot = inputs[0].lot
|
||||
|
||||
for output in self.outputs:
|
||||
if output.lot:
|
||||
continue
|
||||
if output.product.lot_is_required(output.from_location,
|
||||
output.to_location):
|
||||
if output.product.lot_is_required(output.from_location, output.to_location):
|
||||
lot = output.get_production_output_lot()
|
||||
if drag_lot:
|
||||
lot.number = drag_lot.number
|
||||
lot.expiration_date = (drag_lot.expiration_date if
|
||||
drag_lot.expiration_date else None)
|
||||
lot.shelf_life_expiration_date = (
|
||||
drag_lot.shelf_life_expiration_date if
|
||||
drag_lot.shelf_life_expiration_date else None)
|
||||
lot.save()
|
||||
output.lot = lot
|
||||
output.save()
|
||||
|
@ -115,7 +134,6 @@ class Production(metaclass=PoolMeta):
|
|||
class StockMove(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
|
||||
|
||||
def get_production_output_lot(self):
|
||||
pool = Pool()
|
||||
Lot = pool.get('stock.lot')
|
||||
|
@ -128,7 +146,7 @@ class StockMove(metaclass=PoolMeta):
|
|||
lot = Lot(product=self.product, number=number)
|
||||
|
||||
if hasattr(Lot, 'expiration_date'):
|
||||
if self.product.expiry_time:
|
||||
if self.product.expiration_time:
|
||||
input_expiry_dates = [i.lot.expiration_date
|
||||
for i in self.production_output.inputs
|
||||
if i.lot and i.lot.expiration_date]
|
||||
|
|
|
@ -3,9 +3,10 @@ version=5.5.0
|
|||
depends:
|
||||
production
|
||||
stock_lot
|
||||
stock_lot_sequence
|
||||
extras_depend:
|
||||
stock_lot_sled
|
||||
stock_lot_sequence
|
||||
xml:
|
||||
bom.xml
|
||||
production.xml
|
||||
message.xml
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='uom']" position="after">
|
||||
<label name="use_lot"/>
|
||||
<field name="use_lot"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,8 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name='uom']" position="after">
|
||||
<field name="use_lot"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue