[IMP] make sequence on supplier visible and use sequences for PO
bzr revid: nel@tinyerp.com-20100607184214-5u3171l0foqvnjsm
This commit is contained in:
parent
b5ed5d2cca
commit
00c072a4a8
|
@ -262,8 +262,9 @@ class mrp_procurement(osv.osv):
|
|||
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
|
||||
partner_list = sorted([(partner_id.sequence, partner_id) for partner_id in procurement.product_id.seller_ids if partner_id])
|
||||
if partner_list:
|
||||
partner = partner_list and partner_list[0] and partner_list[0][1] and partner_list[0][1].name or False
|
||||
if user.company_id and user.company_id.partner_id:
|
||||
if partner.id == user.company_id.partner_id.id:
|
||||
return True
|
||||
|
@ -288,7 +289,9 @@ class mrp_procurement(osv.osv):
|
|||
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
|
||||
partner_list = sorted([(partner_id.sequence, partner_id) for partner_id in procurement.product_id.seller_ids if partner_id and partner_id.sequence])
|
||||
partner = partner_list and partner_list[0] and partner_list[0][1] and partner_list[0][1].name or False
|
||||
|
||||
if user.company_id and user.company_id.partner_id:
|
||||
if partner.id == user.company_id.partner_id.id:
|
||||
return False
|
||||
|
|
|
@ -245,7 +245,8 @@ class product_template(osv.osv):
|
|||
result = {}
|
||||
for product in self.browse(cr, uid, ids, context):
|
||||
if product.seller_ids:
|
||||
result[product.id] = product.seller_ids[0].delay
|
||||
partner_list = sorted([(partner_id.sequence, partner_id) for partner_id in product.seller_ids if partner_id and partner_id.sequence])
|
||||
result[product.id] = partner_list and partner_list[0] and partner_list[0][1] and partner_list[0][1].delay or False
|
||||
else:
|
||||
result[product.id] = 1
|
||||
return result
|
||||
|
|
|
@ -426,7 +426,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Supplier Information">
|
||||
<field name="name"/>
|
||||
<field name="sequence" invisible="1"/>
|
||||
<field name="sequence"/>
|
||||
<field name="product_name" groups="base.group_extended"/>
|
||||
<field name="product_code" groups="base.group_extended"/>
|
||||
<field name="delay"/>
|
||||
|
@ -451,7 +451,7 @@
|
|||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Supplier Information">
|
||||
<field name="sequence" string="Seq" invisible="1"/>
|
||||
<field name="sequence" string="Seq"/>
|
||||
<field name="name"/>
|
||||
<field name="delay"/>
|
||||
<field name="qty"/>
|
||||
|
|
|
@ -726,22 +726,24 @@ class mrp_procurement(osv.osv):
|
|||
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
|
||||
partner_list = sorted([(partner_id.sequence, partner_id) for partner_id in procurement.product_id.seller_ids if partner_id])
|
||||
partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False
|
||||
partner = partner_rec.name or False
|
||||
partner_id = partner_rec.id or False
|
||||
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)
|
||||
if partner_rec.qty:
|
||||
qty = max(qty,partner_rec.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
|
||||
newdate = newdate - partner_rec.delay
|
||||
|
||||
#Passing partner_id to context for purchase order line integrity of Line name
|
||||
context.update({'lang': partner.lang, 'partner_id': partner_id})
|
||||
|
|
|
@ -82,15 +82,15 @@ class purchase_requisition_partner(osv.osv_memory):
|
|||
purchase_order_line={}
|
||||
for tender in tender_obj.browse(cr, uid, record_ids):
|
||||
for line in tender.line_ids:
|
||||
|
||||
partner_list = sorted([(partner.sequence, partner) for partner in line.product_id.seller_ids if partner])
|
||||
partner_rec = partner_list and partner_list[0] and partner_list[0][1] or False
|
||||
uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False
|
||||
newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S')
|
||||
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
|
||||
newdate = newdate -(line.product_id.seller_ids and line.product_id.seller_ids[0].delay or DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
|
||||
|
||||
|
||||
partner = line.product_id.seller_ids and line.product_id.seller_ids[0].name or supplier_data
|
||||
pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id
|
||||
delay = partner_rec and partner_rec.delay or False
|
||||
newdate = newdate -(delay or DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
|
||||
partner = partner_rec and partner_rec.name or supplier_data
|
||||
pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id or False
|
||||
price = pricelist_obj.price_get(cr, uid, [pricelist_id], line.product_id.id, line.product_qty, False, {'uom': uom_id})[pricelist_id]
|
||||
product = prod_obj.browse(cr, uid, line.product_id.id, context=context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue