diff --git a/addons/mrp/product.py b/addons/mrp/product.py index fc07a88f3a0..47ccb758ccc 100644 --- a/addons/mrp/product.py +++ b/addons/mrp/product.py @@ -41,36 +41,17 @@ class product_template(osv.osv): return res _columns = { -<<<<<<< HEAD - 'produce_delay': fields.float('Manufacturing Lead Time', help="Average delay in days to produce this product. In the case of multi-level BOM, the manufacturing lead times of the components will be added."), - 'track_production': fields.boolean('Track Manufacturing Lots', help="Forces to specify a Serial Number for all moves containing this product and generated by a Manufacturing Order"), -======= ->>>>>>> odoo/8.0 'bom_ids': fields.one2many('mrp.bom', 'product_tmpl_id','Bill of Materials'), 'bom_count': fields.function(_bom_orders_count, string='# Bill of Material', type='integer', multi="_bom_order_count"), 'mo_count': fields.function(_bom_orders_count_mo, string='# Manufacturing Orders', type='integer'), 'produce_delay': fields.float('Manufacturing Lead Time', help="Average delay in days to produce this product. In the case of multi-level BOM, the manufacturing lead times of the components will be added."), 'track_production': fields.boolean('Track Manufacturing Lots', help="Forces to specify a Serial Number for all moves containing this product and generated by a Manufacturing Order"), } - - _defaults = { - "produce_delay": 1, - } -<<<<<<< HEAD _defaults = { - "produce_delay": 1, + 'produce_delay': 1, } - def copy(self, cr, uid, id, default=None, context=None): - if not default: - default = {} - default.update({ - 'bom_ids': [] - }) - return super(product_template, self).copy(cr, uid, id, default, context=context) -======= ->>>>>>> odoo/8.0 class product_product(osv.osv): _inherit = "product.product" @@ -84,10 +65,6 @@ class product_product(osv.osv): _columns = { 'mo_count': fields.function(_bom_orders_count, string='# Manufacturing Orders', type='integer'), } -<<<<<<< HEAD -======= - ->>>>>>> odoo/8.0 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index 963bdd0eea0..70e1838932e 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -43,6 +43,7 @@ product.template.product.form product.template + primary
@@ -109,7 +110,7 @@ - + - - - - - - - -
@@ -254,7 +247,6 @@ - @@ -275,8 +267,6 @@ - - @@ -349,19 +339,28 @@ - - product.template.form + + product.template.form.buttons + primary product.template - -
- -
-
+ + +
+ +
+ + + + + + +
+
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 97000987048..34a8c4df50d 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1390,15 +1390,23 @@ class product_template(osv.Model): for template in self.browse(cr, uid, ids, context=context): res[template.id] = sum([p.purchase_count for p in template.product_variant_ids]) return res + _columns = { 'purchase_ok': fields.boolean('Can be Purchased', help="Specify if the product can be selected in a purchase order line."), 'purchase_count': fields.function(_purchase_count, string='# Purchases', type='integer'), } + _defaults = { 'purchase_ok': 1, 'route_ids': _get_buy_route, } + def action_view_purchases(self, cr, uid, ids, context=None): + products = self._get_products(cr, uid, ids, context=context) + result = self._get_act_window_dict(cr, uid, 'purchase','action_purchase_line_product_tree', context=context) + result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" + return result + class product_product(osv.Model): _name = 'product.product' _inherit = 'product.product' diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index a1c42123611..445afa256b0 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -620,12 +620,6 @@ product.template - - - @@ -634,5 +628,33 @@
+ + + product.template.purchase.button.inherit + product.template + + + + + + + + + + product.product.purchase.button.inherit + product.product + + + + + + + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 8881e917269..6cd6e815974 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1278,10 +1278,37 @@ class product_product(osv.Model): product_id: SaleOrderLine.search_count(cr,uid, [('product_id', '=', product_id)], context=context) for product_id in ids } + _columns = { 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'), } +class product_template(osv.Model): + _inherit = 'product.template' + + def _sales_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict.fromkeys(ids, 0) + for template in self.browse(cr, uid, ids, context=context): + res[template.id] = sum([p.sales_count for p in template.product_variant_ids]) + return res + + def action_view_sales(self, cr, uid, ids, context=None): + act_obj = self.pool.get('ir.actions.act_window') + mod_obj = self.pool.get('ir.model.data') + product_ids = [] + for template in self.browse(cr, uid, ids, context=context): + product_ids += [x.id for x in template.product_variant_ids] + result = mod_obj.get_object_reference(cr, uid, 'sale', 'action_order_line_product_tree') + id = result and result[1] or False + result = act_obj.read(cr, uid, [id], context=context)[0] + result['domain'] = "[('product_id','in',[" + ','.join(map(str, product_ids)) + "])]" + return result + + + _columns = { + 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'), + + } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 13e5d952006..922ab8bfbc0 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -508,6 +508,21 @@ + + product.template.sale.order.button + product.template + + + + + + + + + res.company.form.inherit diff --git a/addons/stock/product.py b/addons/stock/product.py index 20470e45e9a..832f147028b 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -323,8 +323,18 @@ class product_template(osv.osv): res.append(('product_variant_ids', 'in', ids)) return res + + def _product_available_text(self, cr, uid, ids, field_names=None, arg=False, context=None): + res = {} + for product in self.browse(cr, uid, ids, context=context): + res[product.id] = str(product.qty_available) + _(" On Hand") + return res + + + _columns = { 'type': fields.selection([('product', 'Stockable Product'), ('consu', 'Consumable'), ('service', 'Service')], 'Product Type', required=True, help="Consumable: Will not imply stock management for this product. \nStockable product: Will imply stock management for this product."), + 'qty_available_text': fields.function(_product_available_text, type='char'), 'property_stock_procurement': fields.property( type='many2one', relation='stock.location', @@ -388,6 +398,42 @@ class product_template(osv.osv): result['domain'] = "[('id','in',[" + ','.join(map(str, route_ids)) + "])]" return result + + def _get_products(self, cr, uid, ids, context=None): + products = [] + for prodtmpl in self.browse(cr, uid, ids, context=None): + products += [x.id for x in prodtmpl.product_variant_ids] + return products + + def _get_act_window_dict(self, cr, uid, module, name, context=None): + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + result = mod_obj.get_object_reference(cr, uid, module, name) + id = result and result[1] or False + result = act_obj.read(cr, uid, [id], context=context)[0] + return result + + def action_open_quants(self, cr, uid, ids, context=None): + products = self._get_products(cr, uid, ids, context=context) + result = self._get_act_window_dict(cr, uid, 'stock','product_open_quants', context=context) + result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" + print "Result open quants:", result + return result + + def action_view_orderpoints(self, cr, uid, ids, context=None): + products = self._get_products(cr, uid, ids, context=context) + result = self._get_act_window_dict(cr, uid, 'stock','product_open_orderpoint', context=context) + result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" + return result + + + def action_view_stock_moves(self, cr, uid, ids, context=None): + products = self._get_products(cr, uid, ids, context=context) + result = self._get_act_window_dict(cr, uid, 'stock','act_product_stock_move_open', context=context) + result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" + return result + + class product_removal_strategy(osv.osv): _name = 'product.removal' _description = 'Removal Strategy' diff --git a/addons/stock/product_view.xml b/addons/stock/product_view.xml index c22429017e7..100e66ca2aa 100644 --- a/addons/stock/product_view.xml +++ b/addons/stock/product_view.xml @@ -127,7 +127,7 @@ - + @@ -143,9 +143,6 @@ {'default_groups_ref': ['base.group_user', 'base.group_sale_manager', 'stock.group_stock_manager']} - - +