Implement carrier loading reports.

This commit refs #850
This commit is contained in:
Sergio Morillo 2015-11-30 13:42:21 +01:00
parent 10f165996e
commit 789e4f4f9c
8 changed files with 52 additions and 16 deletions

View File

@ -4,7 +4,7 @@ from trytond.pool import Pool
from .load import (Load, LoadOrder, LoadOrderLine,
LoadUnitLoad, LoadUnitLoadOrder,
LoadUnitLoadData, Configuration)
LoadUnitLoadData, Configuration, LoadSheet, CMR)
from .unit_load import UnitLoad
@ -21,3 +21,7 @@ def register():
Pool.register(
LoadUnitLoad,
module='carrier_load_ul', type_='wizard')
Pool.register(
LoadSheet,
CMR,
module='carrier_load_ul', type_='report')

36
load.py
View File

@ -9,7 +9,8 @@ from trytond.wizard import Wizard, StateTransition, StateView, Button
__metaclass__ = PoolMeta
__all__ = ['Configuration', 'Load', 'LoadOrder', 'LoadOrderLine',
'LoadUnitLoad', 'LoadUnitLoadOrder', 'LoadUnitLoadData']
'LoadUnitLoad', 'LoadUnitLoadOrder', 'LoadUnitLoadData',
'LoadSheet', 'CMR']
class Configuration:
@ -398,3 +399,36 @@ class LoadUnitLoad(Wizard):
self.raise_user_error('unload_any')
UnitLoad.unload(list(self.data.uls_loaded))
return 'data'
class LoadSheet:
__name__ = 'carrier.load.sheet'
@classmethod
def get_context(cls, records, data):
report_context = super(LoadSheet, cls).get_context(records, data)
report_context['product_ul_quantity'] = lambda order, product: \
cls.product_ul_quantity(order, product)
return report_context
@classmethod
def _get_products(cls, order):
return list(set([ul.product for ul in order.unit_loads]))
@classmethod
def product_ul_quantity(cls, order, product):
"""Returns product UL quantity in load order"""
value = 0
for line in order.lines:
value += sum(1 for ul in line.unit_loads if ul.product.id == product.id) or 0
return value
class CMR:
__name__ = 'carrier.load.order.cmr'
@classmethod
def _get_products(cls, order):
return list(set([ul.product for ul in order.unit_loads]))

View File

@ -78,5 +78,9 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- Load report -->
<record model="ir.action.report" id="carrier_load.report_load_sheet">
<field name="report">carrier_load_ul/load_sheet.odt</field>
</record>
</data>
</tryton>

BIN
load_sheet.odt Normal file

Binary file not shown.

View File

@ -206,4 +206,8 @@ msgstr "Unidades de carga"
msgctxt "view:stock.unit_load:"
msgid "Unload"
msgstr "Descargar"
msgstr "Descargar"
msgctxt "odt:carrier.load.sheet:"
msgid "ULs"
msgstr "UdCs"

View File

@ -45,16 +45,6 @@ class UnitLoad:
def search_load_order(cls, name, clause):
return [('load_line.order', ) + tuple(clause[1:])]
@classmethod
def _get_attribute_fields(cls, view_type, view_id):
pool = Pool()
Modeldata = pool.get('ir.model.data')
qty_view_id = Modeldata.get_id('carrier_load_ul', 'unit_load_view_tree')
if view_id == qty_view_id:
return None
return super(UnitLoad, cls)._get_attribute_fields(view_type, view_id)
@classmethod
@ModelView.button
def unload(cls, records):

View File

@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<!-- Unit load view with buttons -->
<record model="ir.ui.view" id="unit_load_view_tree">
<record model="ir.ui.view" id="unit_load_view_unload_tree">
<field name="model">stock.unit_load</field>
<field name="type">tree</field>
<field name="name">unit_load_list</field>

View File

@ -8,8 +8,8 @@ this repository contains the full copyright notices and license terms. -->
</xpath>
<xpath expr="/form/notebook" position="inside">
<page id="uls" string="ULs">
<field name="unit_loads" colspan="4"
view_ids="carrier_load_ul.unit_load_view_tree,stock_unit_load.unit_load_view_form"/>
<field name="unit_loads" colspan="4" mode="tree"
view_ids="carrier_load_ul.unit_load_view_unload_tree"/>
</page>
<page id="moves" string="Moves">
<field name="inventory_moves" colspan="4"/>