bzr revid: hmo@tinyerp.com-20100421134602-k2gdh5tt09dykkc9
This commit is contained in:
Harry (Open ERP)
2010-04-21 19:16:02 +05:30
12 changed files with 17 additions and 425 deletions
@@ -39,24 +39,18 @@ class purchase_requisition(osv.osv):
'company_id': fields.many2one('res.company', 'Company', required=True),
'purchase_ids' : fields.one2many('purchase.order','requisition_id','Purchase Orders'),
'line_ids' : fields.one2many('purchase.requisition.line','requisition_id','Products to Purchase'),
'state': fields.selection([('draft','Draft'),('open','Open'),('cancel','Cancelled'),('close','Close'),('done','Done')], 'State', required=True)
'state': fields.selection([('draft','Draft'),('in_progress','In Progress'),('cancel','Cancelled'),('done','Done')], 'State', required=True)
}
_defaults = {
'date_start': lambda *args: time.strftime('%Y-%m-%d %H:%M:%S'),
'state': lambda *args: 'open',
'state': lambda *args: 'draft',
'exclusive': lambda *args: 'multiple',
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
'user_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).id ,
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.requisition'),
}
def tender_close(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state': 'done', 'date_end': time.strftime('%Y-%m-%d %H:%M:%S')})
return True
def tender_open(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'open'}, context=context)
return True
def tender_cancel(self, cr, uid, ids, context={}):
purchase_order_obj = self.pool.get('purchase.order')
for purchase in self.browse(cr, uid, ids):
@@ -65,14 +59,14 @@ class purchase_requisition(osv.osv):
purchase_order_obj.action_cancel(cr,uid,[purchase_id.id])
self.write(cr, uid, ids, {'state': 'cancel'})
return True
def tender_confirm(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'done','date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
def tender_in_progress(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'in_progress'} ,context=context)
return True
def tender_reset(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state': 'draft'})
return True
def tender_done(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'done'}, context=context)
self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
return True
@@ -84,7 +78,7 @@ class purchase_requisition_line(osv.osv):
_description="Purchase Requisition Line"
_rec_name = 'product_id'
_columns = {
'product_id': fields.many2one('product.product', 'Product'),
'product_id': fields.many2one('product.product', 'Product' , domain=[('purchase_requisition', '=', True)]),
'product_uom_id': fields.many2one('product.uom', 'Product UoM'),
'product_qty': fields.float('Quantity', digits=(16,2)),
'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade'),
@@ -156,7 +150,7 @@ class mrp_procurement(osv.osv):
procurement = self.browse(cr, uid, proc_id)
if procurement.product_id.purchase_requisition:
self.pool.get('purchase.requisition').create(cr, uid, {
'name': procurement.name,
'name': sequence_obj.get(cr, uid, 'purchase.order.requisition'),
'origin': procurement.name,
'date_end': procurement.date_planned,
'line_ids': [(0,0,{
@@ -73,11 +73,10 @@
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="1" readonly ="1"/>
<button name="tender_close" states="open,draft" string="Close" type="object" icon="gtk-close" />
<button name="tender_open" states="draft,in_progress" string="Open" type="object" icon="gtk-go-forward" />
<button name="tender_cancel" states="draft,open," string="Cancel" type="object" icon="gtk-cancel" />
<button name="tender_confirm" states="open" string="Confirm" type="object" icon="gtk-go-up" />
<button name="tender_in_progress" states="draft" string="Confirm" type="object" icon="gtk-apply" />
<button name="tender_cancel" states="draft,in_progress" string="Cancel" type="object" icon="gtk-cancel" />
<button name="tender_reset" states="done,cancel" string="Reset to Draft" type="object" icon="gtk-convert" />
<button name="tender_done" states="in_progress" string="Done" type="object" icon="gtk-jump-to" />
</group>
@@ -107,8 +106,7 @@
<field name="arch" type="xml">
<search string="Search Purchase Requisition">
<group col='10' colspan='4'>
<filter icon="terp-purchase" string="Quotations" domain="[('state','=','draft')]" separator="1"/>
<filter icon="terp-purchase" string="Approved" domain="[('state','=','open')]" separator="1"/>
<filter icon="terp-purchase" string=" Current" domain="[('state','=','draft,in_progress')]" separator="1" help="Current Purchaes Requisition"/>
<separator orientation="vertical"/>
<field name="name" select="1" string="Requisition Reference"/>
<field name="purchase_ids" select="1"/>
@@ -31,7 +31,7 @@ class purchase_requisition_partner(osv.osv_memory):
_name = "purchase.requisition.partner"
_description = "Purchase Requisition Partner"
_columns = {
'partner_id': fields.many2one('res.partner', 'Partner', required=True),
'partner_id': fields.many2one('res.partner', 'Partner', required=True,domain=[('supplier', '=', True)]),
'partner_address_id':fields.many2one('res.partner.address', 'Address', required=True),
}
-3
View File
@@ -52,10 +52,7 @@ Thanks to the double entry management, the inventory controlling is powerful and
"wizard/stock_location_product_view.xml",
"wizard/stock_inventory_line_split_view.xml",
"wizard/stock_change_standard_price_view.xml",
"wizard/stock_picking_make_view.xml",
"wizard/stock_traceability_view.xml",
"wizard/stock_picking_make_view.xml",
"wizard/stock_return_picking_view.xml",
"stock_workflow.xml",
"stock_incoterms.xml",
"stock_wizard.xml",
@@ -42,6 +42,5 @@
"access_stock_traceability_lot_downstream","stock.traceability.lot.downstream","model_stock_traceability_lot_downstream","stock.group_stock_user",1,0,0,0
"access_stock_partial_picking",stock.partial.picking","model_stock_partial_picking","stock.group_stock_user",1,0,0,0
"access_stock_partial_move","stock.partial.move","model_stock_partial_move","stock.group_stock_user",1,0,0,0
"access_stock_picking_make","stock.picking.make","model_stock_picking_make","stock.group_stock_user",1,0,0,0
"access_stock_inventory_merge","stock.inventory.merge","model_stock_inventory_merge","stock.group_stock_user",1,0,0,0
"access_stock_change_standard_price","stock.change.standard.price","model_stock_change_standard_price","stock.group_stock_user",1,0,0,0
Can't render this file because it contains an unexpected character in line 43 and column 53.
+4 -1
View File
@@ -1339,8 +1339,11 @@ class stock_move(osv.osv):
new_moves = []
for picking, todo in self._chain_compute(cr, uid, moves, context).items():
ptype = self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
pick_name = ''
if ptype == 'delivery':
pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery')
pickid = self.pool.get('stock.picking').create(cr, uid, {
'name': picking.name,
'name': pick_name or picking.name,
'origin': str(picking.origin or ''),
'type': ptype,
'note': picking.note,
-48
View File
@@ -601,18 +601,6 @@
<field name="min_date" select="1"/>
<field name="type"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<button name="%(act_stock_make_picking_wizard)d"
states="confirmed,assigned"
string="Make Picking"
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
icon="gtk-go-back"
help="Return Picking" colspan="2"/>
</group>
<notebook colspan="4">
<page string="General Information">
@@ -763,18 +751,6 @@
<field name="date" />
<field name="min_date" select="1"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<button name="%(act_stock_make_picking_wizard)d"
states="assigned"
string="Make Picking"
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
icon="gtk-go-back"
help="Return Picking" colspan="2"/>
</group>
<notebook colspan="4">
<page string="General Information">
@@ -953,18 +929,6 @@
<field name="backorder_id" readonly="1"/>
<field name="origin" readonly="1"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<button name="%(act_stock_make_picking_wizard)d"
states="assigned"
string="Make Picking"
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
icon="gtk-go-back"
help="Return Picking" colspan="2"/>
</group>
<notebook colspan="4">
<page string="General Information">
@@ -1140,18 +1104,6 @@
<field name="min_date" readonly="1"/>
<field name="invoice_state" string="Invoice Control"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<button name="%(act_stock_make_picking_wizard)d"
states="confirmed,assigned"
string="Make Picking"
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
icon="gtk-go-back"
help="Return Picking" colspan="2"/>
</group>
<notebook colspan="4">
<page string="General Information">
-2
View File
@@ -23,9 +23,7 @@ import stock_traceability
import stock_move
import stock_partial_picking
import stock_partial_move
import stock_picking_make
import wizard_replacement
import stock_return_picking
import wizard_ups
import stock_inventory_merge
import stock_inventory_set_stock_zero
-80
View File
@@ -1,80 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
import netsvc
class stock_picking_make(osv.osv_memory):
_name = 'stock.picking.make'
_description = "Make Picking"
_columns = {
'picking_ids': fields.many2many('stock.picking', 'stock_picking_ids', 'parent_id', 'child_id', 'Pickings'),
}
def default_get(self, cursor, user, fields, context):
"""
To get default values for the object.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
res = super(stock_picking_make, self).default_get(cursor, user, fields, context=context)
record_ids = context and context.get('active_ids',False) or False
if record_ids:
picking_obj = self.pool.get('stock.picking')
picking_ids = picking_obj.search(cursor, user, [
('id', 'in', record_ids),
('state', '<>', 'done'),
('state', '<>', 'cancel')], context=context)
res['picking_ids'] = picking_ids
return res
def make_packing(self, cursor, user, ids, context):
"""
Make Picking.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
record_ids = context and context.get('active_ids',False) or False
wkf_service = netsvc.LocalService('workflow')
picking_obj = self.pool.get('stock.picking')
data = self.read(cursor, user, ids[0])
pick_ids = data['picking_ids']
picking_obj.force_assign(cursor, user, pick_ids)
picking_obj.action_move(cursor, user, pick_ids)
for picking_id in ids:
wkf_service.trg_validate(user, 'stock.picking', picking_id,
'button_done', cursor)
return {}
stock_picking_make()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_stock_make_picking_wizard" model="ir.ui.view">
<field name="name">Make Picking</field>
<field name="model">stock.picking.make</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Make Picking">
<field name="picking_ids" nolabel="1" colspan="4"
width="600" height="300"/>
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="make_packing" string="Ok"
type="object" icon="gtk-apply" />
</form>
</field>
</record>
<record id="act_stock_make_picking_wizard" model="ir.actions.act_window">
<field name="name">Make Picking</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.picking.make</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
-221
View File
@@ -1,221 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import netsvc
import time
from osv import osv,fields
from tools.translate import _
class stock_return_picking(osv.osv_memory):
_name = 'stock.return.picking'
_description = 'Return Picking'
def default_get(self, cr, uid, fields, context):
"""
To get default values for the object.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
res = super(stock_return_picking, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
for m in [line for line in pick.move_lines]:
res['return%s'%(m.id)] = m.product_qty
if pick.invoice_state=='invoiced':
res['invoice_state'] = '2binvoiced'
else:
res['invoice_state'] = 'none'
return res
def view_init(self, cr, uid, fields_list, context=None):
"""
Creates view dynamically and adding fields at runtime.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view with new columns.
"""
res = super(stock_return_picking, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
if record_id:
pick_obj = self.pool.get('stock.picking')
try:
pick = pick_obj.browse(cr, uid, record_id)
for m in [line for line in pick.move_lines]:
if 'return%s'%(m.id) not in self._columns:
self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True)
if 'invoice_state' not in self._columns:
self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be Invoiced'), ('none', 'None')], string='Invoice State', required=True)
except Exception, e:
return res
return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view.
"""
res = super(stock_return_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
record_id = context and context.get('active_id', False) or False
assert record_id,'Active ID not found'
if record_id:
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
try:
if pick.state != 'done':
raise osv.except_osv(_('Warning !'), _("The Picking is not completed yet!\nYou cannot return picking which is not in 'Done' state!"))
return_history = {}
for m_line in pick.move_lines:
return_history[m_line.id] = 0
for rec in m_line.move_stock_return_history:
return_history[m_line.id] += rec.product_qty
res['fields'].clear()
arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Provide the quantities of the returned products.')]
for m in [line for line in pick.move_lines]:
quantity = m.product_qty
if quantity > return_history[m.id] and (quantity - return_history[m.id])>0:
arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
res['fields']['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True}
res.setdefault('returns', []).append(m.id)
if not res.get('returns',False):
raise osv.except_osv(_('Warning!'),_('There is no product to return!'))
arch_lst.append('<field name="invoice_state"/>\n<newline/>')
if pick.invoice_state=='invoiced':
new_invoice_state='2binvoiced'
else:
new_invoice_state=pick.invoice_state
res['fields']['invoice_state']={'string':_('Invoice state'), 'type':'selection','required':True, 'selection':[('2binvoiced', _('To Be Invoiced')), ('none', _('None'))]}
arch_lst.append('<group col="2" colspan="4">')
arch_lst.append('<button icon="gtk-cancel" special="cancel" string="Cancel" />')
arch_lst.append('<button name="action_open_window" string="Return" colspan="1" type="object" icon="gtk-apply" />')
arch_lst.append('</group>')
arch_lst.append('</form>')
res['arch'] = '\n'.join(arch_lst)
except Exception,e:
return res
return res
def _create_returns(self, cr, uid, ids, context):
"""
Creates return picking.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of ids selected
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
record_id = context and context.get('active_id', False) or False
move_obj = self.pool.get('stock.move')
pick_obj = self.pool.get('stock.picking')
uom_obj = self.pool.get('product.uom')
wf_service = netsvc.LocalService("workflow")
pick = pick_obj.browse(cr, uid, record_id)
data = self.read(cr, uid, ids[0])
new_picking = None
date_cur = time.strftime('%Y-%m-%d %H:%M:%S')
move_ids = [m.id for m in [line for line in pick.move_lines]]
set_invoice_state_to_none = True
for move in move_obj.browse(cr, uid, move_ids):
if not new_picking:
if pick.type=='out':
new_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_location=move.location_dest_id.id
new_qty = data['return%s' % move.id]
returned_qty = move.product_qty
for rec in move.move_stock_return_history:
returned_qty -= rec.product_qty
if returned_qty != new_qty:
set_invoice_state_to_none = False
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, 'date_planned':date_cur,})
move_obj.write(cr, uid, [move.id], {'move_stock_return_history':[(4,new_move)]})
if set_invoice_state_to_none:
pick_obj.write(cr, uid, [pick.id], {'invoice_state':'none'})
if new_picking:
if new_picking:
wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)
pick_obj.force_assign(cr, uid, [new_picking], context)
return new_picking
def action_open_window(self, cr, uid, ids, context):
"""
Opens return picking list.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of ids selected
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
res = self._create_returns(cr, uid, ids, context)
if not res:
return {}
return {
'domain': "[('id', 'in', ["+str(res)+"])]",
'name': 'Picking List',
'view_type':'form',
'view_mode':'tree,form',
'res_model':'stock.picking',
'view_id':False,
'type':'ir.actions.act_window',
}
stock_return_picking()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Return Picking -->
<record id="act_stock_return_picking" model="ir.actions.act_window">
<field name="name">Return Picking</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.return.picking</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>