[ADD] mrp, mrp_procurement: Task ID-574: Remove mrp.procurement from the MRP module. Separated mrp.procurment object into new module mrp_procurement.

bzr revid: uco@tinyerp.co.in-20100429133007-ut53koctlffi8g2a
This commit is contained in:
uco (OpenERP) 2010-04-29 19:00:07 +05:30
parent a51e1755de
commit 0479ed81bc
59 changed files with 1992 additions and 1337 deletions

View File

@ -15,7 +15,7 @@
<child1>
<action colspan="4" height="200" name="%(mrp.mrp_production_action2)d" string="Next production orders" width="510"/>
<action colspan="4" name="%(stock.action_picking_all)d" string="Deliveries (Out picking)" domain="[('state','=','assigned'),('type','=','out')]"/>
<action colspan="4" name="%(mrp.mrp_procurement_action4)d" string="Procurements in Exception"/>
<action colspan="4" name="%(mrp_procurement.mrp_procurement_action4)d" string="Procurements in Exception"/>
</child1>

View File

@ -23,7 +23,7 @@
<form string="Warehouse board">
<hpaned position="100">
<child1>
<action colspan="4" name="%(mrp.mrp_procurement_action5)d" string="Procurement Exceptions" width="510" />
<action colspan="4" name="%(mrp_procurement.mrp_procurement_action5)d" string="Procurement Exceptions" width="510" />
<action colspan="4" name="%(action_reception_picking_move_board)d" string="Products To Receive" />
</child1>

View File

@ -26,5 +26,6 @@ import installer
import wizard
import report
import company
import schedulers
import mrp_procurement
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -26,7 +26,7 @@
"author" : "Tiny",
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Production",
"depends" : ["stock", "resource", "purchase", "product","process"],
"depends" : ["mrp_procurement", "stock", "resource", "purchase", "product","process"],
"description": """
This is the base module to manage the manufacturing process in Open ERP.
@ -61,15 +61,11 @@
'mrp_workflow.xml',
'mrp_data.xml',
'wizard/mrp_product_produce_view.xml',
'wizard/make_procurement_view.xml',
'wizard/mrp_procurement_view.xml',
'wizard/change_production_qty_view.xml',
'wizard/orderpoint_procurement_view.xml',
'wizard/mrp_price_view.xml',
'wizard/mrp_workcenter_load_view.xml',
# 'wizard/mrp_track_prod_view.xml',
'mrp_view.xml',
'wizard/schedulers_all_view.xml',
'mrp_wizard.xml',
'mrp_report.xml',
'company_view.xml',
@ -81,6 +77,7 @@
'report/mrp_production_order_view.xml',
],
'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml'],
# 'test': ['test/mrp_phantom_bom.yml'],
'installable': True,
'active': False,
'certificate': '0032052481373',

View File

@ -24,22 +24,10 @@ from osv import osv,fields
class company(osv.osv):
_inherit = 'res.company'
_columns = {
'schedule_range': fields.float('Scheduler Range', required=True,
help="This is the time frame analysed by the scheduler when "\
"computing procurements. All procurements that are not between "\
"today and today+range are skipped for futur computation."),
'po_lead': fields.float('Purchase Lead Time', required=True,
help="This is the leads/security time for each purchase order."),
'security_lead': fields.float('Security Days', required=True,
help="This is the days added to what you promise to customers "\
"for security purpose"),
'manufacturing_lead': fields.float('Manufacturing Lead Time', required=True,
help="Security days for each manufacturing operation."),
}
_defaults = {
'schedule_range': lambda *a: 80.0,
'po_lead': lambda *a: 1.0,
'security_lead': lambda *a: 5.0,
'manufacturing_lead': lambda *a: 1.0,
}
company()

View File

@ -9,12 +9,7 @@
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<page string="Configuration" position="inside">
<separator string="MRP &amp; Logistic Scheduler" colspan="4"/>
<field name="schedule_range"/>
<field name="po_lead"/>
<field name="security_lead"/>
<field name="manufacturing_lead"/>
<newline/>
</page>
</field>
</record>

View File

@ -64,35 +64,6 @@ class mrp_workcenter(osv.osv):
mrp_workcenter()
class mrp_property_group(osv.osv):
"""
Group of mrp properties.
"""
_name = 'mrp.property.group'
_description = 'Property Group'
_columns = {
'name': fields.char('Property Group', size=64, required=True),
'description': fields.text('Description'),
}
mrp_property_group()
class mrp_property(osv.osv):
"""
Properties of mrp.
"""
_name = 'mrp.property'
_description = 'Property'
_columns = {
'name': fields.char('Name', size=64, required=True),
'composition': fields.selection([('min','min'),('max','max'),('plus','plus')], 'Properties composition', required=True, help="Not used in computations, for information purpose only."),
'group_id': fields.many2one('mrp.property.group', 'Property Group', required=True),
'description': fields.text('Description'),
}
_defaults = {
'composition': lambda *a: 'min',
}
mrp_property()
class mrp_routing(osv.osv):
"""
For specifying the routings of workcenters.
@ -996,520 +967,6 @@ class mrp_production_product_line(osv.osv):
}
mrp_production_product_line()
# ------------------------------------------------------------------
# Procurement
# ------------------------------------------------------------------
#
# Produce, Buy or Find products and place a move
# then wizard for picking lists & move
#
class mrp_procurement(osv.osv):
"""
Procument Orders
"""
_name = "mrp.procurement"
_description = "Procurement"
_order = 'priority,date_planned'
_columns = {
'name': fields.char('Reason', size=64, required=True, help='Procurement name.'),
'origin': fields.char('Source Document', size=64,
help="Reference of the document that created this Procurement.\n"
"This is automatically completed by Open ERP."),
'priority': fields.selection([('0','Not urgent'),('1','Normal'),('2','Urgent'),('3','Very Urgent')], 'Priority', required=True),
'date_planned': fields.datetime('Scheduled date', required=True),
'date_close': fields.datetime('Date Closed'),
'product_id': fields.many2one('product.product', 'Product', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'product_qty': fields.float('Quantity', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'product_uom': fields.many2one('product.uom', 'Product UoM', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'product_uos_qty': fields.float('UoS Quantity', states={'draft':[('readonly',False)]}, readonly=True),
'product_uos': fields.many2one('product.uom', 'Product UoS', states={'draft':[('readonly',False)]}, readonly=True),
'move_id': fields.many2one('stock.move', 'Reservation', ondelete='set null'),
'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True),
'close_move': fields.boolean('Close Move at end', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'procure_method': fields.selection([('make_to_stock','from stock'),('make_to_order','on order')], 'Procurement Method', states={'draft':[('readonly',False)], 'confirmed':[('readonly',False)]},
readonly=True, required=True, help="If you encode manually a Procurement, you probably want to use" \
" a make to order method."),
'purchase_id': fields.many2one('purchase.order', 'Purchase Order'),
'note': fields.text('Note'),
'property_ids': fields.many2many('mrp.property', 'mrp_procurement_property_rel', 'procurement_id','property_id', 'Properties'),
'message': fields.char('Latest error', size=64, help="Exception occurred while computing procurement orders."),
'state': fields.selection([
('draft','Draft'),
('confirmed','Confirmed'),
('exception','Exception'),
('running','Running'),
('cancel','Cancel'),
('ready','Ready'),
('done','Done'),
('waiting','Waiting')], 'State', required=True,
help='When a procurement is created the state is set to \'Draft\'.\n If the procurement is confirmed, the state is set to \'Confirmed\'.\
\nAfter confirming the state is set to \'Running\'.\n If any exception arises in the order then the state is set to \'Exception\'.\n Once the exception is removed the state becomes \'Ready\'.\n It is in \'Waiting\'. state when the procurement is waiting for another one to finish.'),
'note': fields.text('Note'),
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
'state': lambda *a: 'draft',
'priority': lambda *a: '1',
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'close_move': lambda *a: 0,
'procure_method': lambda *a: 'make_to_order',
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.procurement', context=c)
}
def unlink(self, cr, uid, ids, context=None):
procurements = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in procurements:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
""" Finds UoM and UoS of changed product.
@param product_id: Changed id of product.
@return: Dictionary of values.
"""
if product_id:
w = self.pool.get('product.product').browse(cr, uid, product_id, context)
v = {
'product_uom': w.uom_id.id,
'product_uos': w.uos_id and w.uos_id.id or w.uom_id.id
}
return {'value': v}
return {}
def check_product(self, cr, uid, ids):
""" Checks product type.
@return: True or False
"""
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.type in ('product', 'consu'):
return True
return False
def check_move_cancel(self, cr, uid, ids, context={}):
""" Checks if move is cancelled or not.
@return: True or False.
"""
res = True
ok = False
for procurement in self.browse(cr, uid, ids, context):
if procurement.move_id:
ok = True
if not procurement.move_id.state == 'cancel':
res = False
return res and ok
def check_move_done(self, cr, uid, ids, context={}):
""" Checks if move is done or not.
@return: True or False.
"""
res = True
for proc in self.browse(cr, uid, ids, context):
if proc.move_id:
if not proc.move_id.state == 'done':
res = False
return res
#
# This method may be overrided by objects that override mrp.procurment
# for computing their own purpose
#
def _quantity_compute_get(self, cr, uid, proc, context={}):
""" Finds sold quantity of product.
@param proc: Current procurement.
@return: Quantity or False.
"""
if proc.product_id.type == 'product':
if proc.move_id.product_uos:
return proc.move_id.product_uos_qty
return False
def _uom_compute_get(self, cr, uid, proc, context={}):
""" Finds UoS if product is Stockable Product.
@param proc: Current procurement.
@return: UoS or False.
"""
if proc.product_id.type == 'product':
if proc.move_id.product_uos:
return proc.move_id.product_uos.id
return False
#
# Return the quantity of product shipped/produced/served, wich may be
# different from the planned quantity
#
def quantity_get(self, cr, uid, id, context={}):
""" Finds quantity of product used in procurement.
@return: Quantity of product.
"""
proc = self.browse(cr, uid, id, context)
result = self._quantity_compute_get(cr, uid, proc, context)
if not result:
result = proc.product_qty
return result
def uom_get(self, cr, uid, id, context=None):
""" Finds UoM of product used in procurement.
@return: UoM of product.
"""
proc = self.browse(cr, uid, id, context)
result = self._uom_compute_get(cr, uid, proc, context)
if not result:
result = proc.product_uom.id
return result
def check_waiting(self, cr, uid, ids, context=[]):
""" Checks state of move.
@return: True or False
"""
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.move_id and procurement.move_id.state == 'auto':
return True
return False
def check_produce_service(self, cr, uid, procurement, context=[]):
return True
def check_produce_product(self, cr, uid, procurement, context=[]):
""" Finds BoM of a product if not found writes exception message.
@param procurement: Current procurement.
@return: True or False.
"""
properties = [x.id for x in procurement.property_ids]
bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties)
if not bom_id:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
return False
return True
def check_make_to_stock(self, cr, uid, ids, context={}):
""" Checks product type.
@return: True or False
"""
ok = True
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.type == 'service':
ok = ok and self._check_make_to_stock_service(cr, uid, procurement, context)
else:
ok = ok and self._check_make_to_stock_product(cr, uid, procurement, context)
return ok
def check_produce(self, cr, uid, ids, context={}):
""" Checks product type.
@return: True or Product Id.
"""
res = True
user = self.pool.get('res.users').browse(cr, uid, uid)
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.product_tmpl_id.supply_method <> 'produce':
if procurement.product_id.seller_ids:
partner = procurement.product_id.seller_ids[0].name
if user.company_id and user.company_id.partner_id:
if partner.id == user.company_id.partner_id.id:
return True
return False
if procurement.product_id.product_tmpl_id.type=='service':
res = res and self.check_produce_service(cr, uid, procurement, context)
else:
res = res and self.check_produce_product(cr, uid, procurement, context)
if not res:
return False
return res
def check_buy(self, cr, uid, ids):
""" Checks product type.
@return: True or Product Id.
"""
user = self.pool.get('res.users').browse(cr, uid, uid)
partner_obj = self.pool.get('res.partner')
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
return False
if not procurement.product_id.seller_ids:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id))
return False
partner = procurement.product_id.seller_ids[0].name
if user.company_id and user.company_id.partner_id:
if partner.id == user.company_id.partner_id.id:
return False
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
if not address_id:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id))
return False
return True
def test_cancel(self, cr, uid, ids):
""" Tests whether state of move is cancelled or not.
@return: True or False
"""
for record in self.browse(cr, uid, ids):
if record.move_id and record.move_id.state == 'cancel':
return True
return False
def action_confirm(self, cr, uid, ids, context={}):
""" Confirms procurement and writes exception message if any.
@return: True
"""
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.product_qty <= 0.00:
raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity of Procurement Order(s), it should not be less than 1!'))
if procurement.product_id.type in ('product', 'consu'):
if not procurement.move_id:
source = procurement.location_id.id
if procurement.procure_method == 'make_to_order':
source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
id = move_obj.create(cr, uid, {
'name': 'PROC:' + procurement.name,
'location_id': source,
'location_dest_id': procurement.location_id.id,
'product_id': procurement.product_id.id,
'product_qty': procurement.product_qty,
'product_uom': procurement.product_uom.id,
'date_planned': procurement.date_planned,
'state': 'confirmed',
'company_id': procurement.company_id.id,
})
self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
else:
# TODO: check this
if procurement.procure_method == 'make_to_stock' and procurement.move_id.state in ('waiting',):
id = move_obj.write(cr, uid, [procurement.move_id.id], {'state':'confirmed'})
self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
return True
def action_move_assigned(self, cr, uid, ids, context={}):
""" Changes procurement state to Running and writes message.
@return: True
"""
self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')})
return True
def _check_make_to_stock_service(self, cr, uid, procurement, context={}):
return True
def _check_make_to_stock_product(self, cr, uid, procurement, context={}):
""" Checks procurement move state.
@param procurement: Current procurement.
@return: True or move id.
"""
ok = True
if procurement.move_id:
id = procurement.move_id.id
if not (procurement.move_id.state in ('done','assigned','cancel')):
ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id])
cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,))
if not cr.fetchone()[0]:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('from stock and no minimum orderpoint rule defined'), procurement.id))
return ok
def action_produce_assign_service(self, cr, uid, ids, context={}):
""" Changes procurement state to Running.
@return: True
"""
for procurement in self.browse(cr, uid, ids):
self.write(cr, uid, [procurement.id], {'state': 'running'})
return True
def action_produce_assign_product(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign production order to procurements
@return: True
"""
res = self.make_mo(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
def make_mo(self, cr, uid, ids, context={}):
""" Make Manufecturing(production) order from procurement
@return: New created Production Orders procurement wise
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
production_obj = self.pool.get('mrp.production')
move_obj = self.pool.get('stock.move')
wf_service = netsvc.LocalService("workflow")
for procurement in self.browse(cr, uid, ids):
res_id = procurement.move_id.id
loc_id = procurement.location_id.id
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
newdate = newdate - DateTime.RelativeDateTime(days=company.manufacturing_lead)
produce_id = production_obj.create(cr, uid, {
'origin': procurement.origin,
'product_id': procurement.product_id.id,
'product_qty': procurement.product_qty,
'product_uom': procurement.product_uom.id,
'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False,
'product_uos': procurement.product_uos and procurement.product_uos.id or False,
'location_src_id': procurement.location_id.id,
'location_dest_id': procurement.location_id.id,
'bom_id': procurement.bom_id and procurement.bom_id.id or False,
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'move_prod_id': res_id,
'company_id': procurement.company_id.id,
})
res[procurement.id] = produce_id
self.write(cr, uid, [procurement.id], {'state': 'running'})
bom_result = production_obj.action_compute(cr, uid,
[produce_id], properties=[x.id for x in procurement.property_ids])
wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
move_obj.write(cr, uid, [res_id],
{'location_id': procurement.location_id.id})
return res
def action_po_assign(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign purchase order to procuments
@return: True
"""
res = self.make_po(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
def make_po(self, cr, uid, ids, context={}):
""" Make purchase order from procurement
@return: New created Purchase Orders procurement wise
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
partner_obj = self.pool.get('res.partner')
uom_obj = self.pool.get('product.uom')
pricelist_obj = self.pool.get('product.pricelist')
prod_obj = self.pool.get('product.product')
acc_pos_obj = self.pool.get('account.fiscal.position')
po_obj = self.pool.get('purchase.order')
for procurement in self.browse(cr, uid, ids):
res_id = procurement.move_id.id
partner = procurement.product_id.seller_ids[0].name
partner_id = partner.id
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
pricelist_id = partner.property_product_pricelist_purchase.id
uom_id = procurement.product_id.uom_po_id.id
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
if procurement.product_id.seller_ids[0].qty:
qty = max(qty,procurement.product_id.seller_ids[0].qty)
price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, False, {'uom': uom_id})[pricelist_id]
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
newdate = newdate - procurement.product_id.seller_ids[0].delay
#Passing partner_id to context for purchase order line integrity of Line name
context.update({'lang': partner.lang, 'partner_id': partner_id})
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
line = {
'name': product.partner_ref,
'product_qty': qty,
'product_id': procurement.product_id.id,
'product_uom': uom_id,
'price_unit': price,
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'move_dest_id': res_id,
'notes': product.description_purchase,
}
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
line.update({
'taxes_id': [(6,0,taxes)]
})
purchase_id = po_obj.create(cr, uid, {
'origin': procurement.origin,
'partner_id': partner_id,
'partner_address_id': address_id,
'location_id': procurement.location_id.id,
'pricelist_id': pricelist_id,
'order_line': [(0,0,line)],
'company_id': procurement.company_id.id,
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False
})
res[procurement.id] = purchase_id
self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': purchase_id})
return res
def action_cancel(self, cr, uid, ids):
""" Cancels procurement and writes move state to Assigned.
@return: True
"""
todo = []
todo2 = []
move_obj = self.pool.get('stock.move')
for proc in self.browse(cr, uid, ids):
if proc.close_move:
if proc.move_id.state not in ('done', 'cancel'):
todo2.append(proc.move_id.id)
else:
if proc.move_id and proc.move_id.state == 'waiting':
todo.append(proc.move_id.id)
if len(todo2):
move_obj.action_cancel(cr, uid, todo2)
if len(todo):
move_obj.write(cr, uid, todo, {'state': 'assigned'})
self.write(cr, uid, ids, {'state': 'cancel'})
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
return True
def action_check_finnished(self, cr, uid, ids):
return self.check_move_done(cr, uid, ids)
def action_check(self, cr, uid, ids):
""" Checks procurement move state whether assigned or done.
@return: True
"""
ok = False
for procurement in self.browse(cr, uid, ids):
if procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done':
self.action_done(cr, uid, [procurement.id])
ok = True
return ok
def action_ready(self, cr, uid, ids):
""" Changes procurement state to Ready.
@return: True
"""
res = self.write(cr, uid, ids, {'state': 'ready'})
return res
def action_done(self, cr, uid, ids):
""" Changes procurement state to Done and writes Closed date.
@return: True
"""
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.move_id:
if procurement.close_move and (procurement.move_id.state <> 'done'):
move_obj.action_done(cr, uid, [procurement.move_id.id])
res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
return res
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
''' Runs through scheduler.
@param use_new_cursor: False or the dbname
'''
if not context:
context={}
self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
use_new_cursor=use_new_cursor, context=context)
mrp_procurement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -31,18 +31,5 @@
<field name="number_increment">1</field>
</record>
<record forcecreate="True" id="ir_cron_scheduler_action" model="ir.cron">
<field name="name">Run mrp scheduler</field>
<field eval="False" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'mrp.procurement'" name="model"/>
<field eval="'run_scheduler'" name="function"/>
<field eval="'(False,)'" name="args"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,93 @@
# -*- 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 mx import DateTime
from osv import fields
from osv import osv
from tools.translate import _
import ir
import netsvc
import time
class mrp_procurement(osv.osv):
_inherit = 'mrp.procurement'
_columns = {
'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True),
}
def check_produce_product(self, cr, uid, procurement, context=[]):
properties = [x.id for x in procurement.property_ids]
bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties)
if not bom_id:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
return False
return True
def action_produce_assign_product(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign production order to procurements
@return: True
"""
procurement_obj = self.pool.get('mrp.procurement')
res = procurement_obj.make_mo(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
def make_mo(self, cr, uid, ids, context={}):
""" Make Manufacturing(production) order from procurement
@return: New created Production Orders procurement wise
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
production_obj = self.pool.get('mrp.production')
move_obj = self.pool.get('stock.move')
wf_service = netsvc.LocalService("workflow")
procurement_obj = self.pool.get('mrp.procurement')
for procurement in procurement_obj.browse(cr, uid, ids):
res_id = procurement.move_id.id
loc_id = procurement.location_id.id
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
newdate = newdate - DateTime.RelativeDateTime(days=company.manufacturing_lead)
produce_id = production_obj.create(cr, uid, {
'origin': procurement.origin,
'product_id': procurement.product_id.id,
'product_qty': procurement.product_qty,
'product_uom': procurement.product_uom.id,
'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False,
'product_uos': procurement.product_uos and procurement.product_uos.id or False,
'location_src_id': procurement.location_id.id,
'location_dest_id': procurement.location_id.id,
'bom_id': procurement.bom_id and procurement.bom_id.id or False,
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'move_prod_id': res_id,
'company_id': procurement.company_id.id,
})
res[procurement.id] = produce_id
self.write(cr, uid, [procurement.id], {'state': 'running'})
bom_result = production_obj.action_compute(cr, uid,
[produce_id], properties=[x.id for x in procurement.property_ids])
wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
move_obj.write(cr, uid, [res_id],
{'location_id': procurement.location_id.id})
return res
mrp_procurement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -4,92 +4,11 @@
<menuitem icon="terp-mrp" id="base.menu_mrp_root" name="Manufacturing"
groups="group_mrp_user,group_mrp_manager" sequence="3"/>
<menuitem id="menu_mrp_reordering" name="Automatic Procurements" parent="stock.menu_stock_root" sequence="4"/>
<menuitem id="menu_mrp_manufacturing" name="Manufacturing" parent="base.menu_mrp_root" sequence="1"/>
<menuitem name="Control" id="menu_mrp_control" parent="base.menu_mrp_root" sequence="3" />
<menuitem id="menu_mrp_manufacturing" name="Manufacturing" parent="base.menu_mrp_root" sequence="1"/>
<menuitem name="Master Data"
id="menu_mrp_bom"
parent="base.menu_mrp_root"
sequence="5" />
<!--
Property / Property Group
-->
<record id="mrp_property_group_form_view" model="ir.ui.view">
<field name="name">mrp.property.group.form</field>
<field name="model">mrp.property.group</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Properties categories">
<separator colspan="4" string="General Information"/>
<field colspan="4" name="name" select="1"/>
<field colspan="4" name="description"/>
</form>
</field>
</record>
<record id="mrp_property_group_action" model="ir.actions.act_window">
<field name="name">Property Categories</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.property.group</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
id="menu_mrp_configuration"
name="Configuration"
parent="base.menu_mrp_root"
groups="base.group_extended"
sequence="50" />
<record id="mrp_property_tree_view" model="ir.ui.view">
<field name="name">mrp.property.tree</field>
<field name="model">mrp.property</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Properties">
<field name="name"/>
<field name="composition"/>
<field name="group_id"/>
</tree>
</field>
</record>
<record id="mrp_property_form_view" model="ir.ui.view">
<field name="name">mrp.property.form</field>
<field name="model">mrp.property</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Properties">
<separator colspan="4" string="General Information"/>
<field colspan="4" name="name" select="1"/>
<field name="group_id" select="1"/>
<field name="composition" select="1"/>
<separator colspan="4" string="Description"/>
<field colspan="4" name="description"/>
</form>
</field>
</record>
<record id="mrp_property_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.property</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Properties"
id="menu_mrp_property"
parent="menu_mrp_configuration"
groups="base.group_extended"
sequence="20" />
<menuitem
action="mrp_property_action"
id="menu_mrp_property_action"
parent="menu_mrp_property"
groups="base.group_extended" />
<menuitem
action="mrp_property_group_action"
id="menu_mrp_property_group_action"
parent="menu_mrp_property"/>
<!--
Work Centers
@ -765,259 +684,22 @@
</tree>
</field>
</record>
<!--
Procurement
<!--
Procurements
-->
<record id="mrp_procurement_tree_view" model="ir.ui.view">
<field name="name">mrp.procurement.tree</field>
<field name="model">mrp.procurement</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Procurement Lines" colors="red:state=='draft';black:state=='running';green:state=='confirmed';gray:state in ['done','cancel']">
<field name="date_planned" widget="date"/>
<field name="origin"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom" string="UOM"/>
<field name="procure_method"/>
<field name="state"/>
</tree>
</field>
<record id="view_procurement_form_inherit" model="ir.ui.view">
<field name="name">mrp.procurement.form.inherit</field>
<field name="model">mrp.procurement</field>
<field name="inherit_id" ref="mrp_procurement.mrp_procurement_form_view"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='move_id']" position="before">
<field name="bom_id" domain="[('product_id','=',product_id),('bom_id','=',False)]"/>
</xpath>
</field>
</record>
<record id="mrp_procurement_form_view" model="ir.ui.view">
<field name="name">mrp.procurement.form</field>
<field name="model">mrp.procurement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Procurement">
<group col="2" colspan="2">
<separator colspan="2" string="References"/>
<field name="name" select="1" string="Procurement Reason"/>
<field name="origin"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Planification"/>
<field name="date_planned" select="1"/>
<field name="procure_method"/>
<field name="priority" groups="base.group_extended"/>
</group>
<notebook colspan="4">
<page string="Procurement Details">
<separator colspan="4" string="Product &amp; Location"/>
<field name="product_id" select="1" on_change="onchange_product_id(product_id)"/>
<field name="location_id" domain="[('usage','=','internal')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="product_uos_qty" groups="product.group_uos"/>
<field name="product_uos" groups="product.group_uos"/>
<separator colspan="4" string="Status"/>
<field colspan="4" name="message" readonly="1"/>
<field name="state" readonly="1"/>
<group col="7" colspan="2">
<button name="button_confirm" states="draft" string="Confirm" icon="gtk-apply"/>
<button name="button_restart" states="exception" string="Retry" icon="gtk-convert"/>
<button name="button_cancel" states="draft,exception,waiting" string="Cancel" icon="gtk-cancel"/>
<button name="button_check" states="confirmed" string="Run Procurement" icon="gtk-media-play"/>
</group>
</page>
<page string="Extra Information">
<separator colspan="4" string="Details"/>
<field name="bom_id" domain="[('product_id','=',product_id),('bom_id','=',False)]"/>
<field name="move_id" groups="base.group_extended"/>
<field name="date_close"/>
<field name="close_move" groups="base.group_extended"/>
<field name="purchase_id"/>
<group colspan="4" groups="base.group_extended">
<separator colspan="4" string="Properties" />
<field colspan="4" name="property_ids" nolabel="1"/>
</group>
</page>
<page string="Notes">
<separator colspan="4" string="Note" />
<field name="note" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="view_mrp_procurement_filter" model="ir.ui.view">
<field name="name">mrp.procurement.select</field>
<field name="model">mrp.procurement</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Procurement">
<group col='10' colspan='4'>
<filter icon="terp-mrp" string="Current" domain="[('state','in',('draft','confirmed'))]" default="1" help="Procurement Orders in draft or open state."/>
<filter icon="terp-mrp" string="Exceptions" domain="[('state','=','exception')]" help="Procurement Orders with exceptions"/>
<filter icon="terp-mrp" string="Late"
domain="['&amp;', ('date_planned::date','&lt;', current_date), ('state', 'in', ('draft', 'confirmed'))]"
help="Procurement started late" />
<separator orientation="vertical"/>
<field name="name"/>
<field name="origin"/>
<field name="product_id" />
<field name="date_planned" widget="date"/>
<field name="state" />
</group>
<newline/>
<group expand="1" string="Group By" colspan="4" col="8">
<filter string="Product" icon="terp-mrp" domain="[]" context="{'group_by':'product_id'}"/>
<filter string="Reason" icon="terp-mrp" domain="[]" context="{'group_by':'name'}"/>
<filter string="Scheduled Date" icon="terp-mrp" domain="[]" context="{'group_by':'date_planned'}"/>
</group>
</search>
</field>
</record>
<record id="mrp_procurement_action" model="ir.actions.act_window">
<field name="name">Procurement Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_id" eval="False"/>
<field name="search_view_id" ref="view_mrp_procurement_filter"/>
</record>
<menuitem action="mrp_procurement_action" id="menu_mrp_procurement_action" parent="mrp.menu_mrp_manufacturing"
sequence="2" />
<record id="mrp_procurement_action3" model="ir.actions.act_window">
<field name="name">Procurements</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_mrp_procurement_filter"/>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
<record id="mrp_procurement_action5" model="ir.actions.act_window">
<field name="name">Procurement Exceptions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','exception')]</field>
</record>
<menuitem action="mrp_procurement_action5" id="menu_mrp_procurement_exception_action" parent="mrp.menu_mrp_control"
sequence="1" />
<record id="mrp_procurement_action4" model="ir.actions.act_window">
<field name="name">Procurement Exceptions to Fix</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','exception'), ('message', '&lt;&gt;', '')]</field>
<field name="filter" eval="True"/>
</record>
<record id="mrp_procurement_action11" model="ir.actions.act_window">
<field name="name">Temporary Procurement Exceptions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','exception'), ('message', '=', '')]</field>
</record>
<!-- Order Point -->
<record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.tree</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Minimum Stock Rules">
<field name="name"/>
<field name="warehouse_id"/>
<field name="location_id"/>
<field name="product_id"/>
<field name="product_uom"/>
<field name="product_min_qty"/>
<field name="product_max_qty"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="warehouse_orderpoint_search">
<field name="name">stock.warehouse.orderpoint.search</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Minimum Stock Rules Search">
<group col="10" colspan="4">
<field name="name" select="1" />
<field name="warehouse_id" select="1" widget="selection"/>
<field name="location_id" select="1" />
<field name="company_id" select="1" widget="selection"/>
<field name="product_id" select="1"/>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="4" col="10">
<filter string="Warehouse" icon="terp-stock" domain="[]" context="{'group_by':'warehouse_id'}"/>
<filter string="Location" icon="terp-stock" domain="[]" context="{'group_by':'location_id'}"/>
</group>
</search>
</field>
</record>
<record id="view_warehouse_orderpoint_form" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.form</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Minimum Stock Rules">
<group col="2" colspan="2">
<separator string="General Information" colspan="2" />
<field name="name" />
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="product_uom"/>
</group>
<group col="2" colspan="2">
<separator string="Locations" colspan="2" />
<field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection"/>
<field name="location_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<group col="2" colspan="2">
<separator string="Quantity Rules" colspan="2" />
<field name="product_min_qty"/>
<field name="product_max_qty"/>
<field name="qty_multiple"/>
</group>
<group col="2" colspan="2" groups="base.group_extended">
<separator string="Misc" colspan="2" />
<field name="procurement_id" readonly="1"/>
<field name="active" />
</group>
</form>
</field>
</record>
<record id="action_orderpoint_form" model="ir.actions.act_window">
<field name="name">Minimum Stock Rules</field>
<field name="res_model">stock.warehouse.orderpoint</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_warehouse_orderpoint_tree"/>
<field name="search_view_id" ref="warehouse_orderpoint_search" />
</record>
<menuitem action="action_orderpoint_form" id="menu_action_orderpoint_form" parent="menu_mrp_reordering"/>
<act_window domain="[('warehouse_id', '=', active_id)]" id="act_stock_warehouse_2_stock_warehouse_orderpoint" name="Minimum Stock Rules" res_model="stock.warehouse.orderpoint" src_model="stock.warehouse"/>
<!-- add product_uom to context to be the default value when adding new orderpoints -->
<act_window
context="{'product_uom': locals().has_key('uom_id') and uom_id}"
domain="[('product_id', '=', active_id)]"
id="act_product_product_2_stock_warehouse_orderpoint"
name="Minimum Stock Rules"
res_model="stock.warehouse.orderpoint"
src_model="product.product"/>
<act_window
id="action_product_bom_structure"

View File

@ -113,241 +113,34 @@
<field name="act_to" ref="prod_act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<!-- Procurement -->
<record id="wkf" model="workflow">
<field name="name">mrp.procurement.basic</field>
<field name="osv">mrp.procurement</field>
<field name="on_create">True</field>
</record>
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<record id="act_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">cancel</field>
<field name="kind">function</field>
<field name="action">action_cancel()</field>
<field name="flow_stop">True</field>
</record>
<record id="act_confirm" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">confirm</field>
<field name="kind">function</field>
<field name="action">action_confirm()</field>
</record>
<record id="act_confirm_wait" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">confirm_wait</field>
<field name="kind">function</field>
<field name="action">write({'state':'exception'})</field>
</record>
<record id="act_confirm_mts" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">confirm_mts</field>
</record>
<record id="act_confirm_mto" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">confirm_mto</field>
</record>
<record id="act_make_to_stock" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">make_to_stock</field>
<field name="kind">function</field>
<field name="action">action_move_assigned()</field>
</record>
<record id="act_produce" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="wkf_id" ref="mrp_procurement.wkf_procurement"/>
<field name="name">produce</field>
<field name="kind">subflow</field>
<field name="subflow_id" search="[('osv','=','mrp.production')]"/>
<field name="action">action_produce_assign_product()</field>
</record>
<record id="act_produce_check" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">produce_check</field>
</record>
<record id="act_produce_service" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">produce_service</field>
<field name="kind">function</field>
<field name="action">action_produce_assign_service()</field>
</record>
<record id="act_buy" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">buy</field>
<field name="kind">subflow</field>
<field name="subflow_id" search="[('osv','=','purchase.order')]"/>
<field name="action">action_po_assign()</field>
</record>
<record id="act_make_done" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">ready</field>
<field name="kind">function</field>
<field name="action">action_ready()</field>
</record>
<record id="act_wait_done" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">wait_done</field>
<field name="kind">function</field>
<field name="action">write({'state':'waiting'})</field>
</record>
<record id="act_done" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="flow_stop">True</field>
<field name="name">done</field>
<field name="kind">function</field>
<field name="action">action_done()</field>
</record>
<record id="trans_draft_confirm" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_confirm"/>
<field name="signal">button_confirm</field>
</record>
<record id="trans_confirm_cancel2" model="workflow.transition">
<field name="act_from" ref="act_confirm"/>
<field name="act_to" ref="act_wait_done"/>
<field name="signal">button_wait_done</field>
<field name="condition">True</field>
</record>
<record id="trans_confirm_wait_done" model="workflow.transition">
<field name="act_from" ref="act_wait_done"/>
<field name="act_to" ref="act_done"/>
<field name="condition">check_move_done()</field>
<field name="trigger_model">stock.move</field>
<field name="trigger_expr_id">[move_id.id]</field>
</record>
<record id="trans_confirm_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirm"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_check</field>
<field name="condition">test_cancel()</field>
</record>
<record id="trans_confirm_confirm_wait" model="workflow.transition">
<field name="act_from" ref="act_confirm"/>
<field name="act_to" ref="act_confirm_wait"/>
<field name="signal">button_check</field>
<field name="condition">not test_cancel()</field>
</record>
<record id="trans_confirm_wait_confirm_mto" model="workflow.transition">
<field name="act_from" ref="act_confirm_wait"/>
<field name="act_to" ref="act_confirm_mto"/>
<field name="condition">procure_method=='make_to_order'</field>
</record>
<record id="trans_confirm_wait_confirm_mts" model="workflow.transition">
<field name="act_from" ref="act_confirm_wait"/>
<field name="act_to" ref="act_confirm_mts"/>
<field name="condition">procure_method=='make_to_stock'</field>
</record>
<record id="trans_confirm_mts_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirm_mts"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_waiting_cancel" model="workflow.transition">
<field name="act_from" ref="act_wait_done"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mts_confirm" model="workflow.transition">
<field name="act_from" ref="act_confirm_mts"/>
<field name="act_to" ref="act_confirm"/>
<field name="signal">button_restart</field>
</record>
<record id="trans_confirm_mto_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mto_confirm" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_confirm"/>
<field name="signal">button_restart</field>
</record>
<record id="trans_draft_cancel" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mts_make_to_stock" model="workflow.transition">
<field name="act_from" ref="act_confirm_mts"/>
<field name="act_to" ref="act_make_to_stock"/>
<field name="condition">check_make_to_stock()</field>
</record>
<record id="trans_confirm_mto_produce_check" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_produce_check"/>
<field name="condition">check_produce()</field>
</record>
<record id="trans_product_check_produce" model="workflow.transition">
<field name="act_from" ref="act_produce_check"/>
<field name="act_from" ref="mrp_procurement.act_produce_check"/>
<field name="act_to" ref="act_produce"/>
<field name="condition">check_product()</field>
</record>
<record id="trans_product_check_produce_service" model="workflow.transition">
<field name="act_from" ref="act_produce_check"/>
<field name="act_to" ref="act_produce_service"/>
<field name="condition">not check_product()</field>
</record>
<record id="trans_confirm_mto_buy" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_buy"/>
<field name="condition">check_buy()</field>
</record>
<record id="trans_make_to_stock_make_done" model="workflow.transition">
<field name="act_from" ref="act_make_to_stock"/>
<field name="act_to" ref="act_make_done"/>
<field name="condition">True</field>
<field name="trigger_model" eval="False"/>
<field name="trigger_expr_id" eval="False"/>
</record>
<record id="trans_produce_cancel" model="workflow.transition">
<field name="act_from" ref="act_produce"/>
<field name="act_to" ref="act_cancel"/>
<field name="act_to" ref="mrp_procurement.act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_produce_service_cancel" model="workflow.transition">
<field name="act_from" ref="act_produce_service"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_buy_cancel" model="workflow.transition">
<field name="act_from" ref="act_buy"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_produce_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce"/>
<field name="act_to" ref="act_make_done"/>
<field name="act_to" ref="mrp_procurement.act_make_done"/>
<field name="signal">subflow.done</field>
</record>
<record id="trans_produce_service_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce_service"/>
<field name="act_to" ref="act_make_done"/>
</record>
<record id="trans_buy_make_done" model="workflow.transition">
<field name="act_from" ref="act_buy"/>
<field name="act_to" ref="act_make_done"/>
<field name="signal">subflow.delivery_done</field>
</record>
<record id="trans_make_done_done" model="workflow.transition">
<field name="act_from" ref="act_make_done"/>
<field name="act_to" ref="act_done"/>
<field name="condition">action_check_finnished()</field>
</record>
<record id="trans_make_done_confirm" model="workflow.transition">
<field name="act_from" ref="act_make_done"/>
<field name="act_to" ref="act_cancel"/>
<field name="condition">check_move_cancel()</field>
</record>
</data>
</openerp>

View File

@ -2,114 +2,100 @@
<openerp>
<data>
<!--
Process
-->
<record id="process_process_procurementprocess0" model="process.process">
<field eval="&quot;&quot;&quot;Procurement&quot;&quot;&quot;" name="name"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="1" name="active"/>
</record>
<!--
Process Node
-->
<record id="process_node_stockproduct1" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;For stockable products and consumables&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Stockable Product&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="mrp.process_process_stockableproductprocess0"/>
<field name="subflow_id" ref="process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_serviceproduct1" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;For Services.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Service&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="mrp.process_process_serviceproductprocess0"/>
<field name="subflow_id" ref="process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_productionorder0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_production_action"/>
<field name="model_id" ref="mrp.model_mrp_production"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Drives the procurement orders for raw material.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Production Order&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="process_process_procurementprocess0"/>
<field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'picking_except', 'confirmed', 'ready', 'in_production', 'cancel', 'done')&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_minimumstockrule0" model="process.node">
<field name="menu_id" ref="mrp.menu_action_orderpoint_form"/>
<field name="model_id" ref="mrp.model_stock_warehouse_orderpoint"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Linked to the 'Minimum stock rule' supplying method.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Minimum Stock&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="process_process_procurementprocess0"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_procureproducts0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;The way to procurement depends on the product type.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Procure Products&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="process_process_procurementprocess0"/>
<field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="0" name="flow_start"/>
</record>
<record id="process_node_minimumstockrule0" model="process.node">
<field name="menu_id" ref="mrp_procurement.menu_action_orderpoint_form"/>
<field name="model_id" ref="mrp_procurement.model_stock_warehouse_orderpoint"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Linked to the 'Minimum stock rule' supplying method.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Minimum Stock&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_stockproduct0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Product type is Stockable or Consumable.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Stockable Product&quot;&quot;&quot;" name="name"/>
<field name="subflow_id" ref="process_process_stockableproductprocess0"/>
<field name="process_id" ref="process_process_procurementprocess0"/>
<field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="0" name="flow_start"/>
</record>
<record id="process_node_stockproduct1" model="process.node">
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;For stockable products and consumables&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Stockable Product&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="mrp.process_process_stockableproductprocess0"/>
<field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_serviceproduct0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Product type is service&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Service&quot;&quot;&quot;" name="name"/>
<field name="subflow_id" ref="process_process_serviceproductprocess0"/>
<field name="process_id" ref="process_process_procurementprocess0"/>
<field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="0" name="flow_start"/>
</record>
<record id="process_node_serviceproduct1" model="process.node">
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;For Services.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Service&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="mrp.process_process_serviceproductprocess0"/>
<field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_purchaseprocure0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Procurement Orders&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;For purchased material&quot;&quot;&quot;" name="note"/>
<field name="subflow_id" ref="process_process_procurementprocess0"/>
<field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field name="process_id" ref="purchase.process_process_purchaseprocess0"/>
<field eval="1" name="flow_start"/>
</record>
<record id="process_node_productminimumstockrule0" model="process.node">
<field name="menu_id" ref="mrp.menu_action_orderpoint_form"/>
<field name="model_id" ref="mrp.model_stock_warehouse_orderpoint"/>
<field name="menu_id" ref="mrp_procurement.menu_action_orderpoint_form"/>
<field name="model_id" ref="mrp_procurement.model_stock_warehouse_orderpoint"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Minimum Stock&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Automatic procurement rule&quot;&quot;&quot;" name="note"/>

View File

@ -17,7 +17,7 @@
-->
<record id="process_node_serviceonorder0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Assignment from Production or Purchase Order.&quot;&quot;&quot;" name="note"/>
@ -28,7 +28,7 @@
</record>
<record id="process_node_servicemts0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Assignment from stock.&quot;&quot;&quot;" name="note"/>

View File

@ -17,7 +17,7 @@
-->
<record id="process_node_mts0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Assignment from stock.&quot;&quot;&quot;" name="note"/>
@ -28,7 +28,7 @@
</record>
<record id="process_node_stock0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Assignment from Production or Purchase Order.&quot;&quot;&quot;" name="note"/>

View File

@ -1,7 +1,5 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_mrp_workcenter","mrp.workcenter","model_mrp_workcenter","mrp.group_mrp_user",1,0,0,0
"access_mrp_property_group","mrp.property.group","model_mrp_property_group","mrp.group_mrp_user",1,0,0,0
"access_mrp_property","mrp.property","model_mrp_property","mrp.group_mrp_user",1,0,0,0
"access_mrp_routing","mrp.routing","model_mrp_routing","mrp.group_mrp_user",1,0,0,0
"access_mrp_routing_workcenter","mrp.routing.workcenter","model_mrp_routing_workcenter","mrp.group_mrp_user",1,0,0,0
"access_mrp_bom","mrp.bom","model_mrp_bom","mrp.group_mrp_user",1,0,0,0
@ -10,11 +8,7 @@
"access_mrp_production_workcenter_line","mrp.production.workcenter.line","model_mrp_production_workcenter_line","mrp.group_mrp_user",1,1,1,1
"access_mrp_production_product_line","mrp.production.product.line","model_mrp_production_product_line","mrp.group_mrp_user",1,1,1,1
"access_mrp_procurement","mrp.procurement","model_mrp_procurement","mrp.group_mrp_user",1,1,1,1
"access_stock_warehouse_orderpoint","stock.warehouse.orderpoint","model_stock_warehouse_orderpoint","mrp.group_mrp_user",1,0,0,0
"access_stock_warehouse_orderpoint_manager","stock.warehouse.orderpoint.manager","model_stock_warehouse_orderpoint","mrp.group_mrp_manager",1,1,1,1
"access_mrp_workcenter_manager","mrp.workcenter.manager","model_mrp_workcenter","mrp.group_mrp_user",1,1,1,1
"access_mrp_property_group_manager","mrp.property.group.manager","model_mrp_property_group","mrp.group_mrp_user",1,1,1,1
"access_mrp_property_manager","mrp.property.manager","model_mrp_property","mrp.group_mrp_user",1,1,1,1
"access_mrp_routing_manager","mrp.routing.manager","model_mrp_routing","mrp.group_mrp_manager",1,1,1,1
"access_mrp_routing_workcenter_manager","mrp.routing.workcenter.manager","model_mrp_routing_workcenter","mrp.group_mrp_manager",1,1,1,1
"access_mrp_bom_manager","mrp.bom.manager","model_mrp_bom","mrp.group_mrp_manager",1,1,1,1
@ -32,10 +26,7 @@
"access_mrp_production_stock_worker","mrp.production stock_worker","model_mrp_production","stock.group_stock_user",1,0,0,0
"access_mrp_installer","mrp.installer","model_mrp_installer","mrp.group_mrp_user",1,0,0,0
"access_mrp_product_produce","mrp.product.produce","model_mrp_product_produce","mrp.group_mrp_user",1,0,0,0
"access_mrp_make_procurement","make.procurement","model_make_procurement","mrp.group_mrp_user",1,0,0,0
"access_mrp_change_production_qty","change.production.qty","model_change_production_qty","mrp.group_mrp_user",1,0,0,0
"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all","mrp.group_mrp_user",1,0,0,0
"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute","mrp.group_mrp_user",1,0,0,0
"access_mrp_production_order","mrp.production.order","model_mrp_production_order","mrp.group_mrp_user",1,0,0,0
"access_report_workcenter_load","report.workcenter.load","model_report_workcenter_load","mrp.group_mrp_manager",1,0,0,0
"access_report_mrp_inout","report.mrp.inout","model_report_mrp_inout","mrp.group_mrp_manager",1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_mrp_workcenter mrp.workcenter model_mrp_workcenter mrp.group_mrp_user 1 0 0 0
access_mrp_property_group mrp.property.group model_mrp_property_group mrp.group_mrp_user 1 0 0 0
access_mrp_property mrp.property model_mrp_property mrp.group_mrp_user 1 0 0 0
3 access_mrp_routing mrp.routing model_mrp_routing mrp.group_mrp_user 1 0 0 0
4 access_mrp_routing_workcenter mrp.routing.workcenter model_mrp_routing_workcenter mrp.group_mrp_user 1 0 0 0
5 access_mrp_bom mrp.bom model_mrp_bom mrp.group_mrp_user 1 0 0 0
8 access_mrp_production_workcenter_line mrp.production.workcenter.line model_mrp_production_workcenter_line mrp.group_mrp_user 1 1 1 1
9 access_mrp_production_product_line mrp.production.product.line model_mrp_production_product_line mrp.group_mrp_user 1 1 1 1
10 access_mrp_procurement mrp.procurement model_mrp_procurement mrp.group_mrp_user 1 1 1 1
access_stock_warehouse_orderpoint stock.warehouse.orderpoint model_stock_warehouse_orderpoint mrp.group_mrp_user 1 0 0 0
access_stock_warehouse_orderpoint_manager stock.warehouse.orderpoint.manager model_stock_warehouse_orderpoint mrp.group_mrp_manager 1 1 1 1
11 access_mrp_workcenter_manager mrp.workcenter.manager model_mrp_workcenter mrp.group_mrp_user 1 1 1 1
access_mrp_property_group_manager mrp.property.group.manager model_mrp_property_group mrp.group_mrp_user 1 1 1 1
access_mrp_property_manager mrp.property.manager model_mrp_property mrp.group_mrp_user 1 1 1 1
12 access_mrp_routing_manager mrp.routing.manager model_mrp_routing mrp.group_mrp_manager 1 1 1 1
13 access_mrp_routing_workcenter_manager mrp.routing.workcenter.manager model_mrp_routing_workcenter mrp.group_mrp_manager 1 1 1 1
14 access_mrp_bom_manager mrp.bom.manager model_mrp_bom mrp.group_mrp_manager 1 1 1 1
26 access_mrp_production_stock_worker mrp.production stock_worker model_mrp_production stock.group_stock_user 1 0 0 0
27 access_mrp_installer mrp.installer model_mrp_installer mrp.group_mrp_user 1 0 0 0
28 access_mrp_product_produce mrp.product.produce model_mrp_product_produce mrp.group_mrp_user 1 0 0 0
access_mrp_make_procurement make.procurement model_make_procurement mrp.group_mrp_user 1 0 0 0
29 access_mrp_change_production_qty change.production.qty model_change_production_qty mrp.group_mrp_user 1 0 0 0
access_mrp_procurement_compute_all mrp.procurement.compute.all model_mrp_procurement_compute_all mrp.group_mrp_user 1 0 0 0
access_mrp_procurement_orderpoint_compute mrp.procurement.orderpoint.compute model_mrp_procurement_orderpoint_compute mrp.group_mrp_user 1 0 0 0
30 access_mrp_production_order mrp.production.order model_mrp_production_order mrp.group_mrp_user 1 0 0 0
31 access_report_workcenter_load report.workcenter.load model_report_workcenter_load mrp.group_mrp_manager 1 0 0 0
32 access_report_mrp_inout report.mrp.inout model_report_mrp_inout mrp.group_mrp_manager 1 0 0 0

View File

@ -11,36 +11,11 @@
<!-- restrict access to menu -->
<record model='ir.ui.menu' id="mrp_Sched_all">
<record model='ir.ui.menu' id="mrp_procurement.mrp_Sched_all">
<field eval="[(6,0,[ref('group_mrp_manager')])]" name="groups_id"/>
</record>
<!-- Multi -->
<record model="ir.rule.group" id="mrp_procurement_rule_group">
<field name="name">mrp_procurement multi-company</field>
<field name="model_id" search="[('model','=','mrp.procurement')]" model="ir.model"/>
<field name="global" eval="True"/>
</record>
<record model="ir.rule" id="mrp_procurement_rule">
<field model="ir.model.fields" name="field_id" search="[('model','=','mrp.procurement'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
<field name="rule_group" ref="mrp_procurement_rule_group"/>
</record>
<record model="ir.rule.group" id="stock_warehouse_orderpoint_rule_group">
<field name="name">stock_warehouse.orderpoint multi-company</field>
<field name="model_id" search="[('model','=','stock.warehouse.orderpoint')]" model="ir.model"/>
<field name="global" eval="True"/>
</record>
<record model="ir.rule" id="stock_warehouse_orderpoint_rule">
<field model="ir.model.fields" name="field_id" search="[('model','=','stock.warehouse.orderpoint'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
<field name="rule_group" ref="stock_warehouse_orderpoint_rule_group"/>
</record>
<record model="ir.rule.group" id="mrp_production_rule_group">
<field name="name">mrp_production multi-company</field>

View File

@ -27,74 +27,6 @@ import ir
import netsvc
import time
class stock_warehouse_orderpoint(osv.osv):
"""
Defines Minimum stock rules.
"""
_name = "stock.warehouse.orderpoint"
_description = "Orderpoint minimum rule"
_columns = {
'name': fields.char('Name', size=32, required=True),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."),
'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type','=','product')]),
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True ),
'product_min_qty': fields.float('Min Quantity', required=True,
help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
"a procurement to bring the virtual stock to the Max Quantity."),
'product_max_qty': fields.float('Max Quantity', required=True,
help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
"a procurement to bring the virtual stock to the Max Quantity."),
'qty_multiple': fields.integer('Qty Multiple', required=True,
help="The procurement quantity will by rounded up to this multiple."),
'procurement_id': fields.many2one('mrp.procurement', 'Latest procurement'),
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
'active': lambda *a: 1,
'logic': lambda *a: 'max',
'qty_multiple': lambda *a: 1,
'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '',
'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)
}
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
""" Finds location id for changed warehouse.
@param warehouse_id: Changed id of warehouse.
@return: Dictionary of values.
"""
if warehouse_id:
w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context)
v = {'location_id': w.lot_stock_id.id}
return {'value': v}
return {}
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
""" Finds UoM for changed product.
@param product_id: Changed id of product.
@return: Dictionary of values.
"""
if product_id:
prod = self.pool.get('product.product').browse(cr,uid,product_id)
v = {'product_uom': prod.uom_id.id}
return {'value': v}
return {}
def copy(self, cr, uid, id, default=None,context={}):
if not default:
default = {}
default.update({
'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '',
})
return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context)
stock_warehouse_orderpoint()
class StockMove(osv.osv):
_inherit = 'stock.move'

View File

@ -0,0 +1,228 @@
-
In order to test the mrp phantom bom type in OpenERP, I will create products
and then I will create Phantom bom structure for those products.
-
I create the products required to produce some orange juices: Oranges, Sugar and Water.
-
!record {model: product.uom, id: product_uom_litre0}:
category_id: product.product_uom_categ_kgm
factor: 1.0
name: Litre
rounding: 0.01
-
!record {model: product.product, id: product_product_orangejuice0}:
categ_id: product.cat1
name: Orange Juice
procure_method: make_to_order
supply_method: produce
type: product
uom_id: product_uom_litre0
uom_po_id: product_uom_litre0
-
!record {model: product.product, id: product_product_orange0}:
categ_id: product.cat1
name: Orange
procure_method: make_to_stock
seller_ids:
- delay: 1
name: base.res_partner_asus
qty: 1.0
supply_method: buy
type: product
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
-
!record {model: product.product, id: product_product_sugar0}:
categ_id: product.cat1
name: Sugar
procure_method: make_to_stock
seller_ids:
- delay: 1
name: base.res_partner_desertic_hispafuentes
qty: 2.0
supply_method: buy
type: product
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
-
!record {model: product.product, id: product_product_water0}:
categ_id: product.cat1
name: Water
procure_method: make_to_stock
supply_method: buy
type: consu
uom_id: product_uom_litre0
uom_po_id: product_uom_litre0
-
I define the BoM to produce an orange juice
-
!record {model: mrp.bom, id: mrp_bom_orangejuice0}:
company_id: base.main_company
name: Orange Juice
product_efficiency: 1.0
product_id: product_product_orangejuice0
product_qty: 1.0
product_uom: product_uom_litre0
type: phantom
-
!record {model: mrp.bom, id: mrp_bom_orangejuice0}:
bom_lines:
- bom_id: mrp_bom_orangejuice0
company_id: base.main_company
name: Orange
product_efficiency: 1.0
product_id: product_product_orange0
product_qty: 0.5
product_uom: product.product_uom_kgm
type: normal
- bom_id: mrp_bom_orangejuice0
company_id: base.main_company
name: Sugar
product_efficiency: 1.0
product_id: product_product_sugar0
product_qty: 0.02
product_uom: product.product_uom_kgm
type: normal
- bom_id: mrp_bom_orangejuice0
company_id: base.main_company
name: Water
product_efficiency: 1.0
product_id: product_product_water0
product_qty: 0.80000000000000004
product_uom: product_uom_litre0
type: normal
-
I define Minimum stock rules for my stockable products orange and sugar
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
name: OP/00002
product_id: product_product_orange0
product_max_qty: 10.0
product_min_qty: 5.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op1}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
name: OP/00003
product_id: product_product_sugar0
product_max_qty: 4.0
product_min_qty: 2.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
I want to produce 100 litres of Orange juice. I am creating a manufacturing order for this.
I want to see how much quantities of sub products I need, to produce the Orange juice.
-
I compute the data. I get the bill of material of Orange juice and list of
scheduled products according to my bom.
-
!record {model: mrp.production, id: mrp_production_mo0}:
company_id: base.main_company
date_planned: '2010-04-16 15:53:36'
location_dest_id: stock.stock_location_output
location_src_id: stock.stock_location_stock
name: MO/00002
product_id: product_product_orangejuice0
product_qty: 100.0
product_uom: product_uom_litre0
-
Creating an mrp.production record. Computing Bills of materials.
-
!record {model: mrp.production, id: mrp_production_mo0}:
bom_id: mrp.mrp_bom_orangejuice0
company_id: base.main_company
date_planned: '2010-04-16 15:53:36'
location_dest_id: stock.stock_location_output
location_src_id: stock.stock_location_stock
name: MO/00002
product_id: mrp.product_product_orangejuice0
product_lines:
- name: Orange
product_id: mrp.product_product_orange0
product_qty: 50.0
product_uom: product.product_uom_kgm
production_id: mrp_production_mo0
- name: Sugar
product_id: mrp.product_product_sugar0
product_qty: 2.0
product_uom: product.product_uom_kgm
production_id: mrp_production_mo0
- name: Water
product_id: mrp.product_product_water0
product_qty: 80.0
product_uom: mrp.product_uom_litre0
production_id: mrp_production_mo0
product_qty: 100.0
product_uom: mrp.product_uom_litre0
-
I confirm the order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo0}
-
I am checking Procurement orders. There are 3 orders generated for Oranges, Sugar and Water.
-
!python {model: mrp.procurement}: |
from tools.translate import _
proc_ids = self.search(cr, uid, [('origin','=',':MO/00002')])
assert proc_ids, _('No Procurements!')
-
The scheduler runs.
-
!function {model: mrp.procurement, name: run_scheduler}:
- model: mrp.procurement
search: "[('origin','=',':MO/00002')]"
-
I am checking Internal picking. I see one picking for Orange juice and its
stock moves for Oranges, Sugar and Water made correctly.
-
!python {model: stock.picking}: |
from tools.translate import _
pick_ids = self.search(cr, uid, [('origin','=',':MO/00002'),('type','=','internal')])
assert pick_ids, _('No Internal Pickings!')
-
According to minimum stock rules. I have 2 purchase orders for
Sugar with 6 Kg from Axelor and Orange 60 Kg from ASUStek.
-
I confirm the purchase order of Sugar and Orange.
-
!python {model: purchase.order}: |
from tools.translate import _
import netsvc
purch_ids = self.search(cr, uid, [('origin','in',['SCHEDULER','OP/00002','OP/00003'])])
assert purch_ids, _('No Purchase Orders were made!')
wf_service = netsvc.LocalService("workflow")
for p_id in purch_ids:
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr)
-
I get the approval from both the suppliers. So I approve my purchase orders.
-
!python {model: purchase.order}: |
from tools.translate import _
import netsvc
purch_ids = self.search(cr, uid, [('origin','in',['SCHEDULER','OP/00002','OP/00003']),('state','=','confirmed')])
assert purch_ids, _('No Confirmed Purchase Orders found!')
wf_service = netsvc.LocalService("workflow")
for p_id in purch_ids:
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_approve', cr)
-
I see two incoming pickings for Orange and Sugar.
-
!python {model: stock.picking}: |
from tools.translate import _
pick_ids = self.search(cr, uid, [('origin','in',['PO00001:SCHEDULER','PO00002:SCHEDULER','PO00003:OP/00002','PO00004:OP/00003']),('type','=','in')])
assert pick_ids, _('No Incoming Shipments found!')
-
I receive both the products. My incoming pickings are done.
-
!function {model: stock.move.split, name: split_lot}:
- model: stock.picking
search: "[('origin','in',['PO00001:SCHEDULER','PO00002:SCHEDULER','PO00003:OP/00002','PO00004:OP/00003']),('type','=','in')]"

View File

@ -20,14 +20,10 @@
##############################################################################
import mrp_product_produce
import orderpoint_procurement
import mrp_procurement
import schedulers_all
import mrp_price
import mrp_workcenter_load
#import mrp_track_prod
import change_production_qty
import make_procurement_product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,25 @@
# -*- 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 mrp_procurement
import wizard
import schedulers
import company

View File

@ -0,0 +1,52 @@
# -*- 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/>.
#
##############################################################################
{
"name" : "Procurements",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Production",
"depends" : ["base","process", "product", "stock"],
"description": """
This is the module for computing Procurements.
""",
'init_xml': [],
'update_xml': [
'security/ir.model.access.csv',
'security/mrp_procurement_security.xml',
'mrp_procurement_data.xml',
'wizard/make_procurement_view.xml',
'wizard/mrp_procurement_view.xml',
'wizard/orderpoint_procurement_view.xml',
'mrp_procurement_view.xml',
'wizard/schedulers_all_view.xml',
'mrp_procurement_workflow.xml',
'process/procurement_process.xml',
"company_view.xml",
],
# 'demo_xml': [],
'installable': True,
'active': False,
'certificate': '',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,38 @@
# -*- 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 osv,fields
class company(osv.osv):
_inherit = 'res.company'
_columns = {
'schedule_range': fields.float('Scheduler Range', required=True,
help="This is the time frame analysed by the scheduler when "\
"computing procurements. All procurements that are not between "\
"today and today+range are skipped for futur computation."),
}
_defaults = {
'schedule_range': lambda *a: 80.0,
}
company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="mrp_company" model="ir.ui.view">
<field name="name">res.company.mrp.config</field>
<field name="model">res.company</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<page string="Configuration" position="inside">
<separator string="MRP &amp; Logistic Scheduler" colspan="4"/>
<field name="schedule_range"/>
</page>
</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,527 @@
# -*- 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 mx import DateTime
from osv import osv, fields
from tools.translate import _
import netsvc
import time
class mrp_property_group(osv.osv):
"""
Group of mrp properties.
"""
_name = 'mrp.property.group'
_description = 'Property Group'
_columns = {
'name': fields.char('Property Group', size=64, required=True),
'description': fields.text('Description'),
}
mrp_property_group()
class mrp_property(osv.osv):
"""
Properties of mrp.
"""
_name = 'mrp.property'
_description = 'Property'
_columns = {
'name': fields.char('Name', size=64, required=True),
'composition': fields.selection([('min','min'),('max','max'),('plus','plus')], 'Properties composition', required=True, help="Not used in computations, for information purpose only."),
'group_id': fields.many2one('mrp.property.group', 'Property Group', required=True),
'description': fields.text('Description'),
}
_defaults = {
'composition': lambda *a: 'min',
}
mrp_property()
# ------------------------------------------------------------------
# Procurement
# ------------------------------------------------------------------
#
# Produce, Buy or Find products and place a move
# then wizard for picking lists & move
#
class mrp_procurement(osv.osv):
"""
Procurement Orders
"""
_name = "mrp.procurement"
_description = "Procurement"
_order = 'priority,date_planned'
_columns = {
'name': fields.char('Reason', size=64, required=True, help='Procurement name.'),
'origin': fields.char('Source Document', size=64,
help="Reference of the document that created this Procurement.\n"
"This is automatically completed by Open ERP."),
'priority': fields.selection([('0','Not urgent'),('1','Normal'),('2','Urgent'),('3','Very Urgent')], 'Priority', required=True),
'date_planned': fields.datetime('Scheduled date', required=True),
'date_close': fields.datetime('Date Closed'),
'product_id': fields.many2one('product.product', 'Product', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'product_qty': fields.float('Quantity', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'product_uom': fields.many2one('product.uom', 'Product UoM', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'product_uos_qty': fields.float('UoS Quantity', states={'draft':[('readonly',False)]}, readonly=True),
'product_uos': fields.many2one('product.uom', 'Product UoS', states={'draft':[('readonly',False)]}, readonly=True),
'move_id': fields.many2one('stock.move', 'Reservation', ondelete='set null'),
'close_move': fields.boolean('Close Move at end', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True, states={'draft':[('readonly',False)]}, readonly=True),
'procure_method': fields.selection([('make_to_stock','from stock'),('make_to_order','on order')], 'Procurement Method', states={'draft':[('readonly',False)], 'confirmed':[('readonly',False)]},
readonly=True, required=True, help="If you encode manually a Procurement, you probably want to use" \
" a make to order method."),
'note': fields.text('Note'),
'property_ids': fields.many2many('mrp.property', 'mrp_procurement_property_rel', 'procurement_id','property_id', 'Properties'),
'message': fields.char('Latest error', size=64, help="Exception occurred while computing procurement orders."),
'state': fields.selection([
('draft','Draft'),
('confirmed','Confirmed'),
('exception','Exception'),
('running','Running'),
('cancel','Cancel'),
('ready','Ready'),
('done','Done'),
('waiting','Waiting')], 'State', required=True,
help='When a procurement is created the state is set to \'Draft\'.\n If the procurement is confirmed, the state is set to \'Confirmed\'.\
\nAfter confirming the state is set to \'Running\'.\n If any exception arises in the order then the state is set to \'Exception\'.\n Once the exception is removed the state becomes \'Ready\'.\n It is in \'Waiting\'. state when the procurement is waiting for another one to finish.'),
'note': fields.text('Note'),
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
'state': lambda *a: 'draft',
'priority': lambda *a: '1',
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'close_move': lambda *a: 0,
'procure_method': lambda *a: 'make_to_order',
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.procurement', context=c)
}
def unlink(self, cr, uid, ids, context=None):
procurements = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in procurements:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
""" Finds UoM and UoS of changed product.
@param product_id: Changed id of product.
@return: Dictionary of values.
"""
if product_id:
w = self.pool.get('product.product').browse(cr, uid, product_id, context)
v = {
'product_uom': w.uom_id.id,
'product_uos': w.uos_id and w.uos_id.id or w.uom_id.id
}
return {'value': v}
return {}
def check_product(self, cr, uid, ids):
""" Checks product type.
@return: True or False
"""
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.type in ('product', 'consu'):
return True
return False
def check_move_cancel(self, cr, uid, ids, context={}):
""" Checks if move is cancelled or not.
@return: True or False.
"""
res = True
ok = False
for procurement in self.browse(cr, uid, ids, context):
if procurement.move_id:
ok = True
if not procurement.move_id.state == 'cancel':
res = False
return res and ok
def check_move_done(self, cr, uid, ids, context={}):
""" Checks if move is done or not.
@return: True or False.
"""
res = True
for proc in self.browse(cr, uid, ids, context):
if proc.move_id:
if not proc.move_id.state == 'done':
res = False
return res
#
# This method may be overrided by objects that override mrp.procurment
# for computing their own purpose
#
def _quantity_compute_get(self, cr, uid, proc, context={}):
""" Finds sold quantity of product.
@param proc: Current procurement.
@return: Quantity or False.
"""
if proc.product_id.type == 'product':
if proc.move_id.product_uos:
return proc.move_id.product_uos_qty
return False
def _uom_compute_get(self, cr, uid, proc, context={}):
""" Finds UoS if product is Stockable Product.
@param proc: Current procurement.
@return: UoS or False.
"""
if proc.product_id.type == 'product':
if proc.move_id.product_uos:
return proc.move_id.product_uos.id
return False
#
# Return the quantity of product shipped/produced/served, wich may be
# different from the planned quantity
#
def quantity_get(self, cr, uid, id, context={}):
""" Finds quantity of product used in procurement.
@return: Quantity of product.
"""
proc = self.browse(cr, uid, id, context)
result = self._quantity_compute_get(cr, uid, proc, context)
if not result:
result = proc.product_qty
return result
def uom_get(self, cr, uid, id, context=None):
""" Finds UoM of product used in procurement.
@return: UoM of product.
"""
proc = self.browse(cr, uid, id, context)
result = self._uom_compute_get(cr, uid, proc, context)
if not result:
result = proc.product_uom.id
return result
def check_waiting(self, cr, uid, ids, context=[]):
""" Checks state of move.
@return: True or False
"""
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.move_id and procurement.move_id.state == 'auto':
return True
return False
def check_produce_service(self, cr, uid, procurement, context=[]):
return True
def check_produce_product(self, cr, uid, procurement, context=[]):
""" Finds BoM of a product if not found writes exception message.
@param procurement: Current procurement.
@return: True or False.
"""
return True
def check_make_to_stock(self, cr, uid, ids, context={}):
""" Checks product type.
@return: True or False
"""
ok = True
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.type == 'service':
ok = ok and self._check_make_to_stock_service(cr, uid, procurement, context)
else:
ok = ok and self._check_make_to_stock_product(cr, uid, procurement, context)
return ok
def check_produce(self, cr, uid, ids, context={}):
""" Checks product type.
@return: True or Product Id.
"""
res = True
user = self.pool.get('res.users').browse(cr, uid, uid)
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.product_tmpl_id.supply_method <> 'produce':
if procurement.product_id.seller_ids:
partner = procurement.product_id.seller_ids[0].name
if user.company_id and user.company_id.partner_id:
if partner.id == user.company_id.partner_id.id:
return True
return False
if procurement.product_id.product_tmpl_id.type=='service':
res = res and self.check_produce_service(cr, uid, procurement, context)
else:
res = res and self.check_produce_product(cr, uid, procurement, context)
if not res:
return False
return res
def check_buy(self, cr, uid, ids):
""" Checks product type.
@return: True or Product Id.
"""
user = self.pool.get('res.users').browse(cr, uid, uid)
partner_obj = self.pool.get('res.partner')
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
return False
if not procurement.product_id.seller_ids:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id))
return False
partner = procurement.product_id.seller_ids[0].name
if user.company_id and user.company_id.partner_id:
if partner.id == user.company_id.partner_id.id:
return False
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
if not address_id:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id))
return False
return True
def test_cancel(self, cr, uid, ids):
""" Tests whether state of move is cancelled or not.
@return: True or False
"""
for record in self.browse(cr, uid, ids):
if record.move_id and record.move_id.state == 'cancel':
return True
return False
def action_confirm(self, cr, uid, ids, context={}):
""" Confirms procurement and writes exception message if any.
@return: True
"""
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.product_qty <= 0.00:
raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity of Procurement Order(s), it should not be less than 1!'))
if procurement.product_id.type in ('product', 'consu'):
if not procurement.move_id:
source = procurement.location_id.id
if procurement.procure_method == 'make_to_order':
source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
id = move_obj.create(cr, uid, {
'name': 'PROC:' + procurement.name,
'location_id': source,
'location_dest_id': procurement.location_id.id,
'product_id': procurement.product_id.id,
'product_qty': procurement.product_qty,
'product_uom': procurement.product_uom.id,
'date_planned': procurement.date_planned,
'state': 'confirmed',
'company_id': procurement.company_id.id,
})
self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
else:
# TODO: check this
if procurement.procure_method == 'make_to_stock' and procurement.move_id.state in ('waiting',):
id = move_obj.write(cr, uid, [procurement.move_id.id], {'state':'confirmed'})
self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
return True
def action_move_assigned(self, cr, uid, ids, context={}):
""" Changes procurement state to Running and writes message.
@return: True
"""
self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')})
return True
def _check_make_to_stock_service(self, cr, uid, procurement, context={}):
return True
def _check_make_to_stock_product(self, cr, uid, procurement, context={}):
""" Checks procurement move state.
@param procurement: Current procurement.
@return: True or move id.
"""
ok = True
if procurement.move_id:
id = procurement.move_id.id
if not (procurement.move_id.state in ('done','assigned','cancel')):
ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id])
cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,))
if not cr.fetchone()[0]:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('from stock and no minimum orderpoint rule defined'), procurement.id))
return ok
def action_produce_assign_service(self, cr, uid, ids, context={}):
""" Changes procurement state to Running.
@return: True
"""
for procurement in self.browse(cr, uid, ids):
self.write(cr, uid, [procurement.id], {'state': 'running'})
return True
def action_produce_assign_product(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign production order to procurements
@return: True
"""
return 0
def action_po_assign(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign purchase order to procurements
@return: True
"""
return 0
def action_cancel(self, cr, uid, ids):
""" Cancels procurement and writes move state to Assigned.
@return: True
"""
todo = []
todo2 = []
move_obj = self.pool.get('stock.move')
for proc in self.browse(cr, uid, ids):
if proc.close_move:
if proc.move_id.state not in ('done', 'cancel'):
todo2.append(proc.move_id.id)
else:
if proc.move_id and proc.move_id.state == 'waiting':
todo.append(proc.move_id.id)
if len(todo2):
move_obj.action_cancel(cr, uid, todo2)
if len(todo):
move_obj.write(cr, uid, todo, {'state': 'assigned'})
self.write(cr, uid, ids, {'state': 'cancel'})
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
return True
def action_check_finnished(self, cr, uid, ids):
return self.check_move_done(cr, uid, ids)
def action_check(self, cr, uid, ids):
""" Checks procurement move state whether assigned or done.
@return: True
"""
ok = False
for procurement in self.browse(cr, uid, ids):
if procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done':
self.action_done(cr, uid, [procurement.id])
ok = True
return ok
def action_ready(self, cr, uid, ids):
""" Changes procurement state to Ready.
@return: True
"""
res = self.write(cr, uid, ids, {'state': 'ready'})
return res
def action_done(self, cr, uid, ids):
""" Changes procurement state to Done and writes Closed date.
@return: True
"""
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.move_id:
if procurement.close_move and (procurement.move_id.state <> 'done'):
move_obj.action_done(cr, uid, [procurement.move_id.id])
res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
return res
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
''' Runs through scheduler.
@param use_new_cursor: False or the dbname
'''
if not context:
context={}
self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
use_new_cursor=use_new_cursor, context=context)
mrp_procurement()
class stock_warehouse_orderpoint(osv.osv):
"""
Defines Minimum stock rules.
"""
_name = "stock.warehouse.orderpoint"
_description = "Orderpoint minimum rule"
_columns = {
'name': fields.char('Name', size=32, required=True),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."),
'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type','=','product')]),
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True ),
'product_min_qty': fields.float('Min Quantity', required=True,
help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
"a procurement to bring the virtual stock to the Max Quantity."),
'product_max_qty': fields.float('Max Quantity', required=True,
help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
"a procurement to bring the virtual stock to the Max Quantity."),
'qty_multiple': fields.integer('Qty Multiple', required=True,
help="The procurement quantity will by rounded up to this multiple."),
'procurement_id': fields.many2one('mrp.procurement', 'Latest procurement'),
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
'active': lambda *a: 1,
'logic': lambda *a: 'max',
'qty_multiple': lambda *a: 1,
'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '',
'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)
}
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
""" Finds location id for changed warehouse.
@param warehouse_id: Changed id of warehouse.
@return: Dictionary of values.
"""
if warehouse_id:
w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context)
v = {'location_id': w.lot_stock_id.id}
return {'value': v}
return {}
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
""" Finds UoM for changed product.
@param product_id: Changed id of product.
@return: Dictionary of values.
"""
if product_id:
prod = self.pool.get('product.product').browse(cr,uid,product_id)
v = {'product_uom': prod.uom_id.id}
return {'value': v}
return {}
def copy(self, cr, uid, id, default=None,context={}):
if not default:
default = {}
default.update({
'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '',
})
return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context)
stock_warehouse_orderpoint()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record forcecreate="True" id="ir_cron_scheduler_action" model="ir.cron">
<field name="name">Run mrp scheduler</field>
<field eval="False" name="active"/>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'mrp.procurement'" name="model"/>
<field eval="'run_scheduler'" name="function"/>
<field eval="'(False,)'" name="args"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,342 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Procurement
-->
<menuitem id="menu_mrp_procurement" name="Procurements"
parent="base.menu_base_partner" sequence="5"/>
<menuitem name="Procurement Control" id="menu_mrp_control"
parent="mrp_procurement.menu_mrp_procurement" sequence="3" />
<!--
Property / Property Group
-->
<record id="mrp_property_group_form_view" model="ir.ui.view">
<field name="name">mrp.property.group.form</field>
<field name="model">mrp.property.group</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Properties categories">
<separator colspan="4" string="General Information"/>
<field colspan="4" name="name" select="1"/>
<field colspan="4" name="description"/>
</form>
</field>
</record>
<record id="mrp_property_group_action" model="ir.actions.act_window">
<field name="name">Property Categories</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.property.group</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
id="menu_mrp_configuration"
name="Configuration"
parent="mrp_procurement.menu_mrp_procurement"
groups="base.group_extended"
sequence="50" />
<record id="mrp_property_tree_view" model="ir.ui.view">
<field name="name">mrp.property.tree</field>
<field name="model">mrp.property</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Properties">
<field name="name"/>
<field name="composition"/>
<field name="group_id"/>
</tree>
</field>
</record>
<record id="mrp_property_form_view" model="ir.ui.view">
<field name="name">mrp.property.form</field>
<field name="model">mrp.property</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Properties">
<separator colspan="4" string="General Information"/>
<field colspan="4" name="name" select="1"/>
<field name="group_id" select="1"/>
<field name="composition" select="1"/>
<separator colspan="4" string="Description"/>
<field colspan="4" name="description"/>
</form>
</field>
</record>
<record id="mrp_property_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.property</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Properties"
id="menu_mrp_property"
parent="menu_mrp_configuration"
groups="base.group_extended"
sequence="20" />
<menuitem
action="mrp_property_action"
id="menu_mrp_property_action"
parent="menu_mrp_property"
groups="base.group_extended" />
<menuitem
action="mrp_property_group_action"
id="menu_mrp_property_group_action"
parent="menu_mrp_property"/>
<record id="mrp_procurement_tree_view" model="ir.ui.view">
<field name="name">mrp.procurement.tree</field>
<field name="model">mrp.procurement</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Procurement Lines" colors="red:state=='draft';black:state=='running';green:state=='confirmed';gray:state in ['done','cancel']">
<field name="date_planned" widget="date"/>
<field name="origin"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom" string="UOM"/>
<field name="procure_method"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="mrp_procurement_form_view" model="ir.ui.view">
<field name="name">mrp.procurement.form</field>
<field name="model">mrp.procurement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Procurement">
<group col="2" colspan="2">
<separator colspan="2" string="References"/>
<field name="name" select="1" string="Procurement Reason"/>
<field name="origin"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
</group>
<group col="2" colspan="2">
<separator colspan="2" string="Planification"/>
<field name="date_planned" select="1"/>
<field name="procure_method"/>
<field name="priority" groups="base.group_extended"/>
</group>
<notebook colspan="4">
<page string="Procurement Details">
<separator colspan="4" string="Product &amp; Location"/>
<field name="product_id" select="1" on_change="onchange_product_id(product_id)"/>
<field name="location_id" domain="[('usage','=','internal')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="product_uos_qty" groups="product.group_uos"/>
<field name="product_uos" groups="product.group_uos"/>
<separator colspan="4" string="Status"/>
<field colspan="4" name="message" readonly="1"/>
<field name="state" readonly="1"/>
<group col="7" colspan="2">
<button name="button_confirm" states="draft" string="Confirm" icon="gtk-apply"/>
<button name="button_restart" states="exception" string="Retry" icon="gtk-convert"/>
<button name="button_cancel" states="draft,exception,waiting" string="Cancel" icon="gtk-cancel"/>
<button name="button_check" states="confirmed" string="Run Procurement" icon="gtk-media-play"/>
</group>
</page>
<page string="Extra Information">
<separator colspan="4" string="Details"/>
<field name="move_id" groups="base.group_extended"/>
<field name="date_close"/>
<field name="close_move" groups="base.group_extended"/>
<group colspan="4" groups="base.group_extended">
<separator colspan="4" string="Properties" />
<field colspan="4" name="property_ids" nolabel="1"/>
</group>
</page>
<page string="Notes">
<separator colspan="4" string="Note" />
<field name="note" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="view_mrp_procurement_filter" model="ir.ui.view">
<field name="name">mrp.procurement.select</field>
<field name="model">mrp.procurement</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Procurement">
<group col='10' colspan='4'>
<filter icon="terp-mrp" string="Current" domain="[('state','in',('draft','confirmed'))]" default="1" help="Procurement Orders in draft or open state."/>
<filter icon="terp-mrp" string="Exceptions" domain="[('state','=','exception')]" help="Procurement Orders with exceptions"/>
<filter icon="terp-mrp" string="Late"
domain="['&amp;', ('date_planned::date','&lt;', current_date), ('state', 'in', ('draft', 'confirmed'))]"
help="Procurement started late" />
<separator orientation="vertical"/>
<field name="name"/>
<field name="origin"/>
<field name="product_id" />
<field name="date_planned" widget="date"/>
<field name="state" />
</group>
<newline/>
<group expand="1" string="Group By" colspan="4" col="8">
<filter string="Product" icon="terp-mrp" domain="[]" context="{'group_by':'product_id'}"/>
<filter string="Reason" icon="terp-mrp" domain="[]" context="{'group_by':'name'}"/>
<filter string="Scheduled Date" icon="terp-mrp" domain="[]" context="{'group_by':'date_planned'}"/>
</group>
</search>
</field>
</record>
<record id="mrp_procurement_action" model="ir.actions.act_window">
<field name="name">Procurement Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_id" eval="False"/>
<field name="search_view_id" ref="view_mrp_procurement_filter"/>
</record>
<menuitem action="mrp_procurement_action" id="menu_mrp_procurement_action"
parent="mrp_procurement.menu_mrp_procurement" sequence="2" />
<record id="mrp_procurement_action3" model="ir.actions.act_window">
<field name="name">Procurements</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_mrp_procurement_filter"/>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
<record id="mrp_procurement_action5" model="ir.actions.act_window">
<field name="name">Procurement Exceptions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','exception')]</field>
</record>
<menuitem action="mrp_procurement_action5" id="menu_mrp_procurement_exception_action"
parent="mrp_procurement.menu_mrp_control" sequence="1" />
<record id="mrp_procurement_action4" model="ir.actions.act_window">
<field name="name">Procurement Exceptions to Fix</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','exception'), ('message', '&lt;&gt;', '')]</field>
<field name="filter" eval="True"/>
</record>
<record id="mrp_procurement_action11" model="ir.actions.act_window">
<field name="name">Temporary Procurement Exceptions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','exception'), ('message', '=', '')]</field>
</record>
<!-- Order Point -->
<record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.tree</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Minimum Stock Rules">
<field name="name"/>
<field name="warehouse_id"/>
<field name="location_id"/>
<field name="product_id"/>
<field name="product_uom"/>
<field name="product_min_qty"/>
<field name="product_max_qty"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="warehouse_orderpoint_search">
<field name="name">stock.warehouse.orderpoint.search</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Minimum Stock Rules Search">
<group col="10" colspan="4">
<field name="name" select="1" />
<field name="warehouse_id" select="1" widget="selection"/>
<field name="location_id" select="1" />
<field name="company_id" select="1" widget="selection"/>
<field name="product_id" select="1"/>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="4" col="10">
<filter string="Warehouse" icon="terp-stock" domain="[]" context="{'group_by':'warehouse_id'}"/>
<filter string="Location" icon="terp-stock" domain="[]" context="{'group_by':'location_id'}"/>
</group>
</search>
</field>
</record>
<record id="view_warehouse_orderpoint_form" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.form</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Minimum Stock Rules">
<group col="2" colspan="2">
<separator string="General Information" colspan="2" />
<field name="name" />
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="product_uom"/>
</group>
<group col="2" colspan="2">
<separator string="Locations" colspan="2" />
<field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection"/>
<field name="location_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<group col="2" colspan="2">
<separator string="Quantity Rules" colspan="2" />
<field name="product_min_qty"/>
<field name="product_max_qty"/>
<field name="qty_multiple"/>
</group>
<group col="2" colspan="2" groups="base.group_extended">
<separator string="Misc" colspan="2" />
<field name="procurement_id" readonly="1"/>
<field name="active" />
</group>
</form>
</field>
</record>
<record id="action_orderpoint_form" model="ir.actions.act_window">
<field name="name">Minimum Stock Rules</field>
<field name="res_model">stock.warehouse.orderpoint</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_warehouse_orderpoint_tree"/>
<field name="search_view_id" ref="warehouse_orderpoint_search" />
</record>
<menuitem id="menu_mrp_reordering" name="Automatic Procurements" parent="stock.menu_stock_root" sequence="4"/>
<menuitem action="action_orderpoint_form" id="menu_action_orderpoint_form" parent="menu_mrp_reordering"/>
<act_window domain="[('warehouse_id', '=', active_id)]" id="act_stock_warehouse_2_stock_warehouse_orderpoint" name="Minimum Stock Rules" res_model="stock.warehouse.orderpoint" src_model="stock.warehouse"/>
<!-- add product_uom to context to be the default value when adding new orderpoints -->
<act_window
context="{'product_uom': locals().has_key('uom_id') and uom_id}"
domain="[('product_id', '=', active_id)]"
id="act_product_product_2_stock_warehouse_orderpoint"
name="Minimum Stock Rules"
res_model="stock.warehouse.orderpoint"
src_model="product.product"/>
</data>
</openerp>

View File

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Procurement -->
<record id="wkf_procurement" model="workflow">
<field name="name">mrp.procurement.basic</field>
<field name="osv">mrp.procurement</field>
<field name="on_create">True</field>
</record>
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<record id="act_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">cancel</field>
<field name="kind">function</field>
<field name="action">action_cancel()</field>
<field name="flow_stop">True</field>
</record>
<record id="act_confirm" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">confirm</field>
<field name="kind">function</field>
<field name="action">action_confirm()</field>
</record>
<record id="act_confirm_wait" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">confirm_wait</field>
<field name="kind">function</field>
<field name="action">write({'state':'exception'})</field>
</record>
<record id="act_confirm_mts" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">confirm_mts</field>
</record>
<record id="act_confirm_mto" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">confirm_mto</field>
</record>
<record id="act_make_to_stock" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">make_to_stock</field>
<field name="kind">function</field>
<field name="action">action_move_assigned()</field>
</record>
<record id="act_produce_check" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">produce_check</field>
</record>
<record id="act_produce_service" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">produce_service</field>
<field name="kind">function</field>
<field name="action">action_produce_assign_service()</field>
</record>
<record id="act_make_done" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">ready</field>
<field name="kind">function</field>
<field name="action">action_ready()</field>
</record>
<record id="act_wait_done" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="name">wait_done</field>
<field name="kind">function</field>
<field name="action">write({'state':'waiting'})</field>
</record>
<record id="act_done" model="workflow.activity">
<field name="wkf_id" ref="wkf_procurement"/>
<field name="flow_stop">True</field>
<field name="name">done</field>
<field name="kind">function</field>
<field name="action">action_done()</field>
</record>
<record id="trans_draft_confirm" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_confirm"/>
<field name="signal">button_confirm</field>
</record>
<record id="trans_confirm_cancel2" model="workflow.transition">
<field name="act_from" ref="act_confirm"/>
<field name="act_to" ref="act_wait_done"/>
<field name="signal">button_wait_done</field>
<field name="condition">True</field>
</record>
<record id="trans_confirm_wait_done" model="workflow.transition">
<field name="act_from" ref="act_wait_done"/>
<field name="act_to" ref="act_done"/>
<field name="condition">check_move_done()</field>
<field name="trigger_model">stock.move</field>
<field name="trigger_expr_id">[move_id.id]</field>
</record>
<record id="trans_confirm_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirm"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_check</field>
<field name="condition">test_cancel()</field>
</record>
<record id="trans_confirm_confirm_wait" model="workflow.transition">
<field name="act_from" ref="act_confirm"/>
<field name="act_to" ref="act_confirm_wait"/>
<field name="signal">button_check</field>
<field name="condition">not test_cancel()</field>
</record>
<record id="trans_confirm_wait_confirm_mto" model="workflow.transition">
<field name="act_from" ref="act_confirm_wait"/>
<field name="act_to" ref="act_confirm_mto"/>
<field name="condition">procure_method=='make_to_order'</field>
</record>
<record id="trans_confirm_wait_confirm_mts" model="workflow.transition">
<field name="act_from" ref="act_confirm_wait"/>
<field name="act_to" ref="act_confirm_mts"/>
<field name="condition">procure_method=='make_to_stock'</field>
</record>
<record id="trans_confirm_mts_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirm_mts"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_waiting_cancel" model="workflow.transition">
<field name="act_from" ref="act_wait_done"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mts_confirm" model="workflow.transition">
<field name="act_from" ref="act_confirm_mts"/>
<field name="act_to" ref="act_confirm"/>
<field name="signal">button_restart</field>
</record>
<record id="trans_confirm_mto_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mto_confirm" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_confirm"/>
<field name="signal">button_restart</field>
</record>
<record id="trans_draft_cancel" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mts_make_to_stock" model="workflow.transition">
<field name="act_from" ref="act_confirm_mts"/>
<field name="act_to" ref="act_make_to_stock"/>
<field name="condition">check_make_to_stock()</field>
</record>
<record id="trans_confirm_mto_produce_check" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_produce_check"/>
<field name="condition">check_produce()</field>
</record>
<record id="trans_product_check_produce_service" model="workflow.transition">
<field name="act_from" ref="act_produce_check"/>
<field name="act_to" ref="act_produce_service"/>
<field name="condition">not check_product()</field>
</record>
<record id="trans_make_to_stock_make_done" model="workflow.transition">
<field name="act_from" ref="act_make_to_stock"/>
<field name="act_to" ref="act_make_done"/>
<field name="condition">True</field>
<field name="trigger_model" eval="False"/>
<field name="trigger_expr_id" eval="False"/>
</record>
<record id="trans_produce_service_cancel" model="workflow.transition">
<field name="act_from" ref="act_produce_service"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_produce_service_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce_service"/>
<field name="act_to" ref="act_make_done"/>
</record>
<record id="trans_make_done_done" model="workflow.transition">
<field name="act_from" ref="act_make_done"/>
<field name="act_to" ref="act_done"/>
<field name="condition">action_check_finnished()</field>
</record>
<record id="trans_make_done_confirm" model="workflow.transition">
<field name="act_from" ref="act_make_done"/>
<field name="act_to" ref="act_cancel"/>
<field name="condition">check_move_cancel()</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" ?>
<openerp>
<data>
<!--
Process
-->
<record id="process_process_procurementprocess0" model="process.process">
<field eval="&quot;&quot;&quot;Procurement&quot;&quot;&quot;" name="name"/>
<field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
<field eval="1" name="active"/>
</record>
<!--
Process Node
-->
<record id="process_node_procureproducts0" model="process.node">
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;The way to procurement depends on the product type.&quot;&quot;&quot;" name="note"/>
<field eval="&quot;&quot;&quot;Procure Products&quot;&quot;&quot;" name="name"/>
<field name="process_id" ref="process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
<field eval="0" name="flow_start"/>
</record>
</data>
</openerp>

View File

@ -238,4 +238,5 @@ class mrp_procurement(osv.osv):
cr.close()
return {}
mrp_procurement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,9 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_mrp_property_group","mrp.property.group","model_mrp_property_group",,1,0,0,0
"access_mrp_property","mrp.property","model_mrp_property",,1,0,0,0
"access_mrp_procurement","mrp.procurement","model_mrp_procurement",,1,0,0,0
"access_stock_warehouse_orderpoint","stock.warehouse.orderpoint","model_stock_warehouse_orderpoint",,1,0,0,0
"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all",,1,0,0,0
"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute",,1,0,0,0
"access_mrp_make_procurement","make.procurement","model_make_procurement",,1,0,0,0
"access_mrp_make_procurement","mrp.procurement.compute","model_mrp_procurement_compute",,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_mrp_property_group mrp.property.group model_mrp_property_group 1 0 0 0
3 access_mrp_property mrp.property model_mrp_property 1 0 0 0
4 access_mrp_procurement mrp.procurement model_mrp_procurement 1 0 0 0
5 access_stock_warehouse_orderpoint stock.warehouse.orderpoint model_stock_warehouse_orderpoint 1 0 0 0
6 access_mrp_procurement_compute_all mrp.procurement.compute.all model_mrp_procurement_compute_all 1 0 0 0
7 access_mrp_procurement_orderpoint_compute mrp.procurement.orderpoint.compute model_mrp_procurement_orderpoint_compute 1 0 0 0
8 access_mrp_make_procurement make.procurement model_make_procurement 1 0 0 0
9 access_mrp_make_procurement mrp.procurement.compute model_mrp_procurement_compute 1 0 0 0

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.rule.group" id="mrp_procurement_rule_group">
<field name="name">mrp_procurement multi-company</field>
<field name="model_id" search="[('model','=','mrp.procurement')]" model="ir.model"/>
<field name="global" eval="True"/>
</record>
<record model="ir.rule" id="mrp_procurement_rule">
<field model="ir.model.fields" name="field_id" search="[('model','=','mrp.procurement'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
<field name="rule_group" ref="mrp_procurement_rule_group"/>
</record>
<record model="ir.rule.group" id="stock_warehouse_orderpoint_rule_group">
<field name="name">stock_warehouse.orderpoint multi-company</field>
<field name="model_id" search="[('model','=','stock.warehouse.orderpoint')]" model="ir.model"/>
<field name="global" eval="True"/>
</record>
<record model="ir.rule" id="stock_warehouse_orderpoint_rule">
<field model="ir.model.fields" name="field_id" search="[('model','=','stock.warehouse.orderpoint'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
<field name="rule_group" ref="stock_warehouse_orderpoint_rule_group"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,27 @@
# -*- 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 orderpoint_procurement
import mrp_procurement
import schedulers_all
import make_procurement_product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -83,8 +83,8 @@ class make_procurement(osv.osv_memory):
wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view')
id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view')
id2 = data_obj._get_id(cr, uid, 'mrp_procurement', 'mrp_procurement_tree_view')
id3 = data_obj._get_id(cr, uid, 'mrp_procurement', 'mrp_procurement_form_view')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id

View File

@ -30,8 +30,8 @@
key2="client_action_multi"
id="action_compute_schedulers"/>
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
<menuitem action="action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="menu_mrp_procurement" sequence="4"/>
<menuitem action="action_compute_schedulers" id="mrp_Sched_all" parent="mrp_procurement.menu_mrp_scheduler" sequence="90"/>
</data>
</openerp>

View File

@ -174,7 +174,7 @@
ref('stock.menu_action_picking_tree7'),
ref('stock.menu_action_picking_tree8'),
ref('stock.menu_action_picking_tree9'),
ref('mrp.menu_mrp_procurement_action3'),
ref('mrp_procurement.menu_mrp_procurement_action3'),
ref('point_of_sale.menu_point_root')])]" name="menu_access"/>
<field eval="[(6,0,[ref('res_users_shopuser0'),ref('res_users_shopuser1')])]" name="users"/>
<field eval="[(6,0,[ref('point_of_sale.ir_rule_group_point0'),ref('point_of_sale.ir_rule_group_poslinecompany0'),ref('point_of_sale.ir_rule_group_posreporting0')])]" name="rule_groups"/>
@ -211,7 +211,7 @@
</record>
<record id="ir_modelsmrp_pdt0" model="ir.model.access">
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
<field eval="1" name="perm_read"/>
<field eval="&quot;&quot;&quot;MRP - Procurement&quot;&quot;&quot;" name="name"/>
<field eval="0" name="perm_unlink"/>
@ -553,7 +553,7 @@
<field name="group_id" ref="res_groups_posuser0"/>
</record>
<record id="ir_model_access_procurement0" model="ir.model.access">
<field name="model_id" ref="mrp.model_mrp_procurement" />
<field name="model_id" ref="mrp_procurement.model_mrp_procurement" />
<field eval="1" name="perm_read" />
<field eval="1" name="perm_write" />
<field eval="1" name="perm_create" />

View File

@ -9,7 +9,7 @@
<field name="arch" type="xml">
<page string="Sales &amp; Purchases" position="inside">
<newline/>
<group col="2" colspan="2" name="sale_list">
<group col="2" colspan="2">
<separator string="Sales Properties" colspan="2"/>
<field name="property_product_pricelist"/>
</group>

View File

@ -25,6 +25,7 @@ import stock
import wizard
import report
import stock
import company
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -31,7 +31,7 @@
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['base', 'account', 'stock', 'process'],
'depends': ['base', 'account', 'stock', 'process', 'mrp_procurement'],
'init_xml': [],
'update_xml': [
@ -39,6 +39,7 @@
'security/ir.model.access.csv',
'purchase_workflow.xml',
'purchase_sequence.xml',
'company_view.xml',
'purchase_data.xml',
'wizard/purchase_order_group_view.xml',
'wizard/purchase_installer.xml',

View File

@ -0,0 +1,36 @@
# -*- 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 osv,fields
class company(osv.osv):
_inherit = 'res.company'
_columns = {
'po_lead': fields.float('Purchase Lead Time', required=True,
help="This is the leads/security time for each purchase order."),
}
_defaults = {
'po_lead': lambda *a: 1.0,
}
company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,18 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="mrp_company" model="ir.ui.view">
<field name="name">res.company.mrp.config</field>
<field name="model">res.company</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<page string="Configuration" position="inside">
<field name="po_lead"/>
</page>
</field>
</record>
</data>
</openerp>

View File

@ -8,12 +8,14 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority">36</field>
<field name="arch" type="xml">
<group name="sale_list" position="after" groups="base.group_extended">
<group colspan="2" col="2" groups="base.group_extended">
<separator string="Purchases Properties" colspan="2"/>
<field name="property_product_pricelist_purchase"/>
</group>
</group>
<page string="Sales &amp; Purchases" position="inside">
<group groups="base.group_extended">
<group colspan="2" col="2" groups="base.group_extended">
<separator string="Purchases Properties" colspan="2"/>
<field name="property_product_pricelist_purchase"/>
</group>
</group>
</page>
</field>
</record>

View File

@ -19,6 +19,7 @@
#
##############################################################################
from mx import DateTime
from osv import fields
from osv import osv
import time
@ -692,5 +693,86 @@ class purchase_order_line(osv.osv):
return True
purchase_order_line()
class mrp_procurement(osv.osv):
_inherit = 'mrp.procurement'
_columns = {
'purchase_id': fields.many2one('purchase.order', 'Purchase Order'),
}
def action_po_assign(self, cr, uid, ids, context={}):
""" This is action which call from workflow to assign purchase order to procurements
@return: True
"""
res = self.make_po(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
def make_po(self, cr, uid, ids, context={}):
""" Make purchase order from procurement
@return: New created Purchase Orders procurement wise
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
partner_obj = self.pool.get('res.partner')
uom_obj = self.pool.get('product.uom')
pricelist_obj = self.pool.get('product.pricelist')
prod_obj = self.pool.get('product.product')
acc_pos_obj = self.pool.get('account.fiscal.position')
po_obj = self.pool.get('purchase.order')
for procurement in self.browse(cr, uid, ids):
res_id = procurement.move_id.id
partner = procurement.product_id.seller_ids[0].name
partner_id = partner.id
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
pricelist_id = partner.property_product_pricelist_purchase.id
uom_id = procurement.product_id.uom_po_id.id
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
if procurement.product_id.seller_ids[0].qty:
qty = max(qty,procurement.product_id.seller_ids[0].qty)
price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, False, {'uom': uom_id})[pricelist_id]
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
newdate = newdate - procurement.product_id.seller_ids[0].delay
#Passing partner_id to context for purchase order line integrity of Line name
context.update({'lang': partner.lang, 'partner_id': partner_id})
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
line = {
'name': product.partner_ref,
'product_qty': qty,
'product_id': procurement.product_id.id,
'product_uom': uom_id,
'price_unit': price,
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'move_dest_id': res_id,
'notes': product.description_purchase,
}
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
line.update({
'taxes_id': [(6,0,taxes)]
})
purchase_id = po_obj.create(cr, uid, {
'origin': procurement.origin,
'partner_id': partner_id,
'partner_address_id': address_id,
'location_id': procurement.location_id.id,
'pricelist_id': pricelist_id,
'order_line': [(0,0,line)],
'company_id': procurement.company_id.id,
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False
})
res[procurement.id] = purchase_id
self.write(cr, uid, [procurement.id], {'state': 'running'}) #, 'purchase_id': purchase_id
return res
mrp_procurement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -322,7 +322,22 @@
<field name="act_window_id" ref="purchase_line_form_action2"/>
</record>
<menuitem action="purchase_line_form_action2" id="menu_purchase_line_order_draft" parent="menu_procurement_management_invoice"/>
<!--
Procurements
-->
<record id="view_procurement_form_inherit" model="ir.ui.view">
<field name="name">mrp.procurement.form.inherit</field>
<field name="model">mrp.procurement</field>
<field name="inherit_id" ref="mrp_procurement.mrp_procurement_form_view"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='close_move']" position="before">
<field name="purchase_id"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -177,6 +177,27 @@
<field name="act_from" ref="act_invoice_end"/>
<field name="act_to" ref="act_done"/>
</record>
<!-- Procurement -->
<record id="act_buy" model="workflow.activity">
<field name="wkf_id" ref="mrp_procurement.wkf_procurement"/>
<field name="name">buy</field>
<field name="kind">subflow</field>
<field name="subflow_id" search="[('osv','=','purchase.order')]"/>
<field name="action">action_po_assign()</field>
</record>
<record id="trans_confirm_mto_buy" model="workflow.transition">
<field name="act_from" ref="mrp_procurement.act_confirm_mto"/>
<field name="act_to" ref="act_buy"/>
<field name="condition">check_buy()</field>
</record>
<record id="trans_buy_cancel" model="workflow.transition">
<field name="act_from" ref="act_buy"/>
<field name="act_to" ref="mrp_procurement.act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
</data>
</openerp>

View File

@ -26,9 +26,10 @@
import sale
import stock
import product
import mrp
#import mrp
import wizard
import report
import company
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -42,13 +42,14 @@
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['product', 'stock', 'mrp', 'process'],
'depends': ['product', 'stock', 'mrp_procurement', 'process'],
'init_xml': [],
'update_xml': [
'wizard/sale_make_invoice_advance.xml',
'wizard/sale_line_invoice.xml',
'security/sale_security.xml',
'security/ir.model.access.csv',
'company_view.xml',
'sale_workflow.xml',
'sale_sequence.xml',
'sale_data.xml',

37
addons/sale/company.py Normal file
View File

@ -0,0 +1,37 @@
# -*- 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 osv,fields
class company(osv.osv):
_inherit = 'res.company'
_columns = {
'security_lead': fields.float('Security Days', required=True,
help="This is the days added to what you promise to customers "\
"for security purpose"),
}
_defaults = {
'security_lead': lambda *a: 5.0,
}
company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,18 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="mrp_company" model="ir.ui.view">
<field name="name">res.company.mrp.config</field>
<field name="model">res.company</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<page string="Configuration" position="inside">
<field name="security_lead"/>
</page>
</field>
</record>
</data>
</openerp>

View File

@ -35,7 +35,7 @@
<field eval="&quot;&quot;&quot;Sale Order Requisition&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;Drives procurement orders for every sale order line.&quot;&quot;&quot;" name="note"/>
<field name="subflow_id" ref="process_process_salesprocess0"/>
<field name="process_id" ref="mrp.process_process_procurementprocess0"/>
<field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field eval="&quot;&quot;&quot;object.state in ('draft', 'waiting_date', 'manual', 'progress', 'shipping_except', 'invoice_except', 'done', 'cancel')&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
</record>
@ -63,12 +63,12 @@
</record>
<record id="process_node_saleprocurement0" model="process.node">
<field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp.model_mrp_procurement"/>
<field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
<field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
<field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
<field eval="&quot;&quot;&quot;Procurement Order&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;One Procurement order for each sale order line and for each of the components.&quot;&quot;&quot;" name="note"/>
<field name="subflow_id" ref="mrp.process_process_procurementprocess0"/>
<field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
<field name="process_id" ref="process_process_salesprocess0"/>
<field eval="&quot;&quot;&quot;object.state=='confirmed'&quot;&quot;&quot;" name="model_states"/>
<field eval="1" name="flow_start"/>
@ -202,7 +202,7 @@
<field eval="[(6,0,[])]" name="transition_ids"/>
<field eval="&quot;&quot;&quot;Procurement of sold material&quot;&quot;&quot;" name="name"/>
<field eval="&quot;&quot;&quot;For every sale order line, a procurement order is created to supply the sold product.&quot;&quot;&quot;" name="note"/>
<field model="process.node" name="target_node_id" ref="mrp.process_node_procureproducts0"/>
<field model="process.node" name="target_node_id" ref="mrp_procurement.process_node_procureproducts0"/>
<field model="process.node" name="source_node_id" ref="process_node_saleorderprocurement0"/>
</record>

View File

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--
Resource: res.company
-->
<record id="res_company_shop_sale0" model="res.company">
<field eval="5.0" name="security_lead"/>
<field name="partner_id" ref="stock.res_partner_tinyshop0"/>
<field name="parent_id" ref="stock.res_company_shop0"/>
<field eval="&quot;&quot;&quot;Shop 1&quot;&quot;&quot;" name="name"/>
</record>
<!--
Resource: sale.order

View File

@ -163,8 +163,8 @@
<field groups="product.group_uos" name="product_uos"/>
<field name="th_weight"/>
<field name="address_allotment_id"/>
<separator colspan="4" string="Properties"/>
<field colspan="4" name="property_ids" nolabel="1"/>
<!-- <separator colspan="4" string="Properties"/>-->
<!-- <field colspan="4" name="property_ids" nolabel="1"/>-->
</page>
<page string="Notes">
<field colspan="4" name="notes" nolabel="1"/>
@ -395,9 +395,9 @@
icon="gtk-cancel" />
</group>
</page>
<page string="Properties" groups="base.group_extended">
<field name="property_ids" nolabel="1"/>
</page>
<!-- <page string="Properties" groups="base.group_extended">-->
<!-- <field name="property_ids" nolabel="1"/>-->
<!-- </page>-->
<page string="Notes">
<field colspan="4" name="notes" nolabel="1"/>
</page>

View File

@ -11,10 +11,7 @@
"access_account_analytic_account_salesman","account_analytic_account salesman","analytic.model_account_analytic_account","group_sale_user",1,1,1,1
"access_stock_picking_salesman","stock_picking salesman","stock.model_stock_picking","group_sale_user",1,1,1,1
"access_stock_move_salesman","stock_move salesman","stock.model_stock_move","group_sale_user",1,1,1,0
"access_mrp_property_salesman","mrp.property salesman","mrp.model_mrp_property","group_sale_user",1,0,0,0
"access_mrp_procurement_salesman","mrp.procurement salesman","mrp.model_mrp_procurement","group_sale_user",1,1,1,1
"access_sale_order_mrp_user","sale.order mrp worker","model_sale_order","mrp.group_mrp_user",1,0,0,0
"access_sale_order_line_mrp_user","sale.order.line mrp worker","model_sale_order_line","mrp.group_mrp_user",1,0,0,0
"access_mrp_procurement_salesman","mrp.procurement salesman","mrp_procurement.model_mrp_procurement","group_sale_user",1,1,1,1
"access_sale_order_stock_worker","sale.order stock worker","model_sale_order","stock.group_stock_user",1,1,0,0
"access_sale_order_line_stock_worker","sale.order.line stock worker","model_sale_order_line","stock.group_stock_user",1,1,0,0
"access_sale_order_manager","sale.order.manager","model_sale_order","group_sale_manager",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
11 access_account_analytic_account_salesman account_analytic_account salesman analytic.model_account_analytic_account group_sale_user 1 1 1 1
12 access_stock_picking_salesman stock_picking salesman stock.model_stock_picking group_sale_user 1 1 1 1
13 access_stock_move_salesman stock_move salesman stock.model_stock_move group_sale_user 1 1 1 0
14 access_mrp_property_salesman access_mrp_procurement_salesman mrp.property salesman mrp.procurement salesman mrp.model_mrp_property mrp_procurement.model_mrp_procurement group_sale_user 1 0 1 0 1 0 1
access_mrp_procurement_salesman mrp.procurement salesman mrp.model_mrp_procurement group_sale_user 1 1 1 1
access_sale_order_mrp_user sale.order mrp worker model_sale_order mrp.group_mrp_user 1 0 0 0
access_sale_order_line_mrp_user sale.order.line mrp worker model_sale_order_line mrp.group_mrp_user 1 0 0 0
15 access_sale_order_stock_worker sale.order stock worker model_sale_order stock.group_stock_user 1 1 0 0
16 access_sale_order_line_stock_worker sale.order.line stock worker model_sale_order_line stock.group_stock_user 1 1 0 0
17 access_sale_order_manager sale.order.manager model_sale_order group_sale_manager 1 1 1 1

View File

@ -198,13 +198,9 @@
<field eval="1" name="active"/>
</record>
<record id="res_company_shop0" model="res.company">
<field eval="5.0" name="security_lead"/>
<field name="currency_id" ref="base.EUR"/>
<field eval="1.0" name="po_lead"/>
<field name="partner_id" ref="res_partner_tinyshop0"/>
<field eval="1.0" name="manufacturing_lead"/>
<field name="parent_id" ref="base.main_company"/>
<field eval="80.0" name="schedule_range"/>
<field eval="&quot;&quot;&quot;Shop 1&quot;&quot;&quot;" name="name"/>
</record>
<record id="res_partner_tinyshop1" model="res.partner">