[REV] revert of revision 6771 related to split of receptions/deliveries concepts. (will be back...)

bzr revid: qdp-launchpad@openerp.com-20120503102910-om8k1a06h1kosm1l
This commit is contained in:
Quentin (OpenERP) 2012-05-03 12:29:10 +02:00
parent e58dd0966e
commit 5db299411d
13 changed files with 134 additions and 332 deletions

View File

@ -442,9 +442,9 @@ class purchase_order(osv.osv):
'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),
'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
'date': order.date_order,
'type': 'in',
'partner_id': order.dest_address_id.id or order.partner_id.id,
'invoice_state': '2binvoiced' if order.invoice_method == 'picking' else 'none',
'type': 'in',
'purchase_id': order.id,
'company_id': order.company_id.id,
'move_lines' : [],

View File

@ -19,7 +19,7 @@
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<field name="auto_picking" position="after">
<field name="purchase_id" invisible="1"/>
<field name="purchase_id"/>
</field>
</field>
</record>
@ -30,7 +30,7 @@
name="Receptions"
res_model="stock.picking"
src_model="purchase.order"
context="{'default_purchase_id': active_id, 'contact_display': 'partner', 'default_type': 'in'}" />
context="{'default_purchase_id': active_id, 'contact_display': 'partner'}" />
<record id="action_picking_in_tree_view" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
@ -51,9 +51,9 @@
<field name="type">form</field>
<field name="inherit_id" ref="stock.view_picking_in_form"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='date']" position="before">
<field name="backorder_id" position="after">
<field name="purchase_id"/>
</xpath>
</field>
</field>
</record>
@ -67,8 +67,8 @@
<group col="8" colspan="4">
<filter icon="terp-check" name="available" string="Available"
domain="[('state','=','assigned')]" help="Incoming Shipments Available"/>
<filter icon="terp-dialog-close" name="done" string="Received"
domain="[('state','=','done')]" help="Incoming Shipments already Received"/>
<filter icon="terp-dialog-close" name="done" string="Done"
domain="[('state','=','done')]" help="Incoming Shipments already processed"/>
<separator orientation="vertical"/>
<filter icon="terp-accessories-archiver-minus" string="Back Orders"
domain="[('backorder_id', '!=', False)]" help="Is a Back Order"/>
@ -89,7 +89,7 @@
<separator orientation="vertical"/>
<filter string="Order Date" icon="terp-go-month"
domain="[]" context="{'group_by':'date'}"/>
<filter string="Scheduled Date" icon="terp-go-month"
<filter string="Expected Date" icon="terp-go-month"
domain="[]" context="{'group_by':'min_date'}"/>
<separator orientation="vertical"/>
<filter string="Journal" icon="terp-folder-orange"
@ -111,19 +111,6 @@
<field name="help">If you set the Invoicing Control on a purchase order as "Based on receptions", you can track here all the product receptions and create invoices for those receptions.</field>
</record>
<record id="action_picking_in_tree_view1" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="stock.view_picking_in_tree"/>
<field name="act_window_id" ref="action_picking_tree4_picking_to_invoice"/>
</record>
<record id="action_picking_in_form_view1" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="stock.view_picking_in_form"/>
<field name="act_window_id" ref="action_picking_tree4_picking_to_invoice"/>
</record>
<menuitem action="action_picking_tree4_picking_to_invoice"
id="menu_action_picking_tree4_picking_to_invoice"
parent="purchase.menu_procurement_management_invoice" sequence="90"/>

View File

@ -246,21 +246,8 @@
<page string="History">
<separator colspan="4" string="Invoices"/>
<field colspan="4" name="invoice_ids" nolabel="1" context="{'form_view_ref':'account.invoice_form'}"/>
<separator colspan="4" string="Delivery Orders"/>
<field colspan="4" name="picking_ids" nolabel="1" context="{'form_view_ref':'stock.view_picking_out_form', 'default_type': 'out'}">
<tree colors="blue:state == 'draft';grey:state == 'cancel';red:state not in ('cancel', 'done') and min_date &lt; current_date" string="Delivery Orders">
<field name="name"/>
<field name="partner_id"/>
<field name="origin"/>
<field name="date"/>
<field name="min_date"/>
<field name="backorder_id"/>
<field name="invoice_state"/>
<field name="stock_journal_id" widget="selection"/>
<field name="state"/>
<button name="action_process" states="assigned" string="Deliver" type="object" icon="gtk-go-forward" context="{'default_type': 'out'}"/>
</tree>
</field>
<separator colspan="4" string="Packings"/>
<field colspan="4" name="picking_ids" nolabel="1"/>
</page>
</notebook>
</sheet>

View File

@ -72,8 +72,8 @@ Thanks to the double entry management, the inventory controlling is powerful and
'wizard/stock_return_picking_view.xml',
"stock_workflow.xml",
"stock_incoterms.xml",
"stock_report.xml",
"stock_view.xml",
"stock_report.xml",
"stock_sequence.xml",
"product_data.xml",
"product_view.xml",

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<document filename="Packing List.pdf">
<template pageSize="(595.0,842.0)" title="Packing List" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
<template title="Packing List" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="0.0" y1="57.0" width="538" height="728"/>
</pageTemplate>
@ -31,6 +31,7 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="4,0" stop="4,-1"/>
@ -51,12 +52,14 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="4,0" stop="4,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="4,0" stop="4,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="4,0" stop="4,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="4,-1" stop="4,-1"/>
</blockTableStyle>
<blockTableStyle id="Move_Line_Header">
<blockAlignment value="LEFT"/>
@ -158,9 +161,7 @@
<blockTable colWidths="269.0,269.0" style="Table_Address_detail">
<tr>
<td>
<para style="terp_default_Bold_9">Supplier Address : [[ (picking.type == 'in' or removeParentNode('para')) and '' ]]</para>
<para style="terp_default_Bold_9">Customer Address : [[ (picking.type == 'out' or removeParentNode('para')) and '' ]]</para>
<para style="terp_default_Bold_9">Warehouse Address : [[ (picking.type == 'internal' or removeParentNode('para')) and '' ]]</para>
<para style="terp_default_Bold_9">Shipping Address :</para>
<para style="terp_default_9">[[ (picking.partner_id and picking.partner_id.id and picking.partner_id.title.name) or '' ]] [[ picking.partner_id and picking.partner_id.id and picking.partner_id.name ]]</para>
<para style="terp_default_9">[[ picking.partner_id and display_address(picking.partner_id,'delivery') ]]</para>
</td>
@ -180,16 +181,16 @@
<blockTable colWidths="538.0" style="Table_Title_String">
<tr>
<td>
<para style="terp_header">Delivery Order : [[ (picking.type == 'out' or removeParentNode('para')) and '' ]] [[ picking.name ]]</para>
<para style="terp_header">Incoming Shipment : [[ (picking.type == 'in' or removeParentNode('para')) and '' ]] [[ picking.name ]]</para>
<para style="terp_header">Internal Shipment : [[ (picking.type == 'internal' or removeParentNode('para')) and '' ]] [[ picking.name ]]</para>
<para style="terp_header">Packing List: [[ (picking.type == 'out' or removeParentNode('para')) and '' ]] [[ picking.name ]] </para>
<para style="terp_header">Reception: [[ (picking.type == 'in' or removeParentNode('para')) and '' ]] [[ picking.name ]]</para>
<para style="terp_header">Picking List: [[ (picking.type == 'internal' or removeParentNode('para')) and '' ]] [[ picking.name ]]</para>
</td>
</tr>
</blockTable>
<para style="terp_default_5cm_Above_Space">
<font color="white"> </font>
</para>
<blockTable colWidths="100.0,100.0,108.0,107.0,109.0" style="Header_Order_Reference_Tbl">
<blockTable colWidths="100.0,110.0,130.0,120.0,60.0" style="Header_Order_Reference_Tbl">
<tr>
<td>
<para style="terp_tblheader_General_Centre">Journal</para>
@ -208,7 +209,7 @@
</td>
</tr>
</blockTable>
<blockTable colWidths="100.0,100.0,108.0,107.0,109.0" style="Content_Order_Reference_Table">
<blockTable colWidths="100.0,110.0,130.0,120.0,60.0" style="Content_Order_Reference_Table">
<tr>
<td>
<para style="terp_default_Centre_8">[[ picking.stock_journal_id.name]]</para>
@ -239,7 +240,7 @@
<para style="terp_tblheader_Details_Centre">Lot</para>
</td>
<td>
<para style="terp_tblheader_Details_Centre">State</para>
<para style="terp_tblheader_Details">State</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Location</para>

View File

@ -38,7 +38,7 @@ class report_stock_move(osv.osv):
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'company_id':fields.many2one('res.company', 'Company', readonly=True),
'picking_id':fields.many2one('stock.picking', 'Shipment', readonly=True),
'picking_id':fields.many2one('stock.picking', 'Packing', readonly=True),
'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal'), ('other', 'Others')], 'Shipping Type', required=True, select=True, help="Shipping type specify, goods coming in or going out."),
'location_id': fields.many2one('stock.location', 'Source Location', readonly=True, select=True, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."),
'location_dest_id': fields.many2one('stock.location', 'Dest. Location', readonly=True, select=True, help="Location where the system will stock the finished products."),

View File

@ -117,7 +117,7 @@
<filter name="group_categ_id" string="Product Category" icon="terp-stock_symbol-selection" context="{'group_by':'categ_id'}"/>
<filter name="group_product" string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<separator orientation="vertical"/>
<filter name="group_picking" string="Shipment" icon="terp-accessories-archiver" context="{'group_by':'picking_id'}"/>
<filter name="group_picking" string="Packing" icon="terp-accessories-archiver" context="{'group_by':'picking_id'}"/>
<separator orientation="vertical"/>
<filter string="Source Location" name="src_location" icon="terp-gtk-jump-to-rtl" context="{'group_by':'location_id'}"/>
<filter string="Dest. Location" name="dest_location" icon="terp-gtk-jump-to-ltr" context="{'group_by':'location_dest_id'}"/>

View File

@ -19,7 +19,6 @@
#
##############################################################################
from lxml import etree
from datetime import datetime
from dateutil.relativedelta import relativedelta
import time
@ -535,14 +534,6 @@ stock_tracking()
#----------------------------------------------------------
# Stock Picking
#----------------------------------------------------------
PICK_STATE = [
('draft', 'Draft'),
('auto', 'Waiting Another Operation'),
('confirmed', 'Waiting Availability'),
('assigned', 'Ready to Process'),
('done', 'Done'),
('cancel', 'Cancelled'),
]
class stock_picking(osv.osv):
_name = "stock.picking"
_inherit = ['mail.thread']
@ -614,19 +605,6 @@ class stock_picking(osv.osv):
res[pick]['min_date'] = dt1
res[pick]['max_date'] = dt2
return res
def _tooltip_picking_state(self, state=None):
# Update the tooltip of state field based on shipment type e.g: Delivery, Reception and Internal Transfer
if state is None:
state = PICK_STATE
_tooltip_state_assigned = state.get('assigned', False)
_tooltip_state_done = state.get('done', False)
return _("* Draft: not confirmed yet and will not be scheduled until confirmed\n"\
"* Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n"\
"* Waiting Availability: still waiting for the availability of products\n"\
"* %s: products reserved, simply waiting for confirmation.\n"\
"* %s: has been processed, can't be modified or cancelled anymore\n"\
"* Cancelled: has been cancelled, can't be confirmed anymore") % (_tooltip_state_assigned, _tooltip_state_done)
def create(self, cr, user, vals, context=None):
if ('name' not in vals) or (vals.get('name')=='/'):
@ -638,33 +616,46 @@ class stock_picking(osv.osv):
return new_id
_columns = {
'name': fields.char('Reference', size=64, select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'origin': fields.char('Origin', size=64, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="Reference of the document", select=True),
'backorder_id': fields.many2one('stock.picking', 'Back Order of', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="If this shipment was split, then this field links to the shipment which contains the already processed part.", select=True),
'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal')], 'Shipping Type', required=True, select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="Shipping type specify, goods coming in or going out."),
'note': fields.text('Notes', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'location_id': fields.many2one('stock.location', 'Location', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="Keep empty if you produce at the location where the finished products are needed." \
'name': fields.char('Reference', size=64, select=True),
'origin': fields.char('Origin', size=64, help="Reference of the document that produced this picking.", select=True),
'backorder_id': fields.many2one('stock.picking', 'Back Order of', help="If this picking was split this field links to the picking that contains the other part that has been processed already.", select=True),
'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal')], 'Shipping Type', required=True, select=True, help="Shipping type specify, goods coming in or going out."),
'note': fields.text('Notes'),
'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True),
'location_id': fields.many2one('stock.location', 'Location', help="Keep empty if you produce at the location where the finished products are needed." \
"Set a location if you produce at a fixed location. This can be a partner location " \
"if you subcontract the manufacturing operations.", select=True),
'location_dest_id': fields.many2one('stock.location', 'Dest. Location', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="Location where the system will stock the finished products.", select=True),
'move_type': fields.selection([('direct', 'Partial'), ('one', 'All at once')], 'Delivery Method', required=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="It specifies goods to be deliver partially or all at once"),
'state': fields.selection(PICK_STATE, 'State', readonly=True, select=True),
'location_dest_id': fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the finished products.", select=True),
'move_type': fields.selection([('direct', 'Partial Delivery'), ('one', 'All at once')], 'Delivery Method', required=True, help="It specifies goods to be delivered all at once or by direct delivery"),
'state': fields.selection([
('draft', 'New'),
('auto', 'Waiting Another Operation'),
('confirmed', 'Waiting Availability'),
('assigned', 'Ready to Process'),
('done', 'Done'),
('cancel', 'Cancelled'),
], 'State', readonly=True, select=True,
help="* Draft: not confirmed yet and will not be scheduled until confirmed\n"\
"* Confirmed: still waiting for the availability of products\n"\
"* Available: products reserved, simply waiting for confirmation.\n"\
"* Waiting: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n"\
"* Done: has been processed, can't be modified or cancelled anymore\n"\
"* Cancelled: has been cancelled, can't be confirmed anymore"),
'min_date': fields.function(get_min_max_date, fnct_inv=_set_minimum_date, multi="min_max_date",
store=True, type='datetime', string='Scheduled Date', select=1, help="Scheduled date for the shipment to be processed"),
'date': fields.datetime('Order Date', help="Date of order", select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'date_done': fields.datetime('Date Done', help="Date of Completion", states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
store=True, type='datetime', string='Expected Date', select=1, help="Expected date for the picking to be processed"),
'date': fields.datetime('Order Date', help="Date of Order", select=True),
'date_done': fields.datetime('Date Done', help="Date of Completion"),
'max_date': fields.function(get_min_max_date, fnct_inv=_set_maximum_date, multi="min_max_date",
store=True, type='datetime', string='Max. Expected Date', select=2),
'move_lines': fields.one2many('stock.move', 'picking_id', 'Internal Moves', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}),
'auto_picking': fields.boolean('Auto-Picking', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'partner_id': fields.many2one('res.partner', 'Partner', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'auto_picking': fields.boolean('Auto-Picking'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'invoice_state': fields.selection([
("invoiced", "Invoiced"),
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")], "Invoice Control",
select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
}
_defaults = {
'name': lambda self, cr, uid, context: '/',
@ -678,82 +669,23 @@ class stock_picking(osv.osv):
_sql_constraints = [
('name_uniq', 'unique(name, company_id)', 'Reference must be unique per Company!'),
]
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if context is None:
context = {}
mod_obj = self.pool.get('ir.model.data')
# To get the right view of shipment based on type from stock move and Back order.
if context.get('default_picking_id', False):
picking_type = self.browse(cr, uid, context['default_picking_id'], context=context).type
if picking_type == 'out':
context.update({'default_type':'out'})
view_id = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_form')[1]
elif picking_type == 'in':
context.update({'default_type':'in'})
view_id = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_in_form')[1]
elif picking_type == 'internal':
context.update({'default_type':'internal'})
view_id = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_form')[1]
type = context.get('default_type', False)
res = super(stock_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
if type:
if res.get('toolbar', False):
# To update the report label according to shipping type
for report in res['toolbar']['print']:
if report['report_name'] != 'stock.picking.list':
continue
if type == 'in':
report['string'] = _('Receipt Slip')
elif type == 'internal':
report['string'] = _('Picking Slip')
elif type == 'out':
report['string'] = _('Delivery Slip')
report['name'] = report['string']
for field in res['fields']:
# To update the states label according to shipping type
if field == 'state':
_state = dict(PICK_STATE)
if type == 'in':
_state['assigned'] = _('Ready to Receive')
_state['done'] = _('Received')
elif type == 'internal':
_state['assigned'] = _('Ready to Transfer')
_state['done'] = _('Transferred')
elif type == 'out':
_state['assigned'] = _('Ready to Deliver')
_state['done'] = _('Delivered')
res['fields']['state']['selection'] = [(x[0], _state[x[0]]) for x in PICK_STATE]
res['fields']['state']['help'] = self._tooltip_picking_state(_state)
# To update the fields tooltips according to shipping type
if field == 'partner_id':
_tooltip = ''
if type == 'in':
_tooltip = _('supplier')
elif type == 'internal':
_tooltip = _('warehouse')
elif type == 'out':
_tooltip = _('customer')
res['fields']['partner_id']['help'] = _("Address of %s") %(_tooltip)
return res
def action_process(self, cr, uid, ids, context=None):
if context is None: context = {}
mod_obj = self.pool.get('ir.model.data')
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','stock_partial_picking_form')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
ctx = context.copy()
ctx.update({'active_model': 'stock.picking', 'active_ids': ids })
context = dict(context, active_ids=ids, active_model=self._name)
partial_id = self.pool.get("stock.partial.picking").create(cr, uid, {}, context=context)
return {
'view_type': 'form',
'name':_("Products to Process"),
'view_mode': 'form',
'view_id': False,
'view_type': 'form',
'res_model': 'stock.partial.picking',
'views': [(resource_id,'form')],
'view_id': resource_id,
'res_id': partial_id,
'type': 'ir.actions.act_window',
'target': 'new',
'context': ctx,
'nodestroy': True,
'target': 'new',
'domain': '[]',
'context': context,
}
def copy(self, cr, uid, id, default=None, context=None):
@ -807,10 +739,7 @@ class stock_picking(osv.osv):
""" Changes state of picking to available if all moves are confirmed.
@return: True
"""
wf_service = netsvc.LocalService("workflow")
for pick in self.browse(cr, uid, ids):
if pick.state == 'draft':
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_confirm', cr)
move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed']
if not move_ids:
raise osv.except_osv(_('Warning !'),_('Not enough stock, unable to reserve the products.'))
@ -893,9 +822,6 @@ class stock_picking(osv.osv):
for pick in self.browse(cr, uid, ids):
mt = pick.move_type
for move in pick.move_lines:
# incomming shipments are always set as available
if pick.type == 'in':
return True
if (move.state in ('confirmed', 'draft')) and (mt == 'one'):
return False
if (mt == 'direct') and (move.state == 'assigned') and (move.product_qty):
@ -1613,14 +1539,6 @@ stock_production_lot_revision()
# Fields:
# location_dest_id is only used for predicting futur stocks
#
MOVE_STATE = [
('draft', 'Draft'),
('waiting', 'Waiting Another Move'),
('confirmed', 'Waiting Availability'),
('assigned', 'Available'),
('done', 'Done'),
('cancel', 'Cancelled')
]
class stock_move(osv.osv):
def _getSSCC(self, cr, uid, context=None):
@ -1684,17 +1602,6 @@ class stock_move(osv.osv):
return False
return True
def _tooltip_move_state(self, state=None):
# Update the tooltip of state field based on shipment type e.g: Delivery, Reception and Internal Transfer
if state is None:
state = MOVE_STATE
_tooltip_state_assigned = state.get('assigned', False)
_tooltip_state_done = state.get('done', False)
return _("* Draft: When the stock move is created it is in the \'Draft\' state.\n"\
"* Waiting Another Move: it is set to \'Waiting Another Move\' state if the scheduler did not find the products.\n"\
"* Waiting Availability: The state is \'Waiting Availability\' if the move is waiting for another one.\n"\
"* %s: When products are reserved it is set to \'%s\'.\n"\
"* %s: When the shipment is done the state is \'%s\'.") % (_tooltip_state_assigned, _tooltip_state_assigned, _tooltip_state_done, _tooltip_state_done)
_columns = {
'name': fields.char('Name', size=250, required=True, select=True),
'priority': fields.selection([('0', 'Not urgent'), ('1', 'Urgent')], 'Priority'),
@ -1723,12 +1630,9 @@ class stock_move(osv.osv):
'move_history_ids2': fields.many2many('stock.move', 'stock_move_history_ids', 'child_id', 'parent_id', 'Move History (parent moves)'),
'picking_id': fields.many2one('stock.picking', 'Reference', select=True,states={'done': [('readonly', True)]}),
'note': fields.text('Notes'),
'state': fields.selection(MOVE_STATE, 'State', readonly=True, select=True,
help= "* Draft: When the stock move is created it is in the \'Draft\' state.\n"\
"* Waiting Another Move: it is set to \'Waiting Another Move\' state if the scheduler did not find the products.\n"\
"* Waiting Availability: The state is \'Waiting Availability\' if the move is waiting for another one.\n"\
"* Available: When products are reserved it is set to \'Available\'.\n"\
"* Done: When the shipment is done the state is \'Done\'."),
'state': fields.selection([('draft', 'New'), ('waiting', 'Waiting Another Move'), ('confirmed', 'Waiting Availability'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
help='When the stock move is created it is in the \'Draft\' state.\n After that, it is set to \'Not Available\' state if the scheduler did not find the products.\n When products are reserved it is set to \'Available\'.\n When the picking is done the state is \'Done\'.\
\nThe state is \'Waiting\' if the move is waiting for another one.'),
'price_unit': fields.float('Unit Price', digits_compute= dp.get_precision('Account'), help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"),
'price_currency_id': fields.many2one('res.currency', 'Currency for average price', help="Technical field used to record the currency chosen by the user during a picking confirmation (when average price costing method is used)"),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
@ -1754,38 +1658,6 @@ class stock_move(osv.osv):
'You try to assign a lot which is not from the same product',
['prodlot_id'])]
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if context is None:
context = {}
type = context.get('default_type', False)
res = super(stock_move, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
if type:
doc = etree.XML(res['arch'])
if type == 'out':
#To Update button label in case of shipping type is out
if view_type == 'tree':
for node in doc.xpath("//button[@string='Receive']"):
node.set('string', _('Deliver'))
for node in doc.xpath("//group/button[@string='Process Now']"):
node.set('string', _('Deliver'))
for field in res['fields']:
# To update the states label according to shipping type
if field == 'state':
_state = dict(MOVE_STATE)
if type == 'in':
_state['assigned'] = _('Ready to Receive')
_state['done'] = _('Received')
elif type == 'internal':
_state['assigned'] = _('Ready to Transfer')
_state['done'] = _('Transferred')
elif type == 'out':
_state['assigned'] = _('Ready to Deliver')
_state['done'] = _('Delivered')
res['fields']['state']['selection'] = [(x[0], _state[x[0]]) for x in MOVE_STATE]
res['fields']['state']['help'] = self._tooltip_move_state(_state)
res['arch'] = etree.tostring(doc)
return res
def _default_location_destination(self, cr, uid, context=None):
""" Gets default address of partner for destination location
@return: Address id or False

View File

@ -691,20 +691,7 @@
<field name="type">form</field>
<field eval="12" name="priority"/>
<field name="arch" type="xml">
<form layout="manual">
<div class="oe_form_topbar">
<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>
<button name="draft_force_assign" states="draft" string="Process Later" type="object" icon="gtk-apply"/>
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-media-play"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" icon="gtk-find"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="action_process" states="assigned" string="Process" groups="stock.group_stock_user" type="object" icon="gtk-go-forward"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" icon="terp-gtk-go-back-rtl" />
<div class="oe_right">
<field name="state" nolabel="1" widget="statusbar" statusbar_visible="draft,progress,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
</div>
</div>
<sheet string="Internal Picking List" layout="auto">
<form string="Internal Picking List">
<group colspan="4" col="6">
<group colspan="4" col="4">
<field name="name" readonly="1"/>
@ -808,6 +795,16 @@
</group>
</form>
</field>
<group col="10" colspan="4">
<field name="state" readonly="1" widget="statusbar" statusbar_visible="draft,confirmed,assigned,done" statusbar_colors='{"auto":"blue", "confirmed":"blue"}'/>
<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>
<button name="draft_force_assign" states="draft" string="Process Later" type="object" icon="gtk-apply"/>
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-media-play"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" icon="gtk-find"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="action_process" states="assigned" string="Process" groups="stock.group_stock_user" type="object" icon="gtk-go-forward"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" icon="terp-gtk-go-back-rtl" />
</group>
</page>
<page string="Additional info">
<field name="auto_picking"/>
@ -820,7 +817,6 @@
<field colspan="4" name="note" nolabel="1"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
@ -885,21 +881,7 @@
<field name="model">stock.picking</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form layout="manual">
<div class="oe_form_topbar">
<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>
<button name="draft_force_assign" states="draft" string="Process Later" type="object" icon="gtk-ok"/>
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-yes"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" icon="gtk-find"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="action_process" states="assigned" string="Process" type="object" icon="gtk-go-forward"/>
<button name="%(act_stock_return_picking)d" string="Return Products" states="done" type="action" icon="gtk-execute"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" icon="terp-gtk-go-back-rtl"/>
<div class="oe_right">
<field name="state" nolabel="1" readonly="1" widget="statusbar" statusbar_visible="draft,confirmed,assigned,done" statusbar_colors='{"auto":"blue", "confirmed":"blue"}'/>
</div>
</div>
<sheet string="Delivery Orders" layout="auto">
<form string="Delivery Orders">
<group col="6" colspan="4">
<group colspan="4" col="4">
<field name="name" readonly="1"/>
@ -1002,6 +984,17 @@
</group>
</form>
</field>
<group col="12" colspan="4">
<field name="state" readonly="1" widget="statusbar" statusbar_visible="draft,confirmed,assigned,done" statusbar_colors='{"auto":"blue", "confirmed":"blue"}'/>
<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>
<button name="draft_force_assign" states="draft" string="Process Later" type="object" icon="gtk-ok"/>
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-yes"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" icon="gtk-find"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="action_process" states="assigned" string="Process" type="object" icon="gtk-go-forward"/>
<button name="%(act_stock_return_picking)d" string="Return Products" states="done" type="action" icon="gtk-execute"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" icon="terp-gtk-go-back-rtl"/>
</group>
</page>
<page string="Additional info">
<field name="auto_picking"/>
@ -1014,10 +1007,7 @@
<field colspan="4" name="note" nolabel="1"/>
</page>
</notebook>
</sheet>
<div class="oe_form_sheet_width">
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</div>
</form>
</field>
</record>
@ -1110,21 +1100,7 @@
<field name="model">stock.picking</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form layout="manual">
<div class="oe_form_topbar">
<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>
<button name="draft_force_assign" states="draft" string="Process Later" type="object" icon="gtk-ok"/>
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-media-play"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" icon="gtk-find"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="action_process" states="assigned" string="Process" type="object" icon="gtk-go-forward"/>
<button name="%(act_stock_return_picking)d" string="Return Products" states="done" type="action" icon="gtk-execute"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" icon="terp-gtk-go-back-rtl" />
<div class="oe_right">
<field name="state" nolabel="1" readonly="1" widget="statusbar" statusbar_visible="draft,assigned,done" statusbar_colors='{"auto":"blue", "confirmed":"blue"}'/>
</div>
</div>
<sheet string="Input Picking List" layout="auto">
<form string="Input Picking List">
<group colspan="4" col="6">
<group colspan="4" col="4">
<field name="name" readonly="1"/>
@ -1225,6 +1201,17 @@
</group>
</form>
</field>
<group col="10" colspan="4">
<field name="state" readonly="1" widget="statusbar" statusbar_visible="draft,assigned,done" statusbar_colors='{"auto":"blue", "confirmed":"blue"}'/>
<button name="button_cancel" states="assigned,confirmed,draft" string="_Cancel" icon="gtk-cancel"/>
<button name="draft_force_assign" states="draft" string="Process Later" type="object" icon="gtk-ok"/>
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-media-play"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" icon="gtk-find"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="action_process" states="assigned" string="Process" type="object" icon="gtk-go-forward"/>
<button name="%(act_stock_return_picking)d" string="Return Products" states="done" type="action" icon="gtk-execute"/>
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice" attrs="{'invisible': ['|','|',('state','&lt;&gt;','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" icon="terp-gtk-go-back-rtl" />
</group>
</page>
<page string="Additional Info">
<field name="type"/>
@ -1234,10 +1221,7 @@
<field colspan="4" name="note" nolabel="1"/>
</page>
</notebook>
</sheet>
<div class="oe_form_sheet_width">
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</div>
</form>
</field>
</record>

View File

@ -51,12 +51,11 @@
<field name="act_to" ref="act_confirmed"/>
<field name="signal">button_confirm</field>
</record>
<record id="trans_confirmed_assigned_back" model="workflow.transition">
<field name="act_from" ref="act_assigned"/>
<field name="act_to" ref="act_confirmed"/>
<field name="condition">not test_assigned()</field>
</record>
</record>
<record id="trans_confirmed_assigned" model="workflow.transition">
<field name="act_from" ref="act_confirmed"/>
<field name="act_to" ref="act_assigned"/>

View File

@ -20,7 +20,6 @@
##############################################################################
import time
from lxml import etree
from osv import fields, osv
from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
import decimal_precision as dp
@ -72,32 +71,6 @@ class stock_partial_picking(osv.osv_memory):
'picking_id': fields.many2one('stock.picking', 'Picking', required=True, ondelete='CASCADE'),
'hide_tracking': fields.function(_hide_tracking, string='Tracking', type='boolean', help='This field is for internal purpose. It is used to decide if the column prodlot has to be shown on the move_ids field or not'),
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if context is None:
context={}
# remove the entry with key 'form_view_ref', otherwise fields_view_get crashes
context.pop('form_view_ref', None)
res = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
type = context.get('default_type', False)
if type:
doc = etree.XML(res['arch'])
for node in doc.xpath("//group/button[@string='_Validate']"):
if type == 'in':
node.set('string', _('_Receive'))
elif type == 'internal':
node.set('string', _('_Transfer'))
elif type == 'out':
node.set('string', _('_Deliver'))
for node in doc.xpath("//separator[@string='Products']"):
if type == 'in':
node.set('string', _('Receive Products'))
elif type == 'internal':
node.set('string', _('Transfer Products'))
elif type == 'out':
node.set('string', _('Deliver Products'))
res['arch'] = etree.tostring(doc)
return res
def default_get(self, cr, uid, fields, context=None):
if context is None: context = {}
@ -138,7 +111,7 @@ class stock_partial_picking(osv.osv_memory):
def _partial_move_for(self, cr, uid, move):
partial_move = {
'product_id' : move.product_id.id,
'quantity' : move.state in ('assigned','draft','confirmed') and move.product_qty or 0,
'quantity' : move.state in ('assigned','new') and move.product_qty or 0,
'product_uom' : move.product_uom.id,
'prodlot_id' : move.prodlot_id.id,
'move_id' : move.id,

View File

@ -45,7 +45,7 @@ class stock_return_picking(osv.osv_memory):
_columns = {
'product_return_moves' : fields.one2many('stock.return.picking.memory', 'wizard_id', 'Moves'),
'invoice_state': fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing')], 'Invoicing',required=True),
}
}
def default_get(self, cr, uid, fields, context=None):
"""
@ -143,8 +143,6 @@ class stock_return_picking(osv.osv_memory):
pick_obj = self.pool.get('stock.picking')
uom_obj = self.pool.get('product.uom')
data_obj = self.pool.get('stock.return.picking.memory')
act_obj = self.pool.get('ir.actions.act_window')
model_obj = self.pool.get('ir.model.data')
wf_service = netsvc.LocalService("workflow")
pick = pick_obj.browse(cr, uid, record_id, context=context)
data = self.read(cr, uid, ids[0], context=context)
@ -154,20 +152,15 @@ class stock_return_picking(osv.osv_memory):
returned_lines = 0
# Create new picking for returned products
if pick.type =='out':
if pick.type=='out':
new_type = 'in'
elif pick.type =='in':
elif pick.type=='in':
new_type = 'out'
else:
new_type = 'internal'
new_picking = pick_obj.copy(cr, uid, pick.id, {
'name':'%s-return' % pick.name,
'move_lines': [],
'state':'draft',
'type': new_type,
'date':date_cur,
'invoice_state': data['invoice_state'],
})
new_picking = pick_obj.copy(cr, uid, pick.id, {'name':'%s-return' % pick.name,
'move_lines':[], 'state':'draft', 'type':new_type,
'date':date_cur, 'invoice_state':data['invoice_state'],})
val_id = data['product_return_moves']
for v in val_id:
@ -185,34 +178,40 @@ class stock_return_picking(osv.osv_memory):
if new_qty:
returned_lines += 1
new_move=move_obj.copy(cr, uid, move.id, {
'product_qty': new_qty,
'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id, new_qty, move.product_uos.id),
'picking_id':new_picking,
'state': 'draft',
'location_id': new_location,
'location_dest_id': move.location_id.id,
'date': date_cur,
})
move_obj.write(cr, uid, [move.id], {'move_history_ids2':[(4,new_move)]}, context=context)
'product_qty': new_qty,
'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id,
new_qty, move.product_uos.id),
'picking_id':new_picking, 'state':'draft',
'location_id':new_location, 'location_dest_id':move.location_id.id,
'date':date_cur,})
move_obj.write(cr, uid, [move.id], {'move_history_ids2':[(4,new_move)]})
if not returned_lines:
raise osv.except_osv(_('Warning !'), _("Please specify at least one non-zero quantity!"))
if set_invoice_state_to_none:
pick_obj.write(cr, uid, [pick.id], {'invoice_state':'none'}, context=context)
pick_obj.write(cr, uid, [pick.id], {'invoice_state':'none'})
wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)
pick_obj.force_assign(cr, uid, [new_picking], context)
# Update view id in context, lp:702939
action_list = {
'out': 'action_picking_tree',
'in': 'action_picking_tree4',
'internal': 'action_picking_tree6',
view_list = {
'out': 'view_picking_out_tree',
'in': 'view_picking_in_tree',
'internal': 'vpicktree',
}
data_obj = self.pool.get('ir.model.data')
res = data_obj.get_object_reference(cr, uid, 'stock', view_list.get(new_type, 'vpicktree'))
context.update({'view_id': res and res[1] or False})
return {
'domain': "[('id', 'in', ["+str(new_picking)+"])]",
'name': 'Picking List',
'view_type':'form',
'view_mode':'tree,form',
'res_model':'stock.picking',
'type':'ir.actions.act_window',
'context':context,
}
res = model_obj.get_object_reference(cr, uid, 'stock', action_list.get(new_type, 'action_picking_tree6'))
id = res and res[1] or False
result = act_obj.read(cr, uid, [id], context=context)[0]
result['domain'] = "[('id', 'in', ["+str(new_picking)+"])]"
return result
stock_return_picking()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<act_window name="Return Shipment"
<act_window name="Return Picking"
res_model="stock.return.picking"
src_model="stock.picking"
view_mode="form"