[WIP] stock
bzr revid: qdp-launchpad@openerp.com-20130710155911-9h4c40w0oqgontce
This commit is contained in:
parent
339e8ad65c
commit
f3676a6640
|
@ -666,7 +666,7 @@
|
|||
<field name="bom_id" ref="mrp.mrp_bom_7"/>
|
||||
<field name="routing_id" ref="mrp.mrp_routing_1"/>
|
||||
</record>
|
||||
<!--<workflow action="button_confirm" model="mrp.production" ref="mrp_production_1"/> -->
|
||||
<workflow action="button_confirm" model="mrp.production" ref="mrp_production_1"/>
|
||||
|
||||
<!-- Run Scheduler -->
|
||||
<function model="procurement.order" name="run_scheduler"/>
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
</record>
|
||||
|
||||
<!-- Confirm some Sale Orders-->
|
||||
<!--<workflow action="order_confirm" model="sale.order" ref="sale.sale_order_1"/>
|
||||
<workflow action="order_confirm" model="sale.order" ref="sale.sale_order_5"/>-->
|
||||
<workflow action="order_confirm" model="sale.order" ref="sale.sale_order_1"/>
|
||||
<workflow action="order_confirm" model="sale.order" ref="sale.sale_order_5"/>
|
||||
|
||||
<record id="sale.sale_order_line_4" model="sale.order.line">
|
||||
<field name="type">make_to_order</field>
|
||||
|
|
|
@ -19,13 +19,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
import openerp.addons.decimal_precision as dp
|
||||
from openerp.tools.translate import _
|
||||
|
||||
class procurement_group(osv.osv):
|
||||
_inherit = 'procurement.group'
|
||||
|
@ -35,11 +30,13 @@ class procurement_group(osv.osv):
|
|||
|
||||
class procurement_rule(osv.osv):
|
||||
_inherit = 'procurement.rule'
|
||||
|
||||
def _get_action(self, cr, uid, context=None):
|
||||
result = super(procurement_rule, self)._get_action(cr, uid, context=context)
|
||||
return result + [('move','Move From Another Location')]
|
||||
return result + [('move', 'Move From Another Location')]
|
||||
|
||||
_columns = {
|
||||
'location_id': fields.many2one('stock.location', 'Destination Location'),
|
||||
'location_id': fields.many2one('stock.location', 'Destination Location'),
|
||||
'location_src_id': fields.many2one('stock.location', 'Source Location',
|
||||
help="Source location is action=move")
|
||||
}
|
||||
|
@ -47,27 +44,28 @@ class procurement_rule(osv.osv):
|
|||
class procurement_order(osv.osv):
|
||||
_inherit = "procurement.order"
|
||||
_columns = {
|
||||
'location_id': fields.many2one('stock.location', 'Destination Location'),
|
||||
'move_id': fields.many2one('stock.move', 'Move', help="Move created by the procurement"),
|
||||
'location_id': fields.many2one('stock.location', 'Destination Location'),
|
||||
'move_id': fields.many2one('stock.move', 'Move', help="Move created by the procurement"),
|
||||
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Move which caused (created) the procurement")
|
||||
}
|
||||
|
||||
def _assign(self, cr, uid, procurement, context=None):
|
||||
rule_obj = self.pool.get('procurement.rule')
|
||||
res = rule_obj.search(cr, uid, [('location_id','=',procurement.location_id.id)], context=context)
|
||||
def _find_suitable_rule(self, cr, uid, procurement, context=None):
|
||||
res = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
|
||||
if not res:
|
||||
return super(procurement_order, self)._assign(cr, uid, procurement, context=context)
|
||||
return rule_obj.browse(cr, uid, res[0], context=context)
|
||||
rule_obj = self.pool.get('procurement.rule')
|
||||
res = rule_obj.search(cr, uid, [('location_id', '=', procurement.location_id.id)], context=context)
|
||||
res = res and res[0] or False
|
||||
return res
|
||||
|
||||
def _run_move_create(self, cr, uid, procurement, context=None):
|
||||
def _run_move_create(self, cr, uid, procurement, context=None):
|
||||
return {
|
||||
'name': procurement.name,
|
||||
'company_id': procurement.company_id.id,
|
||||
'company_id': procurement.company_id.id,
|
||||
'product_id': procurement.product_id.id,
|
||||
'date': procurement.date_planned,
|
||||
'product_qty': procurement.product_qty,
|
||||
'product_uom': procurement.product_uom.id,
|
||||
'product_uom_qty': procurement.product_qty,
|
||||
'product_uom_qty': procurement.product_qty,
|
||||
'product_uos_qty': (procurement.product_uos and procurement.product_uos_qty)\
|
||||
or procurement.product_qty,
|
||||
'product_uos': (procurement.product_uos and procurement.product_uos.id)\
|
||||
|
@ -77,28 +75,28 @@ class procurement_order(osv.osv):
|
|||
'location_id': procurement.rule_id.location_src_id.id,
|
||||
'location_dest_id': procurement.rule_id.location_id.id,
|
||||
'move_dest_id': procurement.move_dest_id and procurement.move_dest_id.id or False,
|
||||
'procure_method': procurement.rule_id and procurement.rule_id.procure_method or 'make_to_stock',
|
||||
'procure_method': procurement.rule_id and procurement.rule_id.procure_method or 'make_to_stock',
|
||||
#'cancel_cascade': procurement.rule_id and procurement.rule_id.cancel_cascade or False,
|
||||
'group_id': procurement.group_id and procurement.group_id.id or False,
|
||||
'group_id': procurement.group_id and procurement.group_id.id or False,
|
||||
}
|
||||
|
||||
def _run(self, cr, uid, procurement, context=None):
|
||||
context=context or {}
|
||||
if procurement.rule_id and procurement.rule_id.action == 'move':
|
||||
if not procurement.rule_id.location_src_id:
|
||||
self.message_post(cr, uid, [procurement.id], body=_('No source location defined!'), context=context)
|
||||
return False
|
||||
move_obj = self.pool.get('stock.move')
|
||||
move_dict = self._run_move_create(cr, uid, procurement, context=context)
|
||||
|
||||
|
||||
move_id = move_obj.create(cr, uid, move_dict, context=context)
|
||||
move_obj.action_confirm(cr,uid, [move_id], context=context)
|
||||
move_obj.action_confirm(cr, uid, [move_id], context=context)
|
||||
self.write(cr, uid, [procurement.id], {'move_id': move_id}, context=context)
|
||||
return move_id
|
||||
return super(procurement_order, self)._run(cr, uid, procurement, context)
|
||||
|
||||
def _check(self, cr, uid, procurement, context=None):
|
||||
if procurement.rule_id and procurement.rule_id.action == 'move':
|
||||
return procurement.move_id.state=='done'
|
||||
return procurement.move_id.state == 'done'
|
||||
return super(procurement_order, self)._check(cr, uid, procurement, context)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue