[MERGE] procurement workflow fixes + removal of a unused file hr_payroll_account/hr_payroll_account_workflow.xml

bzr revid: qdp-launchpad@openerp.com-20121218161136-dqcinl0gputptkt3
This commit is contained in:
Quentin (OpenERP) 2012-12-18 17:11:36 +01:00
commit b8e3477f06
9 changed files with 130 additions and 149 deletions

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="act_account_check" model="workflow.activity">
<field name="wkf_id" ref="hr_payroll.wkf"/>
<field name="name">account_check</field>
<field name="action">account_check_sheet()</field>
<field name="kind">function</field>
</record>
<record id="hr_payroll.t4" model="workflow.transition">
<field name="act_from" ref="hr_payroll.act_confirm"/>
<field name="act_to" ref="act_account_check"/>
<field name="condition">True</field>
<field name="signal">account_verify_sheet</field>
</record>
<record id="t3" model="workflow.transition">
<field name="act_from" ref="act_account_check"/>
<field name="act_to" ref="hr_payroll.act_done"/>
<field name="condition">True</field>
<field name="signal">final_verify_sheet</field>
</record>
<record id="hr_payroll.t9" model="workflow.transition">
<field name="act_from" ref="act_account_check"/>
<field name="act_to" ref="hr_payroll.act_cancel"/>
<field name="signal">cancel_sheet</field>
</record>
</data>
</openerp>

View File

@ -123,28 +123,24 @@
<field name="subflow_id" search="[('osv','=','mrp.production')]"/>
<field name="action">action_produce_assign_product()</field>
</record>
<record id="trans_product_check_produce" model="workflow.transition">
<field name="act_from" ref="procurement.act_produce_check"/>
<record id="trans_confirm_mto_need_production" model="workflow.transition">
<field name="act_from" ref="procurement.act_confirm_mto"/>
<field name="act_to" ref="act_produce"/>
<field name="condition">check_product()</field>
<field name="condition">check_produce() and is_product() and check_bom_exists()</field>
</record>
<record id="trans_produce_finished_prod" model="workflow.transition">
<field name="act_from" ref="act_produce"/>
<field name="act_to" ref="procurement.act_make_done"/>
<field name="signal">subflow.done</field>
</record>
<record id="trans_produce_cancel" model="workflow.transition">
<field name="act_from" ref="act_produce"/>
<field name="act_to" ref="procurement.act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="procurement.trans_produce_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce"/>
<field name="act_to" ref="procurement.act_make_done"/>
<field name="signal">subflow.done</field>
</record>
<record id="procurement.trans_confirm_confirm_wait" model="workflow.transition">
<field name="condition">not test_cancel() and not get_phantom_bom_id()</field>
</record>
</data>
</openerp>

View File

@ -33,21 +33,32 @@ class procurement_order(osv.osv):
'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'),
'production_id': fields.many2one('mrp.production', 'Manufacturing Order'),
}
def check_produce_product(self, cr, uid, procurement, context=None):
''' Depict the capacity of the procurement workflow to produce products (not services)'''
return True
def check_bom_exists(self, cr, uid, ids, context=None):
""" Finds the bill of material for the product from procurement order.
@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 procurement_order set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
for (id, name) in self.name_get(cr, uid, procurement.id):
message = _("Procurement '%s' has an exception: 'No BoM defined for this product !'") % name
self.message_post(cr, uid, [procurement.id], body=message, context=context)
return False
for procurement in self.browse(cr, uid, ids, context=context):
product = procurement.product_id
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 procurement_order set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
for (id, name) in self.name_get(cr, uid, procurement.id):
message = _("Procurement '%s' has an exception: 'No BoM defined for this product !'") % name
self.message_post(cr, uid, [procurement.id], body=message, context=context)
return False
return True
def check_conditions_confirm2wait(self, cr, uid, ids):
""" condition on the transition to go from 'confirm' activity to 'confirm_wait' activity """
res = super(procurement_order, self).check_conditions_confirm2wait(cr, uid, ids)
return res and not self.get_phantom_bom_id(cr, uid, ids)
def get_phantom_bom_id(self, cr, uid, ids, context=None):
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.move_id and procurement.move_id.product_id.supply_method=='produce' \

View File

@ -2,8 +2,12 @@
<openerp>
<data>
<record model="workflow.transition" id="procurement.trans_confirm_confirm_wait">
<field name="signal" eval="False"/>
<record model="workflow.transition" id="trans_direct_confirm_to_wait">
<!-- Duplicates the transition between the act_confirm and act_confirm_wait activites
but, this time, without the signal -->
<field name="act_from" ref="procurement.act_confirm"/>
<field name="act_to" ref="procurement.act_confirm_wait"/>
<field name="condition">check_conditions_confirm2wait()</field>
</record>
</data>

View File

@ -153,9 +153,9 @@ class procurement_order(osv.osv):
return {'value': v}
return {}
def check_product(self, cr, uid, ids, context=None):
""" Checks product type.
@return: True or False
def is_product(self, cr, uid, ids, context=None):
""" Checks product type to decide which transition of the workflow to follow.
@return: True if all product ids received in argument are of type 'product' or 'consummable'. False if any is of type 'service'
"""
return all(proc.product_id.type in ('product', 'consu') for proc in self.browse(cr, uid, ids, context=context))
@ -234,14 +234,16 @@ class procurement_order(osv.osv):
return False
def check_produce_service(self, cr, uid, procurement, context=None):
""" Depicts the capacity of the procurement workflow to deal with production of services.
By default, it's False. Overwritten by project_mrp module.
"""
return False
def check_produce_product(self, cr, uid, procurement, context=None):
""" Finds BoM of a product if not found writes exception message.
@param procurement: Current procurement.
@return: True or False.
""" Depicts the capacity of the procurement workflow to deal with production of products.
By default, it's False. Overwritten by mrp module.
"""
return True
return False
def check_make_to_stock(self, cr, uid, ids, context=None):
""" Checks product type.
@ -264,10 +266,6 @@ class procurement_order(osv.osv):
product = procurement.product_id
#TOFIX: if product type is 'service' but supply_method is 'buy'.
if product.supply_method <> 'produce':
supplier = product.seller_id
if supplier and user.company_id and user.company_id.partner_id:
if supplier.id == user.company_id.partner_id.id:
continue
return False
if product.type=='service':
res = self.check_produce_service(cr, uid, procurement, context)
@ -278,37 +276,14 @@ class procurement_order(osv.osv):
return True
def check_buy(self, cr, uid, ids):
""" Checks product type.
@return: True or Product Id.
""" Depicts the capacity of the procurement workflow to manage the supply_method == 'buy'.
By default, it's False. Overwritten by purchase module.
"""
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:
message = _('No supplier defined for this product !')
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement.
return False
if not partner:
message = _('No default supplier defined for this product')
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
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:
message = _('No address defined for the supplier')
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
return True
def check_conditions_confirm2wait(self, cr, uid, ids):
""" condition on the transition to go from 'confirm' activity to 'confirm_wait' activity """
return not self.test_cancel(cr, uid, ids)
def test_cancel(self, cr, uid, ids):
""" Tests whether state of move is cancelled or not.

View File

@ -46,17 +46,6 @@
<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>
<!-- act_produce_service should be move in project_mrp module. -->
<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"/>
@ -108,7 +97,7 @@
<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>
<field name="condition">check_conditions_confirm2wait()</field>
</record>
<record id="trans_confirm_wait_confirm_mto" model="workflow.transition">
<field name="act_from" ref="act_confirm_wait"/>
@ -140,11 +129,6 @@
<field name="act_to" ref="act_cancel"/>
<field name="signal">button_cancel</field>
</record>
<record id="trans_confirm_mto_purchase" model="workflow.transition">
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_make_done"/>
<field name="condition">check_buy()</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"/>
@ -160,12 +144,18 @@
<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">
<record id="trans_confirm_mto_make_done" model="workflow.transition">
<!-- This transition is there to unblock products that would be in MTO with a supply method that would be
produce or buy without MRP or purchase module installed. These modules overwrite the check_produce()
and check_buy() methods -so that it invalidates their part of this 'bypass transition'-, and define
their own workflow paths.
-->
<field name="act_from" ref="act_confirm_mto"/>
<field name="act_to" ref="act_produce_check"/>
<field name="condition">check_produce()</field>
<field name="act_to" ref="act_make_done"/>
<field name="condition">not check_produce() and not check_buy()</field>
</record>
<record id="trans_make_to_stock_make_done" model="workflow.transition">
<field name="act_from" ref="act_make_to_stock"/> <!-- TOFIX: If product is service product and procure method is 'make_to_stock', procurement is closed without generated service -->
<field name="act_to" ref="act_make_done"/>
@ -173,29 +163,6 @@
<field name="trigger_model" eval="False"/>
<field name="trigger_expr_id" eval="False"/>
</record>
<!-- TOFIX: Without installing 'mrp' module, If product is produce(mto), procurement never close (Its gone in idle) so sale order never close and also invoice never created if post paid invoice. solution of this issue is below, just add one transition from act_produce_check to act_make_done -->
<!--
<record id="trans_produce_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce_check"/>
<field name="act_to" ref="procurement.act_make_done"/>
<field name="condition">check_product()</field>
</record> -->
<!-- TOFIX: service related transition should be move into project_mrp module. -->
<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_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"/>

View File

@ -1,6 +1,27 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="act_produce_service" model="workflow.activity">
<field name="wkf_id" ref="procurement.wkf_procurement"/>
<field name="name">produce_service</field>
<field name="kind">function</field>
<field name="action">action_produce_assign_service()</field>
</record>
<record id="trans_product_check_produce_service" model="workflow.transition">
<field name="act_from" ref="procurement.act_confirm_mto"/>
<field name="act_to" ref="act_produce_service"/>
<field name="condition">check_produce() and not is_product()</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="procurement.act_make_done"/>
</record>
<record id="trans_produce_service_cancel" model="workflow.transition">
<field name="act_from" ref="act_produce_service"/>
<field name="act_to" ref="procurement.act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_make_done_done2" model="workflow.transition">
<field name="act_from" ref="procurement.act_make_done"/>
<field name="act_to" ref="procurement.act_done"/>

View File

@ -1041,6 +1041,44 @@ class procurement_order(osv.osv):
'purchase_id': fields.many2one('purchase.order', 'Purchase Order'),
}
def check_buy(self, cr, uid, ids, context=None):
''' return True if the supply method of the mto product is 'buy'
'''
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
return False
return True
def check_supplier_info(self, cr, uid, ids, context=None):
partner_obj = self.pool.get('res.partner')
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
for procurement in self.browse(cr, uid, ids, context=context):
if not procurement.product_id.seller_ids:
message = _('No supplier defined for this product !')
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement.
if not partner:
message = _('No default supplier defined for this product')
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
if user.company_id and user.company_id.partner_id:
if partner.id == user.company_id.partner_id.id:
raise osv.except_osv(_('Configuration Error!'), _('The product "%s" has been defined with your company as reseller which seems to be a configuration error!' % procurement.product_id.name))
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
if not address_id:
message = _('No address defined for the supplier')
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
return True
def action_po_assign(self, cr, uid, ids, context=None):
""" This is action which call from workflow to assign purchase order to procurements
@return: True

View File

@ -201,7 +201,7 @@
<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="procurement.wkf_procurement"/>
@ -210,19 +210,19 @@
<field name="subflow_id" search="[('osv','=','purchase.order')]"/>
<field name="action">action_po_assign()</field>
</record>
<record id="procurement.trans_confirm_mto_purchase" model="workflow.transition">
<record id="trans_confirm_mto_purchase" model="workflow.transition">
<field name="act_from" ref="procurement.act_confirm_mto"/>
<field name="act_to" ref="act_buy"/>
<field name="condition">check_buy()</field>
<field name="condition">check_buy() and check_supplier_info()</field>
</record>
<record id="trans_buy_make_done" model="workflow.transition">
<field name="act_from" ref="act_buy"/>
<field name="act_to" ref="procurement.act_make_done"/>
<field name="signal">subflow.delivery_done</field>
</record>
<record id="trans_buy_cancel" model="workflow.transition">
<field name="act_from" ref="act_buy"/>
<field name="act_to" ref="procurement.act_cancel"/>