Add materials to location. (#8)
Add news validations in stock.move (uom and quantity). Task #046344
This commit is contained in:
parent
a08b385498
commit
d917fabb1f
|
@ -8,6 +8,8 @@ from . import product
|
||||||
from . import weighing
|
from . import weighing
|
||||||
from . import quality
|
from . import quality
|
||||||
from . import production
|
from . import production
|
||||||
|
from . import location
|
||||||
|
from . import move
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
|
@ -52,6 +54,9 @@ def register():
|
||||||
# production.ProductionProductionCostPriceDistribution,
|
# production.ProductionProductionCostPriceDistribution,
|
||||||
production.ProductionCostPriceDistributionTemplate,
|
production.ProductionCostPriceDistributionTemplate,
|
||||||
production.ProductionCostPriceDistributionTemplateProductionTemplateAsk,
|
production.ProductionCostPriceDistributionTemplateProductionTemplateAsk,
|
||||||
|
location.LocationMaterial,
|
||||||
|
location.Location,
|
||||||
|
move.Move,
|
||||||
module='agronomics', type_='model')
|
module='agronomics', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
production.ProductionCostPriceDistributionTemplateProductionTemplate,
|
production.ProductionCostPriceDistributionTemplateProductionTemplate,
|
||||||
|
|
52
locale/ca.po
52
locale/ca.po
|
@ -1051,6 +1051,30 @@ msgctxt "field:quality.quantitative.test.line,product:"
|
||||||
msgid "Product"
|
msgid "Product"
|
||||||
msgstr "Productes"
|
msgstr "Productes"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,material:"
|
||||||
|
msgid "Material"
|
||||||
|
msgstr "Material"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,max_capacity:"
|
||||||
|
msgid "Maximum capacity"
|
||||||
|
msgstr "Capacitat màxima"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,tank:"
|
||||||
|
msgid "Tank"
|
||||||
|
msgstr "Dipòsit"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,unit_digits:"
|
||||||
|
msgid "Unit Digits"
|
||||||
|
msgstr "Dígits de la unitat"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,uom:"
|
||||||
|
msgid "Uom"
|
||||||
|
msgstr "UdM"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location.material,name:"
|
||||||
|
msgid "Name"
|
||||||
|
msgstr "Nom"
|
||||||
|
|
||||||
msgctxt "model:agronomics.beneficiary,name:"
|
msgctxt "model:agronomics.beneficiary,name:"
|
||||||
msgid "Beneficiaries"
|
msgid "Beneficiaries"
|
||||||
msgstr "Beneficiaris"
|
msgstr "Beneficiaris"
|
||||||
|
@ -1195,6 +1219,10 @@ msgctxt "model:ir.action,name:act_production_template_tree"
|
||||||
msgid "Production Template"
|
msgid "Production Template"
|
||||||
msgstr "Plantilla de producció"
|
msgstr "Plantilla de producció"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action,name:act_stock_location_material"
|
||||||
|
msgid "Materials"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:act_weighing_action"
|
msgctxt "model:ir.action,name:act_weighing_action"
|
||||||
msgid "Weighing"
|
msgid "Weighing"
|
||||||
msgstr "Pesada"
|
msgstr "Pesada"
|
||||||
|
@ -1264,6 +1292,22 @@ msgctxt "model:ir.message,text:msg_check_production_percentatge"
|
||||||
msgid "Invalid percentatge \"%(percentatge)s\" in \"%(production)s\"."
|
msgid "Invalid percentatge \"%(percentatge)s\" in \"%(production)s\"."
|
||||||
msgstr "Percentatge \"%(percentatge)s\" no vàlid a \"%(producció)s\"."
|
msgstr "Percentatge \"%(percentatge)s\" no vàlid a \"%(producció)s\"."
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_move_amount_exceed"
|
||||||
|
msgid ""
|
||||||
|
"The move cannot be done because the amount of the move exceeds the set "
|
||||||
|
"maximum amount."
|
||||||
|
msgstr ""
|
||||||
|
"No es pot finalitzar el moviment perquè la quantitat del moviment supera a "
|
||||||
|
"la quantitat màxima de la ubicació destí."
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_move_unit_not_match"
|
||||||
|
msgid ""
|
||||||
|
"The movement cannot be done because the unit of measure of the movement not "
|
||||||
|
"matches the unit of mesure of the capacity in the destination location."
|
||||||
|
msgstr ""
|
||||||
|
"No es pot finalitzar el moviment perquè la unitat de mesura del moviment no "
|
||||||
|
"coincideix amb la unitat de mesura de la capacitat de la ubicació destí."
|
||||||
|
|
||||||
msgctxt "model:ir.message,text:msg_uom_not_fit"
|
msgctxt "model:ir.message,text:msg_uom_not_fit"
|
||||||
msgid ""
|
msgid ""
|
||||||
"Inputs from Production template \"%(production)s\" must be of uom "
|
"Inputs from Production template \"%(production)s\" must be of uom "
|
||||||
|
@ -1385,6 +1429,10 @@ msgctxt "model:ir.ui.menu,name:menu_weighing_list"
|
||||||
msgid "Weighing"
|
msgid "Weighing"
|
||||||
msgstr "Pesada"
|
msgstr "Pesada"
|
||||||
|
|
||||||
|
msgctxt "model:ir.ui.menu,name:menuitem_stock_location_material"
|
||||||
|
msgid "Materials"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "model:product.product-agronomics.crop,name:"
|
msgctxt "model:product.product-agronomics.crop,name:"
|
||||||
msgid "Product - Crop"
|
msgid "Product - Crop"
|
||||||
msgstr "Producte - Collita"
|
msgstr "Producte - Collita"
|
||||||
|
@ -1642,6 +1690,10 @@ msgctxt "model:res.group,name:group_agronomics_admin"
|
||||||
msgid "Agronomics Administration"
|
msgid "Agronomics Administration"
|
||||||
msgstr "Administració Agronomics"
|
msgstr "Administració Agronomics"
|
||||||
|
|
||||||
|
msgctxt "model:stock.location.material,name:"
|
||||||
|
msgid "Location Material"
|
||||||
|
msgstr "Material Ubicació"
|
||||||
|
|
||||||
msgctxt "selection:agronomics.weighing,state:"
|
msgctxt "selection:agronomics.weighing,state:"
|
||||||
msgid "Cancelled"
|
msgid "Cancelled"
|
||||||
msgstr "Cancel·lat"
|
msgstr "Cancel·lat"
|
||||||
|
|
53
locale/es.po
53
locale/es.po
|
@ -1051,6 +1051,30 @@ msgctxt "field:quality.quantitative.test.line,product:"
|
||||||
msgid "Product"
|
msgid "Product"
|
||||||
msgstr "Productos"
|
msgstr "Productos"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,material:"
|
||||||
|
msgid "Material"
|
||||||
|
msgstr "Material"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,max_capacity:"
|
||||||
|
msgid "Maximum capacity"
|
||||||
|
msgstr "Capacidad máxima"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,tank:"
|
||||||
|
msgid "Tank"
|
||||||
|
msgstr "Depósito"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,unit_digits:"
|
||||||
|
msgid "Unit Digits"
|
||||||
|
msgstr "Dígitos unidad"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location,uom:"
|
||||||
|
msgid "Uom"
|
||||||
|
msgstr "UdM"
|
||||||
|
|
||||||
|
msgctxt "field:stock.location.material,name:"
|
||||||
|
msgid "Name"
|
||||||
|
msgstr "Nombre"
|
||||||
|
|
||||||
msgctxt "model:agronomics.beneficiary,name:"
|
msgctxt "model:agronomics.beneficiary,name:"
|
||||||
msgid "Beneficiaries"
|
msgid "Beneficiaries"
|
||||||
msgstr "Beneficiarios"
|
msgstr "Beneficiarios"
|
||||||
|
@ -1195,6 +1219,10 @@ msgctxt "model:ir.action,name:act_production_template_tree"
|
||||||
msgid "Production Template"
|
msgid "Production Template"
|
||||||
msgstr "Plantilla producción"
|
msgstr "Plantilla producción"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action,name:act_stock_location_material"
|
||||||
|
msgid "Materials"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:act_weighing_action"
|
msgctxt "model:ir.action,name:act_weighing_action"
|
||||||
msgid "Weighing"
|
msgid "Weighing"
|
||||||
msgstr "Pesada"
|
msgstr "Pesada"
|
||||||
|
@ -1264,6 +1292,23 @@ msgctxt "model:ir.message,text:msg_check_production_percentatge"
|
||||||
msgid "Invalid percentatge \"%(percentatge)s\" in \"%(production)s\"."
|
msgid "Invalid percentatge \"%(percentatge)s\" in \"%(production)s\"."
|
||||||
msgstr "Porcentaje no válido \"%(porcentaje)s\" en \"% (distribución) s\"."
|
msgstr "Porcentaje no válido \"%(porcentaje)s\" en \"% (distribución) s\"."
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_move_amount_exceed"
|
||||||
|
msgid ""
|
||||||
|
"The move cannot be done because the amount of the move exceeds the set "
|
||||||
|
"maximum amount."
|
||||||
|
msgstr ""
|
||||||
|
"No se puede finalizar el movimiento porque la cantidad del movimiento supera"
|
||||||
|
" la cantidad máxima de la ubicación destino."
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_move_unit_not_match"
|
||||||
|
msgid ""
|
||||||
|
"The movement cannot be done because the unit of measure of the movement not "
|
||||||
|
"matches the unit of mesure of the capacity in the destination location."
|
||||||
|
msgstr ""
|
||||||
|
"No se puede finalizar el movimiento porque la unidad de medida del "
|
||||||
|
"movimiento no coincide con la unidad de medida de capacidad de la de la "
|
||||||
|
"ubicación destino."
|
||||||
|
|
||||||
msgctxt "model:ir.message,text:msg_uom_not_fit"
|
msgctxt "model:ir.message,text:msg_uom_not_fit"
|
||||||
msgid ""
|
msgid ""
|
||||||
"Inputs from Production template \"%(production)s\" must be of uom "
|
"Inputs from Production template \"%(production)s\" must be of uom "
|
||||||
|
@ -1385,6 +1430,10 @@ msgctxt "model:ir.ui.menu,name:menu_weighing_list"
|
||||||
msgid "Weighing"
|
msgid "Weighing"
|
||||||
msgstr "Pesada"
|
msgstr "Pesada"
|
||||||
|
|
||||||
|
msgctxt "model:ir.ui.menu,name:menuitem_stock_location_material"
|
||||||
|
msgid "Materials"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "model:product.product-agronomics.crop,name:"
|
msgctxt "model:product.product-agronomics.crop,name:"
|
||||||
msgid "Product - Crop"
|
msgid "Product - Crop"
|
||||||
msgstr "Producto - Cosecha"
|
msgstr "Producto - Cosecha"
|
||||||
|
@ -1642,6 +1691,10 @@ msgctxt "model:res.group,name:group_agronomics_admin"
|
||||||
msgid "Agronomics Administration"
|
msgid "Agronomics Administration"
|
||||||
msgstr "Agronomics Administración"
|
msgstr "Agronomics Administración"
|
||||||
|
|
||||||
|
msgctxt "model:stock.location.material,name:"
|
||||||
|
msgid "Location Material"
|
||||||
|
msgstr "Material Ubicación"
|
||||||
|
|
||||||
msgctxt "selection:agronomics.weighing,state:"
|
msgctxt "selection:agronomics.weighing,state:"
|
||||||
msgid "Cancelled"
|
msgid "Cancelled"
|
||||||
msgstr "Cancelado"
|
msgstr "Cancelado"
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
# copyright notices and license terms.
|
||||||
|
from trytond.model import fields, ModelSQL, ModelView
|
||||||
|
from trytond.pool import PoolMeta, Pool
|
||||||
|
from trytond.pyson import Eval, Bool
|
||||||
|
|
||||||
|
|
||||||
|
tank_states = {'invisible': ~Bool(Eval('tank'))}
|
||||||
|
tank_depends = ['tank']
|
||||||
|
|
||||||
|
class LocationMaterial(ModelSQL, ModelView):
|
||||||
|
"Location Material"
|
||||||
|
__name__ = 'stock.location.material'
|
||||||
|
|
||||||
|
name = fields.Char("Name", required=True)
|
||||||
|
|
||||||
|
|
||||||
|
class Location(metaclass=PoolMeta):
|
||||||
|
__name__ = 'stock.location'
|
||||||
|
|
||||||
|
tank = fields.Boolean("Tank",
|
||||||
|
states={
|
||||||
|
'invisible': Eval('type') != 'storage',
|
||||||
|
},
|
||||||
|
depends=['type'])
|
||||||
|
material = fields.Selection('get_materials', "Material",
|
||||||
|
states=tank_states, depends=tank_depends)
|
||||||
|
uom = fields.Many2One('product.uom', 'Uom',
|
||||||
|
states=tank_states, depends=tank_depends)
|
||||||
|
unit_digits = fields.Function(fields.Integer("Unit Digits",
|
||||||
|
states=tank_states, depends=tank_depends),
|
||||||
|
'on_change_with_unit_digits')
|
||||||
|
max_capacity = fields.Float("Maximum capacity",
|
||||||
|
digits=(16, Eval('unit_digits', 2)),
|
||||||
|
states=tank_states, depends=['unit_digits', 'tank'])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_materials(field_name):
|
||||||
|
pool = Pool()
|
||||||
|
LocationMaterial = pool.get('stock.location.material')
|
||||||
|
materials = [(None, "")]
|
||||||
|
for material in LocationMaterial.search([]):
|
||||||
|
materials.append((material.name, material.name))
|
||||||
|
return materials
|
||||||
|
|
||||||
|
@fields.depends('uom')
|
||||||
|
def on_change_with_unit_digits(self, name=None):
|
||||||
|
if self.uom:
|
||||||
|
return self.uom.digits
|
||||||
|
return 2
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?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>
|
||||||
|
<!-- stock.location.material -->
|
||||||
|
<record model="ir.ui.view" id="stock_location_material_view_form">
|
||||||
|
<field name="model">stock.location.material</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">material_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="stock_location_material_view_tree">
|
||||||
|
<field name="model">stock.location.material</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="name">material_tree</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.act_window" id="act_stock_location_material">
|
||||||
|
<field name="name">Materials</field>
|
||||||
|
<field name="res_model">stock.location.material</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_stock_location_material_view1">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="stock_location_material_view_tree"/>
|
||||||
|
<field name="act_window" ref="act_stock_location_material"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_stock_location_material_view2">
|
||||||
|
<field name="sequence" eval="20"/>
|
||||||
|
<field name="view" ref="stock_location_material_view_form"/>
|
||||||
|
<field name="act_window" ref="act_stock_location_material"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem parent="stock.menu_configuration" action="act_stock_location_material"
|
||||||
|
id="menuitem_stock_location_material" sequence="10"/>
|
||||||
|
|
||||||
|
<!-- stock.location -->
|
||||||
|
<record model="ir.ui.view" id="location_view_form">
|
||||||
|
<field name="model">stock.location</field>
|
||||||
|
<field name="inherit" ref="stock.location_view_form"/>
|
||||||
|
<field name="name">location_form</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -30,7 +30,12 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<record model="ir.message" id="msg_check_cost_templates">
|
<record model="ir.message" id="msg_check_cost_templates">
|
||||||
<field name="text">Cost "%(cost)s" has template "%(template)s" not present in Production Template Outputs".</field>
|
<field name="text">Cost "%(cost)s" has template "%(template)s" not present in Production Template Outputs".</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.message" id="msg_move_unit_not_match">
|
||||||
|
<field name="text">The movement cannot be done because the unit of measure of the movement not matches the unit of mesure of the capacity in the destination location.</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.message" id="msg_move_amount_exceed">
|
||||||
|
<field name="text">The move cannot be done because the amount of the move exceeds the set maximum amount.</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
# copyright notices and license terms.
|
||||||
|
from trytond.pool import PoolMeta, Pool
|
||||||
|
from trytond.i18n import gettext
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
|
||||||
|
class Move(metaclass=PoolMeta):
|
||||||
|
__name__ = 'stock.move'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def validate(cls, moves):
|
||||||
|
pool = Pool()
|
||||||
|
Product = pool.get('product.product')
|
||||||
|
super(Move, cls).validate(moves)
|
||||||
|
for move in moves:
|
||||||
|
if move.to_location.tank:
|
||||||
|
#Same unit move and to location
|
||||||
|
if move.uom != move.to_location.uom:
|
||||||
|
raise UserError(gettext(
|
||||||
|
'agronomics.msg_move_unit_not_match'))
|
||||||
|
#Do not exceed the amount
|
||||||
|
context = Transaction().context
|
||||||
|
with Transaction().set_context(context):
|
||||||
|
location_quantity = sum(Product.products_by_location(
|
||||||
|
[move.to_location.id]).values())
|
||||||
|
if (location_quantity > move.to_location.max_capacity):
|
||||||
|
raise UserError(gettext(
|
||||||
|
'agronomics.msg_move_amount_exceed'))
|
|
@ -10,6 +10,7 @@ depends:
|
||||||
quality_control
|
quality_control
|
||||||
purchase_contract
|
purchase_contract
|
||||||
production
|
production
|
||||||
|
stock
|
||||||
xml:
|
xml:
|
||||||
plot.xml
|
plot.xml
|
||||||
party.xml
|
party.xml
|
||||||
|
@ -18,4 +19,5 @@ xml:
|
||||||
wine.xml
|
wine.xml
|
||||||
message.xml
|
message.xml
|
||||||
production.xml
|
production.xml
|
||||||
quality.xml
|
location.xml
|
||||||
|
quality.xml
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?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='flat_childs']" position="after">
|
||||||
|
<label name="tank"/>
|
||||||
|
<field name="tank"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="/form/field[@name='childs']" position="before">
|
||||||
|
<label name="material"/>
|
||||||
|
<field name="material"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="max_capacity"/>
|
||||||
|
<field name="max_capacity"/>
|
||||||
|
<label name="uom"/>
|
||||||
|
<field name="uom"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?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. -->
|
||||||
|
<form>
|
||||||
|
<label name="name"/>
|
||||||
|
<field name="name"/>
|
||||||
|
</form>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?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. -->
|
||||||
|
<tree>
|
||||||
|
<field name="name"/>
|
||||||
|
</tree>
|
Loading…
Reference in New Issue