[IMP] Clean need_procurement and add partner on procurement for Phantom with service

This commit is contained in:
Josse Colpaert 2014-08-11 15:06:03 +02:00
parent 6553e22306
commit 86b8e73482
4 changed files with 7 additions and 20 deletions

View File

@ -109,6 +109,7 @@ class StockMove(osv.osv):
'product_uos': line['product_uos'],
'group_id': move.group_id.id,
'priority': move.priority,
'partner_dest_id': move.partner_id.id,
}
proc = proc_obj.create(cr, uid, vals, context=context)
proc_obj.run(cr, uid, [proc], context=context)

View File

@ -815,7 +815,10 @@ class sale_order_line(osv.osv):
def need_procurement(self, cr, uid, ids, context=None):
#when sale is installed only, there is no need to create procurements, that's only
#further installed modules (sale_service, sale_stock) that will change this.
return False
prod_obj = self.pool.get('product.product')
for line in self.browse(cr, uid, ids, context=context):
if prod_obj.need_procurement(cr, uid, [line.product_id.id], context=context):
return True
def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
tax_obj = self.pool.get('account.tax')

View File

@ -81,7 +81,7 @@ class procurement_order(osv.osv):
'date_deadline': procurement.date_planned,
'planned_hours': planned_hours,
'remaining_hours': planned_hours,
'partner_id': procurement.sale_line_id and procurement.sale_line_id.order_id.partner_id.id or False,
'partner_id': procurement.sale_line_id and procurement.sale_line_id.order_id.partner_id.id or procurement.partner_dest_id.id,
'user_id': procurement.product_id.product_manager.id,
'procurement_id': procurement.id,
'description': procurement.name + '\n',
@ -156,15 +156,5 @@ class product_product(osv.osv):
return super(product_product, self).need_procurement(cr, uid, ids, context=context)
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
def need_procurement(self, cr, uid, ids, context=None):
#when sale is installed alone, there is no need to create procurements, but with sale_service
#we must create a procurement for each service that has the auto_create_task boolean set to True.
for line in self.browse(cr, uid, ids, context=context):
if line.product_id and line.product_id.type == 'service' and line.product_id.auto_create_task:
return True
return super(sale_order_line, self).need_procurement(cr, uid, ids, context=context)

View File

@ -206,7 +206,7 @@ class product_product(osv.osv):
_inherit = 'product.product'
def need_procurement(self, cr, uid, ids, context=None):
#when sale is installed alone, there is no need to create procurements, but with sale_stock
#when sale/product is installed alone, there is no need to create procurements, but with sale_stock
#we must create a procurement for each product that is not a service.
for product in self.browse(cr, uid, ids, context=context):
if product.type != 'service':
@ -216,13 +216,6 @@ class product_product(osv.osv):
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
def need_procurement(self, cr, uid, ids, context=None):
#when sale is installed alone, there is no need to create procurements, but with sale_stock
#we must create a procurement for each product that is not a service.
for line in self.browse(cr, uid, ids, context=context):
if line.product_id and line.product_id.type != 'service':
return True
return super(sale_order_line, self).need_procurement(cr, uid, ids, context=context)
def _number_packages(self, cr, uid, ids, field_name, arg, context=None):
res = {}