[WIP] Pricelist of purchase is not in stock only and remove product_manufacturer...
authorJosse Colpaert <jco@odoo.com>
Thu, 4 Sep 2014 12:54:39 +0000 (14:54 +0200)
committerJosse Colpaert <jco@odoo.com>
Fri, 12 Sep 2014 11:49:42 +0000 (13:49 +0200)
addons/mrp/report/bom_structure.py
addons/mrp/res_config.py
addons/mrp/res_config_view.xml
addons/product/product.py
addons/purchase/stock.py
addons/stock/stock.py
addons/stock_account/stock.py

index 1b286fe..c8a3132 100644 (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:
index 71635cc..5edebfa 100644 (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'
index d9af7a6..7dfba32 100644 (file)
                         <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" />
                             </div>
index feabe13..009377c 100644 (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)
index 75fabe4..0875ff8 100644 (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'
     
index 531b2fa..56d525a 100644 (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):
index e4d58e3..c662ec8 100644 (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)