[IMP] Start of extra primary view on product template that is not inherited by product_product

This commit is contained in:
Josse Colpaert 2014-07-07 21:45:11 +02:00
parent af0e9b8aa6
commit 2518767005
9 changed files with 171 additions and 108 deletions

View File

@ -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:

View File

@ -43,6 +43,7 @@
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<form string="Product">
<field name="is_product_variant" invisible="1"/>
@ -109,7 +110,7 @@
</group>
</group>
</page>
<page string="Sales" attrs="{'invisible':[('sale_ok','=',False)]}">
<page string="Sales" attrs="{'invisible':[('sale_ok','=',False)]}" name="sales">
<group name="sale">
<group name="sale_condition" string="Sale Conditions" colspan="3">
<label for="warranty"/>
@ -128,14 +129,6 @@
<separator string="Description for Quotations"/>
<field name="description_sale" placeholder="note to be displayed on quotations..."/>
</page>
<page name="variants" string="Variants">
<field name="attribute_line_ids" widget="one2many_list">
<tree string="Variants" editable="bottom">
<field name="attribute_id"/>
<field name="value_ids" widget="many2many_tags" domain="[('attribute_id', '=', attribute_id)]" context="{'default_attribute_id': attribute_id}"/>
</tree>
</field>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
@ -254,7 +247,6 @@
<field name="state" invisible="1"/>
<field name="product_tmpl_id" invisible="1"/>
</tree>
</field>
</record>
@ -275,8 +267,6 @@
<xpath expr="//div[@class='oe_title']" position="inside">
<field name="attribute_value_ids" widget="many2many_tags"/>
</xpath>
<page name="variants" position="replace">
</page>
</field>
</record>
@ -349,19 +339,28 @@
</field>
</record>
<record id="product_template_form_view_variant_button" model="ir.ui.view">
<field name="name">product.template.form</field>
<record id="product_template_form_view_only" model="ir.ui.view">
<field name="name">product.template.form.buttons</field>
<field name="mode">primary</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="attribute_line_ids" position="before">
<div class="oe_right">
<button class="oe_inline oe_stat_button" string="Variant Prices" name="%(product.variants_template_action)d" type="action" icon="fa-strikethrough"/>
<button class="oe_inline oe_stat_button" name="%(product.product_variant_action)d" type="action" icon="fa-sitemap">
<field string="Variants" name="product_variant_count" widget="statinfo" />
</button>
</div>
</field>
<page name="sales" position="after">
<page name="variants" string="Variants">
<div class="oe_right">
<button class="oe_inline oe_stat_button" string="Variant Prices" name="%(product.variants_template_action)d" type="action" icon="fa-strikethrough"/>
<button class="oe_inline oe_stat_button" name="%(product.product_variant_action)d" type="action" icon="fa-sitemap">
<field string="Variants" name="product_variant_count" widget="statinfo" />
</button>
</div>
<field name="attribute_line_ids" widget="one2many_list">
<tree string="Variants" editable="bottom">
<field name="attribute_id"/>
<field name="value_ids" widget="many2many_tags" domain="[('attribute_id', '=', attribute_id)]" context="{'default_attribute_id': attribute_id}"/>
</tree>
</field>
</page>
</page>
</field>
</record>

View File

@ -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'

View File

@ -620,12 +620,6 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" name="%(action_purchase_line_product_tree)d" type="action"
groups="purchase.group_purchase_user" icon="fa-shopping-cart">
<field string="Purchases" name="purchase_count" widget="statinfo" />
</button>
</xpath>
<field name="property_account_expense" position="replace" >
<field name="property_account_expense" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" groups="account.group_account_user"/>
</field>
@ -634,5 +628,33 @@
</field>
</field>
</record>
<record id="view_product_template_purchase_buttons_from" model="ir.ui.view">
<field name="name">product.template.purchase.button.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view_only"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" name="action_view_purchases" type="object"
groups="purchase.group_purchase_user" icon="fa-shopping-cart">
<field string="Purchases" name="purchase_count" widget="statinfo"/>
</button>
</xpath>
</field>
</record>
<record id="view_product_normal_purchase_buttons_from" model="ir.ui.view">
<field name="name">product.product.purchase.button.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" name="%(action_purchase_line_product_tree)d" type="action"
groups="purchase.group_purchase_user" icon="fa-shopping-cart">
<field string="Purchases" name="purchase_count" widget="statinfo"/>
</button>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -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:

View File

@ -508,6 +508,21 @@
</field>
</record>
<record model="ir.ui.view" id="product_template_form_view_sale_order_button">
<field name="name">product.template.sale.order.button</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view_only"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" name="action_view_sales"
type="object" groups="base.group_sale_salesman" icon="fa-strikethrough">
<field string="Sales" name="sales_count" widget="statinfo" />
</button>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_company_inherit_form2">
<field name="name">res.company.form.inherit</field>
<field name="inherit_id" ref="base.view_company_form"/>

View File

@ -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'

View File

@ -127,7 +127,7 @@
</group>
</group>
<group name="status" position="before">
<group name="lot" groups="stock.group_production_lot" string="Lots">
<group name="lot" groups="stock.group_production_lot" string="Lots" attrs="{'invisible':[('type','=','service')]}">
<field name="track_all" groups="stock.group_production_lot"/>
<field name="track_incoming" groups="stock.group_production_lot" attrs="{'invisible': [('track_all', '=', True)]}"/>
<field name="track_outgoing" groups="stock.group_production_lot" attrs="{'invisible': [('track_all', '=', True)]}"/>
@ -143,9 +143,6 @@
<field name="product_manager" position="attributes">
<attribute name="context">{'default_groups_ref': ['base.group_user', 'base.group_sale_manager', 'stock.group_stock_manager']}</attribute>
</field>
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" name="action_view_routes" string="Routes" type="object" icon="fa-cogs"/>
</xpath>
<group name="procurement_uom" position="after" >
<group string="Supply Chain Information" attrs="{'invisible': [('type', '=', 'service')]}" groups="base.group_user">
<field name="route_ids" widget="many2many_checkboxes"/>
@ -154,6 +151,8 @@
</field>
</record>
<record model="ir.ui.view" id="product_template_kanban_stock_view">
<field name="name">Product Template Kanban Stock</field>
<field name="model">product.template</field>
@ -224,6 +223,27 @@
<button class="oe_inline oe_stat_button" string="Moves" name= "%(act_product_stock_move_open)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_stock_user" icon="fa-arrows-v"/>
<button class="oe_inline oe_stat_button" name="%(product_open_orderpoint)d" type="action"
attrs="{'invisible':[('type', '=', 'service')]}" icon="fa-refresh" string="Reordering Rules"/>
<button class="oe_inline oe_stat_button" name="action_view_routes" string="Routes" type="object" icon="fa-cogs" attrs="{'invisible':[('type', '=', 'service')]}" />
</xpath>
</field>
</record>
<record model="ir.ui.view" id="product_template_form_view_procurement_button">
<field name="name">product.template_procurement</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view_only"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_stat_button"
name="action_open_quants"
icon="fa-building-o"
type="object" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_locations">
<div><field name="qty_available_text"/></div>
</button>
<button class="oe_inline oe_stat_button" string="Moves" name= "action_view_stock_moves" type="object" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_stock_user" icon="fa-arrows-v"/>
<button class="oe_inline oe_stat_button" name="action_view_orderpoints" type="object"
attrs="{'invisible':[('type', '=', 'service')]}" icon="fa-refresh" string="Reordering Rules"/>
<button class="oe_inline oe_stat_button" name="action_view_routes" string="Routes" type="object" icon="fa-cogs" attrs="{'invisible':[('type', '=', 'service')]}" />
</xpath>
</field>
</record>

View File

@ -300,58 +300,6 @@
</field>
</record>
<record id="stock_move_tree2" model="ir.ui.view">
<field name="name">Stock Moves</field>
<field name="model">stock.move</field>
<field name="arch" type="xml">
<tree colors="grey:state == 'cancel'" string="Moves" create="false">
<field name="product_id"/>
<field name="product_uom_qty"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
<field name="product_packaging" domain="[('product_id','=',product_id)]" groups="product.group_stock_packaging"/>
<field name="picking_id"/>
<field name="location_id" groups="stock.group_locations"/>
<field name="location_dest_id" groups="stock.group_locations"/>
<field name="create_date" groups="base.group_no_one"/>
<field name="date" string="Date" groups="base.group_no_one"/>
<field name="date_expected" string="Date Expected"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="action3" model="ir.actions.act_window">
<field name="name">Downstream traceability</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move</field>
<field name="domain">[('id','in',active_ids)]</field>
<field name="view_type">tree</field>
<field eval="stock_move_tree2" name="view_id"/>
</record>
<record id="ir_move_traceability_upstream" model="ir.values">
<field name="key2">tree_but_action</field>
<field name="model">stock.move</field>
<field name="name">Downstream traceability</field>
<field eval="'ir.actions.act_window,'+str(action3)" name="value"/>
</record>
<record id="action5" model="ir.actions.act_window">
<field name="name">Upstream traceability</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move</field>
<field name="domain">[('id','in',active_ids)]</field>
<field name="view_type">tree</field>
<field eval="stock_move_tree" name="view_id"/>
</record>
<record id="ir_move_traceability_downstream" model="ir.values">
<field name="key2">tree_but_action</field>
<field name="model">stock.move</field>
<field name="name">Upstream traceability</field>
<field eval="'ir.actions.act_window,'+str(action5)" name="value"/>
</record>
<record model="ir.actions.act_window" id="location_open_quants">
<field name="context">{'search_default_productgroup': 1}</field>
<field name="domain">[('location_id', 'child_of', active_ids)]</field>
@ -1766,6 +1714,7 @@
<field name="name">Reordering Rules</field>
<field name="res_model">stock.warehouse.orderpoint</field>
</record>
<record model="ir.actions.act_window" id="product_open_quants">
<field name="context">{'search_default_internal_loc': 1, 'search_default_product_id': active_id, 'search_default_locationgroup':1}</field>
<field name="name">Current Stock</field>