[MERGE] master-wmsstaging-jco with fixes on WMS + new barcode reports

This commit is contained in:
qdp-odoo 2014-05-30 18:09:05 +02:00
commit 52b799d8d0
14 changed files with 172 additions and 35 deletions

View File

@ -27,6 +27,8 @@ import openerp.addons.decimal_precision as dp
from openerp.tools.translate import _
import openerp
PROCUREMENT_PRIORITIES = [('0', 'Not urgent'), ('1', 'Normal'), ('2', 'Urgent'), ('3', 'Very Urgent')]
class procurement_group(osv.osv):
'''
The procurement group class is used to group products together
@ -113,7 +115,7 @@ class procurement_order(osv.osv):
'company_id': fields.many2one('res.company', 'Company', required=True),
# These two fields are used for shceduling
'priority': fields.selection([('0', 'Not urgent'), ('1', 'Normal'), ('2', 'Urgent'), ('3', 'Very Urgent')], 'Priority', required=True, select=True, track_visibility='onchange'),
'priority': fields.selection(PROCUREMENT_PRIORITIES, 'Priority', required=True, select=True, track_visibility='onchange'),
'date_planned': fields.datetime('Scheduled Date', required=True, select=True, track_visibility='onchange'),
'group_id': fields.many2one('procurement.group', 'Procurement Group'),

View File

@ -84,7 +84,9 @@ Dashboard / Reports for Warehouse Management will include:
'report/report_stock_view.xml',
'res_config_view.xml',
'views/report_package_barcode.xml',
'views/report_stockpicking.xml',
'views/report_lot_barcode.xml',
'views/report_location_barcode.xml',
'views/report_stockpicking.xml',
'views/report_stockinventory.xml',
'views/stock.xml',
],

View File

@ -188,6 +188,7 @@ class procurement_order(osv.osv):
'date': newdate,
'date_expected': newdate,
'propagate': procurement.rule_id.propagate,
'priority': procurement.priority,
}
return vals
@ -288,7 +289,7 @@ class procurement_order(osv.osv):
self._procure_orderpoint_confirm(cr, SUPERUSER_ID, use_new_cursor=False, company_id=company.id, context=context)
#Search all confirmed stock_moves and try to assign them
confirmed_ids = move_obj.search(cr, uid, [('state', '=', 'confirmed')], limit=None, order='picking_priority desc, date_expected asc', context=context)
confirmed_ids = move_obj.search(cr, uid, [('state', '=', 'confirmed')], limit=None, order='priority desc, date_expected asc', context=context)
for x in xrange(0, len(confirmed_ids), 100):
move_obj.action_assign(cr, uid, confirmed_ids[x:x + 100], context=context)
if use_new_cursor:

View File

@ -168,9 +168,16 @@ class product_product(osv.osv):
res.append(('id', 'in', ids))
return res
def _product_available_text(self, cr, uid, ids, field_names=None, arg=False, context=None):
res = {}
for product in self.browse(cr, uid, ids, context=context):
res[product.id] = str(product.qty_available) + _(" In Stock")
return res
_columns = {
'reception_count': fields.function(_stock_move_count, string="Reception", type='integer', multi='pickings'),
'delivery_count': fields.function(_stock_move_count, string="Delivery", type='integer', multi='pickings'),
'qty_in_stock': fields.function(_product_available_text, type='char'),
'qty_available': fields.function(_product_available, multi='qty_available',
type='float', digits_compute=dp.get_precision('Product Unit of Measure'),
string='Quantity On Hand',

View File

@ -200,12 +200,17 @@
</group>
</group>
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" string="Current Stock" name="%(product_open_quants)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_locations" icon="fa-bank"/>
<button class="oe_inline oe_stat_button" string="Moves" name= "%(act_product_stock_move_open)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_stock_user" icon="fa-arrows-h"/>
<button class="oe_stat_button"
name="%(product_open_quants)d"
icon="fa-bank"
type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_locations">
<div><field name="qty_in_stock"/></div>
</button>
<button class="oe_inline oe_stat_button" string="Moves" name= "%(act_product_stock_move_open)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_stock_user" icon="fa-arrows-v"/>
<button class="oe_inline oe_stat_button" name="%(product_open_orderpoint)d" type="action"
attrs="{'invisible':[('type', '=', 'service')]}" icon="fa-pinterest" string="Reordering Rules"/>
</xpath>
</field>
</record>
</data>
</openerp>
</openerp>

View File

@ -49,6 +49,15 @@
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
<record model="ir.rule" id="stock_picking_rule">
<field name="name">Stock Picking Type multi-company</field>
<field name="model_id" search="[('model','=','stock.picking.type')]" model="ir.model"/>
<field name="global" eval="True"/>
<field name="domain_force">['|', ('warehouse_id', '=', False), '|',('warehouse_id.company_id','=',False),('warehouse_id.company_id','child_of',[user.company_id.id])]</field>
</record>
<record model="ir.rule" id="stock_warehouse_comp_rule">
<field name="name">Warehouse multi-company</field>

View File

@ -29,6 +29,7 @@ from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
from openerp import SUPERUSER_ID
import openerp.addons.decimal_precision as dp
from openerp.addons.procurement import procurement
import logging
@ -622,6 +623,12 @@ class stock_picking(osv.osv):
move_ids = [move.id for move in self.browse(cr, uid, id, context=context).move_lines]
move_obj.write(cr, uid, move_ids, {'date_expected': value}, context=context)
def _set_priority(self, cr, uid, id, field, value, arg, context=None):
move_obj = self.pool.get("stock.move")
if value:
move_ids = [move.id for move in self.browse(cr, uid, id, context=context).move_lines]
move_obj.write(cr, uid, move_ids, {'priority': value}, context=context)
def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None):
""" Finds minimum and maximum dates for picking.
@return: Dictionary of values
@ -634,16 +641,18 @@ class stock_picking(osv.osv):
cr.execute("""select
picking_id,
min(date_expected),
max(date_expected)
max(date_expected),
max(priority)
from
stock_move
where
picking_id IN %s
group by
picking_id""", (tuple(ids),))
for pick, dt1, dt2 in cr.fetchall():
for pick, dt1, dt2, prio in cr.fetchall():
res[pick]['min_date'] = dt1
res[pick]['max_date'] = dt2
res[pick]['priority'] = prio
return res
def create(self, cr, user, vals, context=None):
@ -759,7 +768,9 @@ class stock_picking(osv.osv):
* Transferred: has been processed, can't be modified or cancelled anymore\n
* Cancelled: has been cancelled, can't be confirmed anymore"""
),
'priority': fields.selection([('0', 'Low'), ('1', 'Normal'), ('2', 'High')], states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, string='Priority', required=True),
'priority': fields.function(get_min_max_date, multi="min_max_date", fnct_inv=_set_priority, type='selection', selection=procurement.PROCUREMENT_PRIORITIES, string='Priority',
store={'stock.move': (_get_pickings, ['priority'], 20)}, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, select=1, help="Priority for this picking. Setting manually a value here would set it as priority for all the moves",
track_visibility='onchange', required=True),
'min_date': fields.function(get_min_max_date, multi="min_max_date", fnct_inv=_set_min_date,
store={'stock.move': (_get_pickings, ['date_expected'], 20)}, type='datetime', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, string='Scheduled Date', select=1, help="Scheduled time for the first part of the shipment to be processed. Setting manually a value here would set it as expected date for all the stock moves.", track_visibility='onchange'),
'max_date': fields.function(get_min_max_date, multi="min_max_date",
@ -1591,7 +1602,7 @@ class stock_move(osv.osv):
_columns = {
'name': fields.char('Description', required=True, select=True),
'priority': fields.selection([('0', 'Not urgent'), ('1', 'Urgent')], 'Priority'),
'priority': fields.selection(procurement.PROCUREMENT_PRIORITIES, 'Priority'),
'create_date': fields.datetime('Creation Date', readonly=True, select=True),
'date': fields.datetime('Date', required=True, select=True, help="Move date: scheduled date until move is done, then date of actual move processing", states={'done': [('readonly', True)]}),
'date_expected': fields.datetime('Expected Date', states={'done': [('readonly', True)]}, required=True, select=True, help="Scheduled date for the processing of this move"),
@ -1628,7 +1639,6 @@ class stock_move(osv.osv):
'move_orig_ids': fields.one2many('stock.move', 'move_dest_id', 'Original Move', help="Optional: previous stock move when chaining them", select=True),
'picking_id': fields.many2one('stock.picking', 'Reference', select=True, states={'done': [('readonly', True)]}),
'picking_priority': fields.related('picking_id', 'priority', type='selection', selection=[('0', 'Low'), ('1', 'Normal'), ('2', 'High')], string='Picking Priority', store={'stock.picking': (_get_move_ids, ['priority'], 10)}),
'note': fields.text('Notes'),
'state': fields.selection([('draft', 'New'),
('cancel', 'Cancelled'),
@ -1774,6 +1784,7 @@ class stock_move(osv.osv):
'group_id': group_id,
'route_ids': [(4, x.id) for x in move.route_ids],
'warehouse_id': move.warehouse_id and move.warehouse_id.id or False,
'priority': move.priority,
}
def _push_apply(self, cr, uid, moves, context=None):
@ -1981,7 +1992,7 @@ class stock_move(osv.osv):
values = {
'origin': move.origin,
'company_id': move.company_id and move.company_id.id or False,
'move_type': move.group_id and move.group_id.move_type or 'one',
'move_type': move.group_id and move.group_id.move_type or 'direct',
'partner_id': move.partner_id.id or False,
'picking_type_id': move.picking_type_id and move.picking_type_id.id or False,
}
@ -2743,7 +2754,7 @@ class stock_warehouse(osv.osv):
_columns = {
'name': fields.char('Warehouse Name', size=128, required=True, select=True),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, select=True),
'partner_id': fields.many2one('res.partner', 'Address'),
'view_location_id': fields.many2one('stock.location', 'View Location', required=True, domain=[('usage', '=', 'view')]),
'lot_stock_id': fields.many2one('stock.location', 'Location Stock', required=True, domain=[('usage', '=', 'internal')]),
@ -3615,19 +3626,11 @@ class stock_package(osv.osv):
return True
def action_print(self, cr, uid, ids, context=None):
if context is None:
context = {}
datas = {
'ids': context.get('active_id') and [context.get('active_id')] or ids,
'model': 'stock.quant.package',
'form': self.read(cr, uid, ids)[0]
}
return {
'type': 'ir.actions.report.xml',
'report_name': 'stock.quant.package.barcode',
'datas': datas
}
context = context or {}
context['active_ids'] = ids
return self.pool.get("report").get_action(cr, uid, ids, 'stock.report_package_barcode', context=context)
def unpack(self, cr, uid, ids, context=None):
quant_obj = self.pool.get('stock.quant')
for package in self.browse(cr, uid, ids, context=context):

View File

@ -20,6 +20,7 @@
/>
<report auto="False" id="report_product_history" model="product.product" name="stock.product.history" string="Stock Level Forecast"/>
<report id="action_report_quant_package_barcode" model="stock.quant.package" report_type="qweb-pdf" name="stock.report_package_barcode" string="Package BarCode" file="stock.report_package_barcode"/>
<report id="action_report_location_barcode" model="stock.location" report_type="qweb-pdf" name="stock.report_location_barcode" string="Location BarCode" file="stock.report_location_barcode"/>
<report id="action_report_lot_barcode" model="stock.production.lot" report_type="qweb-pdf" name="stock.report_lot_barcode" string="Lot BarCode" file="stock.report_lot_barcode"/>
</data>
</openerp>

View File

@ -365,7 +365,10 @@
<field name="arch" type="xml">
<form string="Stock Location" version="7.0">
<div class="oe_right oe_button_box" name="buttons">
<button string="Current Stock" name="%(location_open_quants)d" type="action"/>
<button string="Current Stock"
class="oe_stat_button"
icon="fa-building-o" name="%(location_open_quants)d" type="action"
context="{'search_default_internal_loc': 1}"/>
</div>
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
@ -560,7 +563,11 @@
<form string="Warehouse" version="7.0">
<sheet>
<div class="oe_right oe_button_box">
<button name="view_all_routes_for_wh" string="View Warehouse Routes" type="object"/>
<button name="view_all_routes_for_wh"
string="Routes"
icon="fa-refresh"
class="oe_stat_button"
type="object"/>
</div>
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
@ -744,6 +751,21 @@
<field name="pack_operation_exist" invisible="1"/>
<field name="note" placeholder="Add an internal note..." class="oe_inline"/>
</page>
<page string="Operations Done" attrs="{'invisible': ['|', ('state','!=','done'), ('pack_operation_ids','=',[])]}">
<field name="pack_operation_ids">
<tree editable="top">
<field name="location_id"/>
<field name="product_id"/>
<field name="product_uom_id" groups="product.group_uom"/>
<field name="lot_id" domain="[('product_id','=?', product_id)]" context="{'product_id': product_id}" groups="stock.group_production_lot"/>
<field name="package_id" groups="stock.group_tracking_lot"/>
<field name="owner_id" groups="stock.group_tracking_owner"/>
<field name="product_qty" attrs="{'required': [('product_id', '!=', False)]}"/>
<field name="location_dest_id"/>
<field name="result_package_id" groups="stock.group_tracking_lot"/>
</tree>
</field>
</page>
<page string="Additional Info">
<group string="General Informations">
<group>
@ -1058,7 +1080,7 @@
</group>
<group name="main_grp_col2">
<field name="picking_type_id"/>
<field name="picking_priority"/>
<field name="priority"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="date_expected" on_change="onchange_date(date,date_expected)" attrs="{'invisible': [('state', '=', 'done')]}"/>
<field name="date" attrs="{'invisible': [('state', '!=', 'done')]}"/>
@ -1769,7 +1791,7 @@
<field name="res_model">stock.warehouse.orderpoint</field>
</record>
<record model="ir.actions.act_window" id="product_open_quants">
<field name="context">{'search_default_product_id': active_id, 'search_default_locationgroup':1}</field>
<field name="context">{'search_default_internal_loc': 1, 'search_default_product_id': active_id, 'search_default_locationgroup':1}</field>
<field name="name">Quants</field>
<field name="res_model">stock.quant</field>
</record>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_location_barcode">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t>
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-4">
<img class="image" t-att-src="'data:image/png;base64,%s' % res_company.logo" style="border:auto;"/>
</div>
</div>
<div class="row">
<div class="col-xs-6 mt6">
<table class="table table-condensed" style="border-bottom: 3px solid black !important;"><thead><th> </th></thead></table>
<img t-if="not o.loc_barcode" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)" style="width:300px;height:50px"/>
<img t-if="o.loc_barcode" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.loc_barcode, 600, 100)" style="width:300px;height:50px"/>
<p class="text-center" t-if="not o.loc_barcode" t-field="o.name"></p>
<p class="text-center" t-if="o.loc_barcode" t-field="o.loc_barcode"></p>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_lot_barcode">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t>
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-8">
<table class="table table-condensed" style="border-bottom: 0px solid white !important;">
<thead>
<tr>
<th>Product</th>
<th>Lot</th>
</tr>
</thead>
<tbody>
<td>
<span t-field="o.product_id.name"/>
</td>
<td>
<span t-field="o.name"/>
</td>
</tbody>
</table>
</div>
<div class="col-xs-4">
<img class="image" t-att-src="'data:image/png;base64,%s' % res_company.logo" style="border:auto;"/>
</div>
</div>
<div class="row">
<div class="col-xs-12 mt32">
<table class="table table-condensed" style="border-bottom: 3px solid black !important;"><thead><th> </th></thead></table>
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)" style="width:300px;height:50px"/>
<p class="text-center" t-field="o.name"></p>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>

View File

@ -40,7 +40,7 @@
<div class="row">
<div class="col-xs-12 mt32">
<table class="table table-condensed" style="border-bottom: 3px solid black !important;"><thead><th> </th></thead></table>
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Standard39', o.name, 800, 40)" style="width:100%;"/>
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)" style="width:300px;height:50px"/>
<p class="text-center" t-field="o.name"></p>
</div>
</div>

View File

@ -7,7 +7,7 @@
<t t-call="report.external_layout">
<div class="page">
<div class="row"><div class="col-xs-4 pull-right">
<img t-att-src="'/report/barcode/Standard39/%s' % o.name"/>
<img t-att-src="'/report/barcode/Code128/%s' % o.name"/>
</div></div>
<div t-if="o.picking_type_id.code=='incoming'">
<span><strong>Supplier Address:</strong></span>
@ -104,13 +104,13 @@
</t>
<td>
<span t-if="pack_operation.lot_id">
<img t-att-src="'/report/barcode/Standard39/%s' % pack_operation.lot_id.name"/>
<img t-att-src="'/report/barcode/Code128/%s' % pack_operation.lot_id.name"/>
</span>
<span t-if="pack_operation.product_id and not pack_operation.lot_id and pack_operation.product_id.ean13">
<img t-att-src="'/report/barcode/EAN13/%s' % pack_operation.product_id.ean13"/>
</span>
<span t-if="pack_operation.package_id and not pack_operation.product_id">
<img t-att-src="'/report/barcode/Standard39/%s' % pack_operation.package_id.name"/>
<img t-att-src="'/report/barcode/Code128/%s' % pack_operation.package_id.name"/>
</span>
</td>
<t t-if="o.picking_type_id.code != 'outgoing'"><td><span t-field="pack_operation.location_dest_id"/>

View File

@ -8,6 +8,15 @@
<field name="name">Manage Inventory Valuation and Costing Methods</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record model="ir.rule" id="stock_history_rule">
<field name="name">Stock History multi-company</field>
<field name="model_id" search="[('model','=','stock.history')]" model="ir.model"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
</data>
</openerp>