[REF] refactor the methode make_po in order to make easier the overwritting
bzr revid: sebastien.beau@akretion.com.br-20110706002624-8ag88jv5a5i979iy
This commit is contained in:
parent
7c7e977b23
commit
0757ae25ab
|
@ -761,6 +761,10 @@ class procurement_order(osv.osv):
|
||||||
res = res.values()
|
res = res.values()
|
||||||
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
|
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
|
||||||
|
|
||||||
|
def create_procurement_purchase_order(self, cr, uid, procurement, po_vals, line, context=None):
|
||||||
|
po_vals.update({'order_line': [(0,0,line)]})
|
||||||
|
return self.pool.get('purchase.order').create(cr, uid, po_vals, context=context)
|
||||||
|
|
||||||
def make_po(self, cr, uid, ids, context=None):
|
def make_po(self, cr, uid, ids, context=None):
|
||||||
""" Make purchase order from procurement
|
""" Make purchase order from procurement
|
||||||
@return: New created Purchase Orders procurement wise
|
@return: New created Purchase Orders procurement wise
|
||||||
|
@ -774,7 +778,6 @@ class procurement_order(osv.osv):
|
||||||
pricelist_obj = self.pool.get('product.pricelist')
|
pricelist_obj = self.pool.get('product.pricelist')
|
||||||
prod_obj = self.pool.get('product.product')
|
prod_obj = self.pool.get('product.product')
|
||||||
acc_pos_obj = self.pool.get('account.fiscal.position')
|
acc_pos_obj = self.pool.get('account.fiscal.position')
|
||||||
po_obj = self.pool.get('purchase.order')
|
|
||||||
for procurement in self.browse(cr, uid, ids, context=context):
|
for procurement in self.browse(cr, uid, ids, context=context):
|
||||||
res_id = procurement.move_id.id
|
res_id = procurement.move_id.id
|
||||||
partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement.
|
partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement.
|
||||||
|
@ -799,6 +802,8 @@ class procurement_order(osv.osv):
|
||||||
context.update({'lang': partner.lang, 'partner_id': partner_id})
|
context.update({'lang': partner.lang, 'partner_id': partner_id})
|
||||||
|
|
||||||
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
|
product = prod_obj.browse(cr, uid, procurement.product_id.id, context=context)
|
||||||
|
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 = {
|
line = {
|
||||||
'name': product.partner_ref,
|
'name': product.partner_ref,
|
||||||
|
@ -809,25 +814,20 @@ class procurement_order(osv.osv):
|
||||||
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
|
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
'move_dest_id': res_id,
|
'move_dest_id': res_id,
|
||||||
'notes': product.description_purchase,
|
'notes': product.description_purchase,
|
||||||
|
'taxes_id': [(6,0,taxes)],
|
||||||
}
|
}
|
||||||
|
|
||||||
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
|
po_vals = {
|
||||||
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,
|
'origin': procurement.origin,
|
||||||
'partner_id': partner_id,
|
'partner_id': partner_id,
|
||||||
'partner_address_id': address_id,
|
'partner_address_id': address_id,
|
||||||
'location_id': procurement.location_id.id,
|
'location_id': procurement.location_id.id,
|
||||||
'pricelist_id': pricelist_id,
|
'pricelist_id': pricelist_id,
|
||||||
'order_line': [(0,0,line)],
|
|
||||||
'company_id': procurement.company_id.id,
|
'company_id': procurement.company_id.id,
|
||||||
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False
|
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False
|
||||||
})
|
}
|
||||||
res[procurement.id] = purchase_id
|
res[procurement.id] = self.create_procurement_purchase_order(cr, uid, procurement, po_vals, line, context=context)
|
||||||
self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': purchase_id})
|
self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': res[procurement.id]})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
procurement_order()
|
procurement_order()
|
||||||
|
|
Loading…
Reference in New Issue