[WIP] Pricelist of purchase is not in stock only and remove product_manufacturer module in view + manufacturer

This commit is contained in:
Josse Colpaert 2014-09-04 14:54:39 +02:00
parent a0d855ffad
commit 246c425226
7 changed files with 43 additions and 28 deletions

View File

@ -59,10 +59,10 @@ class bom_structure(report_sxw.rml_parse):
return children
class report_lunchorder(osv.AbstractModel):
class report_mrpbomstructure(osv.AbstractModel):
_name = 'report.mrp.report_mrpbomstructure'
_inherit = 'report.abstract_report'
_template = 'mpr.report_mrpbomstructure'
_template = 'mrp.report_mrpbomstructure'
_wrapped_report_class = bom_structure
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -52,6 +52,7 @@ class mrp_config_settings(osv.osv_memory):
'group_mrp_properties': fields.boolean("Allow several bill of materials per products using properties",
implied_group='product.group_mrp_properties',
help="""The selection of the right Bill of Material to use will depend on the properties specified on the sales order and the Bill of Material."""),
#FIXME: Should be removed as module product_manufacturer has been removed
'module_product_manufacturer': fields.boolean("Define manufacturers on products ",
help='This allows you to define the following for a product:\n'
'* Manufacturer\n'

View File

@ -54,10 +54,6 @@
<group >
<label for="id" string="Products"/>
<div>
<div>
<field name="module_product_manufacturer" class="oe_inline"/>
<label for="module_product_manufacturer"/>
</div>
<div>
<field name="group_mrp_properties" class="oe_inline"/>
<label for="group_mrp_properties" />

View File

@ -1211,6 +1211,7 @@ class product_supplierinfo(osv.osv):
for supplier in partner_pool.browse(cr, uid, supplier_ids, context=context):
price = product_price
# Compute price from Purchase pricelist of supplier
#FIXME: property_product_pricelist_purchase is defined in purchase
pricelist_id = supplier.property_product_pricelist_purchase.id
if pricelist_id:
price = pricelist_pool.price_get(cr, uid, [pricelist_id], product_id, product_qty, context=context).setdefault(pricelist_id, 0)

View File

@ -69,8 +69,15 @@ class stock_move(osv.osv):
if move.purchase_line_id:
purchase_order = move.purchase_line_id.order_id
return purchase_order.partner_id, purchase_order.create_uid.id, purchase_order.currency_id.id
else:
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id) or False
if partner:
if partner.property_product_pricelist_purchase and move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal':
currency = partner.property_product_pricelist_purchase.currency_id.id
return partner, uid, currency
return super(stock_move, self)._get_master_data(cr, uid, move, company, context=context)
def _get_invoice_line_vals(self, cr, uid, move, partner, inv_type, context=None):
res = super(stock_move, self)._get_invoice_line_vals(cr, uid, move, partner, inv_type, context=context)
if move.purchase_line_id:
@ -79,6 +86,30 @@ class stock_move(osv.osv):
res['price_unit'] = purchase_line.price_unit
return res
def attribute_price(self, cr, uid, move, context=None):
"""
Attribute price to move, important in inter-company moves or receipts with only one partner
"""
if move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal' and not move.price_unit:
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id)
price = False
# If partner given, search price in its purchase pricelist
if partner and partner.property_product_pricelist_purchase:
pricelist_obj = self.pool.get("product.pricelist")
pricelist = partner.property_product_pricelist.id
price = pricelist_obj.price_get(cr, uid, [pricelist],
move.product_id.id, move.product_uom_qty, partner, {
'uom': move.product_uom.id,
'date': move.date,
})[pricelist]
if price:
self.write(cr, uid, [move.id], {'price_unit': price}, context=context)
return True
super(stock_move, self).attribute_price(cr, uid, move, context=context)
class stock_picking(osv.osv):
_inherit = 'stock.picking'

View File

@ -2016,23 +2016,10 @@ class stock_move(osv.osv):
def attribute_price(self, cr, uid, move, context=None):
"""
Attribute price to move, important in multi-company
Attribute price to move, important in inter-company moves or receipts with only one partner
"""
if move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal' and not move.price_unit:
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id)
price = False
# If partner given, search price in its purchase pricelist
if partner and partner.property_product_pricelist_purchase:
pricelist_obj = self.pool.get("product.pricelist")
pricelist = partner.property_product_pricelist.id
price = pricelist_obj.price_get(cr, uid, [pricelist],
move.product_id.id, move.product_uom_qty, partner, {
'uom': move.product_uom.id,
'date': move.date,
})[pricelist]
if not price:
price = move.product_id.standard_price
self.write(cr, uid, [move.id], {'price_unit': price})
price = move.product_id.standard_price
self.write(cr, uid, [move.id], {'price_unit': price})
def action_confirm(self, cr, uid, ids, context=None):

View File

@ -97,12 +97,11 @@ class stock_move(osv.osv):
def _get_master_data(self, cr, uid, move, company, context=None):
''' returns a tuple (browse_record(res.partner), ID(res.users), ID(res.currency)'''
currency = company.currency_id.id
if move.partner_id:
if move.partner_id.property_product_pricelist_purchase and move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal':
currency = move.partner_id.property_product_pricelist_purchase.currency_id.id
elif move.partner_id.property_product_pricelist and move.location_id.usage == 'internal' and move.location_dest_id.usage != 'internal':
currency = move.partner_id.property_product_pricelist.currency_id.id
return move.picking_id.partner_id, uid, currency
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id) or False
if partner:
if partner.property_product_pricelist and move.location_id.usage == 'internal' and move.location_dest_id.usage != 'internal':
currency = partner.property_product_pricelist.currency_id.id
return partner, uid, currency
def _create_invoice_line_from_vals(self, cr, uid, move, invoice_line_vals, context=None):
return self.pool.get('account.invoice.line').create(cr, uid, invoice_line_vals, context=context)