[MERGE, IMP] merge with mma branch and improve view so it will open proper view from invoice based on reception in case of purchase and Delivery to Invoice in case of sale

bzr revid: psi@tinyerp.com-20120320124612-4dg1nj12yr9sh22m
This commit is contained in:
Purnendu Singh (OpenERP) 2012-03-20 18:16:12 +05:30
commit 2ed9a957e8
6 changed files with 119 additions and 45 deletions

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"/>
<field name="purchase_id" invisible="1"/>
</field>
</field>
</record>
@ -31,7 +31,7 @@
res_model="stock.picking"
groups="base.group_extended"
src_model="purchase.order"
context="{'default_purchase_id': active_id, 'contact_display': 'partner'}" />
context="{'default_purchase_id': active_id, 'contact_display': 'partner', 'default_type': 'in'}" />
<record id="action_picking_in_tree_view" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
@ -52,9 +52,9 @@
<field name="type">form</field>
<field name="inherit_id" ref="stock.view_picking_in_form"/>
<field name="arch" type="xml">
<field name="backorder_id" position="after">
<xpath expr="/form/notebook/page/field[@name='date']" position="before">
<field name="purchase_id"/>
</field>
</xpath>
</field>
</record>
@ -115,6 +115,19 @@
<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,7 +246,21 @@
<page string="History" groups="base.group_extended">
<separator colspan="4" string="Invoices"/>
<field colspan="4" name="invoice_ids" nolabel="1" context="{'form_view_ref':'account.invoice_form'}"/>
<field colspan="4" name="picking_ids" nolabel="1"/>
<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" groups="base.group_extended"/>
<field name="invoice_state"/>
<field name="stock_journal_id" groups="base.group_extended" 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>
</page>
</notebook>
</form>

View File

@ -8,7 +8,7 @@
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<field name="auto_picking" position="after">
<field name="sale_id"/>
<field name="sale_id" invisible="1"/>
</field>
</field>
</record>
@ -57,9 +57,9 @@
<field name="type">form</field>
<field name="inherit_id" ref="stock.view_picking_out_form"/>
<field name="arch" type="xml">
<field name="move_type" position="after">
<xpath expr="/form/notebook/page/field[@name='date']" position="after">
<field name="sale_id"/>
</field>
</xpath>
</field>
</record>
@ -74,6 +74,21 @@
<field name="context">{'default_type': 'out', 'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1}</field>
<field name="search_view_id" ref="stock.view_picking_out_search"/>
</record>
<record id="action_sale_picking_out_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_out_tree"/>
<field name="act_window_id" ref="outgoing_picking_list_to_invoice"/>
</record>
<record id="action_sale_picking_out_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_out_form"/>
<field name="act_window_id" ref="outgoing_picking_list_to_invoice"/>
</record>
<menuitem action="outgoing_picking_list_to_invoice" id="menu_action_picking_list_to_invoice" parent="base.menu_invoiced" groups="base.group_no_one" sequence="20"/>
</data>

View File

@ -640,7 +640,7 @@ class stock_picking(osv.osv):
"* 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='Expected Date', select=1, help="Expected date for the picking to be processed"),
store=True, type='datetime', string='Scheduled Date', select=1, help="Expected date for the picking 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)]}),
'max_date': fields.function(get_min_max_date, fnct_inv=_set_maximum_date, multi="min_max_date",
@ -711,22 +711,23 @@ class stock_picking(osv.osv):
return res
def action_process(self, cr, uid, ids, context=None):
if context is None: context = {}
context = dict(context, active_ids=ids, active_model=self._name)
partial_id = self.pool.get("stock.partial.picking").create(cr, uid, {}, context=context)
return {
'name':_("Products to Process"),
'view_mode': 'form',
'view_id': False,
'view_type': 'form',
'res_model': 'stock.partial.picking',
'res_id': partial_id,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'domain': '[]',
'context': context,
}
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 })
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.partial.picking',
'views': [(resource_id,'form')],
'view_id': resource_id,
'type': 'ir.actions.act_window',
'target': 'new',
'context': ctx,
'nodestroy': True,
}
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
@ -783,7 +784,7 @@ class stock_picking(osv.osv):
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)
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.'))

View File

@ -696,14 +696,12 @@
<group colspan="4" col="4">
<field name="name" readonly="1"/>
<field name="origin"/>
<field name="address_id" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" colspan="4"/>
<field name="address_id" string="Warehouse" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" colspan="4"/>
<field name="invoice_state" string="Invoice Control" groups="base.group_extended"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
</group>
<group colspan="2" col="2">
<field name="date"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
<field name="min_date" readonly="1"/>
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
</group>
</group>
<notebook colspan="4">
@ -737,8 +735,9 @@
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_expected" string="Date Expected"/>
<field name="date_expected" />
<field name="state"/>
</tree>
<form string="Stock Moves">
@ -808,10 +807,12 @@
</page>
<page string="Additional info" groups="base.group_extended,base.group_multi_company">
<field name="auto_picking" groups="base.group_extended"/>
<field name="date_done" groups="base.group_extended"/>
<field name="move_type" groups="base.group_extended"/>
<field name="type" groups="base.group_extended"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="move_type" groups="base.group_extended"/>
<field name="date"/>
<field name="type" groups="base.group_extended" invisible="1"/>
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
<field name="date_done" string="Received Date" groups="base.group_extended"/>
</page>
<page string="Notes">
<field colspan="4" name="note" nolabel="1"/>
@ -888,12 +889,12 @@
<group colspan="4" col="4">
<field name="name" readonly="1"/>
<field name="origin" readonly="1"/>
<field name="address_id" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" colspan="4"/>
<field name="address_id" string="Customer" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" colspan="4"/>
<field name="invoice_state"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
</group>
<group colspan="2" col="2">
<field name="date"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
<field name="min_date" readonly="1"/>
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
</group>
@ -927,7 +928,7 @@
groups="base.group_extended"
states="draft,assigned,confirmed"/>
<field name="location_id"/>
<field name="date"/>
<field name="date_expected"/>
<field name="state"/>
<button name="%(action_partial_move_server)d" string="Process" type="action" states="confirmed,assigned" icon="gtk-go-forward"/>
</tree>
@ -1000,10 +1001,11 @@
</page>
<page string="Additional info" groups="base.group_extended,base.group_multi_company">
<field name="auto_picking" groups="base.group_extended"/>
<field name="date_done" groups="base.group_extended"/>
<field name="move_type" groups="base.group_extended"/>
<field name="type" groups="base.group_extended"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="move_type" groups="base.group_extended"/>
<field name="date"/>
<field name="date_done" string="Delivery Date" groups="base.group_extended"/>
<field name="type" groups="base.group_extended" invisible="1"/>
</page>
<page string="Notes">
<field colspan="4" name="note" nolabel="1"/>
@ -1109,12 +1111,12 @@
<group colspan="4" col="4">
<field name="name" readonly="1"/>
<field name="origin"/>
<field name="address_id" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" domain="[('partner_id','&lt;&gt;',False)]" colspan="4"/>
<field name="address_id" string="Supplier" on_change="onchange_partner_in(address_id)" context="{'contact_display':'partner'}" domain="[('partner_id','&lt;&gt;',False)]" colspan="4"/>
<field name="invoice_state" string="Invoice Control"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
</group>
<group colspan="2" col="2">
<field name="date"/>
<field name="backorder_id" readonly="1" groups="base.group_extended"/>
<field name="min_date" readonly="1"/>
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
</group>
@ -1219,7 +1221,8 @@
</group>
</page>
<page string="Additional Info" groups="base.group_extended,base.group_multi_company">
<field name="type" groups="base.group_extended"/>
<field name="type" groups="base.group_extended" invisible="1"/>
<field name="date"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</page>
<page string="Notes">
@ -1804,6 +1807,7 @@
src_model="product.product"/>
<act_window
context="{'default_type': 'internal'}"
domain="[('move_lines','=',active_id)]"
id="act_relate_picking"
name="Related Picking"

View File

@ -20,6 +20,7 @@
##############################################################################
import time
from lxml import etree
from osv import fields, osv
from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
import decimal_precision as dp
@ -71,6 +72,32 @@ 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', '_Move')
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', 'Move 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 = {}