diff --git a/addons/hr_payroll_account/hr_payroll_account_workflow.xml b/addons/hr_payroll_account/hr_payroll_account_workflow.xml deleted file mode 100644 index ff627f2619d..00000000000 --- a/addons/hr_payroll_account/hr_payroll_account_workflow.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - account_check - account_check_sheet() - function - - - - - - True - account_verify_sheet - - - - - - True - final_verify_sheet - - - - - - cancel_sheet - - - diff --git a/addons/mrp/mrp_workflow.xml b/addons/mrp/mrp_workflow.xml index 365c1195c44..a0943628fc8 100644 --- a/addons/mrp/mrp_workflow.xml +++ b/addons/mrp/mrp_workflow.xml @@ -123,28 +123,24 @@ action_produce_assign_product() - - - + + + - check_product() + check_produce() and is_product() and check_bom_exists() - + + + + + subflow.done + + subflow.cancel - - - - - subflow.done - - - - not test_cancel() and not get_phantom_bom_id() - - + diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 97d27d0d08d..78fb8382cda 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -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' \ diff --git a/addons/mrp_jit/mrp_jit.xml b/addons/mrp_jit/mrp_jit.xml index 99f74a19517..c00393ac04d 100644 --- a/addons/mrp_jit/mrp_jit.xml +++ b/addons/mrp_jit/mrp_jit.xml @@ -2,8 +2,12 @@ - - + + + + + check_conditions_confirm2wait() diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index bdaa8fd32df..16f2f67212e 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -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. diff --git a/addons/procurement/procurement_workflow.xml b/addons/procurement/procurement_workflow.xml index 53b6608fa6f..76b54370ef2 100644 --- a/addons/procurement/procurement_workflow.xml +++ b/addons/procurement/procurement_workflow.xml @@ -46,17 +46,6 @@ function action_move_assigned() - - - produce_check - - - - - produce_service - function - action_produce_assign_service() - @@ -108,7 +97,7 @@ button_check - not test_cancel() + check_conditions_confirm2wait() @@ -140,11 +129,6 @@ button_cancel - - - - check_buy() - @@ -160,12 +144,18 @@ check_make_to_stock() - + + + - - check_produce() + + not check_produce() and not check_buy() - + @@ -173,29 +163,6 @@ - - - - - - - - not check_product() - - - - - subflow.cancel - - - - - diff --git a/addons/project_mrp/project_mrp_workflow.xml b/addons/project_mrp/project_mrp_workflow.xml index 18962cde0ee..f8decb98623 100644 --- a/addons/project_mrp/project_mrp_workflow.xml +++ b/addons/project_mrp/project_mrp_workflow.xml @@ -1,6 +1,27 @@ + + + produce_service + function + action_produce_assign_service() + + + + + + check_produce() and not is_product() + + + + + + + + + subflow.cancel + diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 41a30755bc5..2347de95879 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -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 diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml index aa2de4d17a0..11936db0bed 100644 --- a/addons/purchase/purchase_workflow.xml +++ b/addons/purchase/purchase_workflow.xml @@ -201,7 +201,7 @@ - + @@ -210,19 +210,19 @@ action_po_assign() - - + + - check_buy() + check_buy() and check_supplier_info() - + subflow.delivery_done - +