[IMP]:product:improved kanban view for product and also set default product images.

bzr revid: apa@tinyerp.com-20110920111257-4pmqzdoqc601neu9
This commit is contained in:
Amit (OpenERP)
2011-09-20 16:42:57 +05:30
parent 92e1432757
commit b2f74f995a
2 changed files with 97 additions and 3 deletions
+10 -2
View File
@@ -21,7 +21,7 @@
from osv import osv, fields
import decimal_precision as dp
import addons
import math
from _common import rounding
import re
@@ -457,10 +457,16 @@ class product_product(osv.osv):
(data['name'] or '') + (data['variants'] and (' - '+data['variants']) or '')
return res
def _get_photo(self, cr, uid, context=None):
photo_path = addons.get_module_resource('product','images','product.png')
return open(photo_path, 'rb').read().encode('base64')
_defaults = {
'active': lambda *a: 1,
'price_extra': lambda *a: 0.0,
'price_margin': lambda *a: 1.0,
'color': 0,
'product_image':_get_photo,
}
_name = "product.product"
@@ -487,8 +493,10 @@ class product_product(osv.osv):
'price_margin': fields.float('Variant Price Margin', digits_compute=dp.get_precision('Sale Price')),
'pricelist_id': fields.dummy(string='Pricelist', relation='product.pricelist', type='many2one'),
'name_template': fields.related('product_tmpl_id', 'name', string="Name", type='char', size=128, store=True),
'color': fields.integer('Color Index'),
'product_image': fields.binary('Image'),
}
def unlink(self, cr, uid, ids, context=None):
unlink_ids = []
unlink_product_tmpl_ids = []
+87 -1
View File
@@ -69,7 +69,7 @@
<field eval="7" name="priority"/>
<field name="arch" type="xml">
<form string="Product">
<group colspan="4" col="6">
<group colspan="4" col="8">
<group colspan="4" col="2">
<separator string="Name" colspan="2"/>
<field name="name"/>
@@ -85,6 +85,9 @@
<field name="sale_ok"/>
<field name="purchase_ok"/>
</group>
<group colspan="1" col="1">
<field name="product_image" widget='image' nolabel="1"/>
</group>
</group>
<notebook colspan="4">
@@ -191,6 +194,74 @@
</form>
</field>
</record>
<!-- Product Kanban View -->
<record model="ir.ui.view" id="product_kanban_view">
<field name="name">Product Kanban</field>
<field name="model">product.product</field>
<field name="type">kanban</field>
<field name="arch" type="xml">
<kanban default_group_by="type">
<field name="name"/>
<field name="color"/>
<field name="default_code"/>
<field name="type"/>
<field name="product_manager"/>
<field name="product_image"/>
<field name="qty_available"/>
<field name="virtual_available"/>
<field name="lst_price"/>
<field name="standard_price"/>
<field name="list_price"/>
<templates>
<t t-name="kanban-box">
<t t-set="color" t-value="kanban_color(record.color.raw_value || record.type.raw_value)"/>
<div t-att-class="color + (record.color.raw_value == 1 ? ' oe_kanban_color_alert' : '')">
<div class="oe_kanban_box oe_kanban_color_border">
<table class="oe_kanban_table oe_kanban_box_header oe_kanban_color_bgdark oe_kanban_color_border oe_kanban_draghandle">
<tr>
<td class="oe_kanban_title1" align="left" valign="middle">
<t t-if="record.default_code.raw_value">[<field name="default_code"/>]</t>
<field name="name"/>
</td>
<td align="right" valign="top" width="22">
<img t-att-src="kanban_gravatar(record.product_manager.raw_value, 22)" class="oe_kanban_gravatar"/>
</td>
</tr>
</table>
<div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_box_show_onclick_trigger">
<table class="oe_kanban_table">
<tr>
<td valign="top" width="22">
<img t-att-src="'data:image/png;base64,'+record.product_image.raw_value" width='48' height='48'/>
</td>
<td>
<div class="oe_kanban_title2">
<t t-if="record.type.raw_value=='service'">No Stock</t>
<t t-if="record.type.raw_value!='service'">
<div><field name="qty_available"/> On Hand , <field name="virtual_available"/> Available</div>
<div><t t-if="record.list_price.raw_value!=0">Public Price : <field name="lst_price"/> ,</t> Cost : <field name="standard_price"/></div>
</t>
</div>
</td>
</tr>
</table>
</div>
<div class="oe_kanban_buttons_set oe_kanban_color_border oe_kanban_color_bglight oe_kanban_box_show_onclick">
<div class="oe_kanban_left">
<a string="Edit" icon="gtk-edit" type="edit"/>
<a string="Change Color" icon="color-picker" type="color" name="color"/>
</div>
<br class="oe_kanban_clear"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="product_normal_action" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="type">ir.actions.act_window</field>
@@ -204,12 +275,27 @@
<field name="name">Products</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.product</field>
<field name="view_mode">tree,form,kanban</field>
<field name="view_type">form</field>
<field name="context">{"search_default_filter_to_sell":1}</field>
<field name="view_id" ref="product_product_tree_view"/>
<field name="search_view_id" ref="product_search_form_view"/>
<field name="help">You must define a Product for everything you buy or sell. Products can be raw materials, stockable products, consumables or services. The Product form contains detailed information about your products related to procurement logistics, sales price, product category, suppliers and so on.</field>
</record>
<record id="open_view_product_tree1" model="ir.actions.act_window.view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="product_product_tree_view"/>
<field name="act_window_id" ref="product_normal_action_sell"/>
</record>
<record id="open_view_product_form1" model="ir.actions.act_window.view">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="product_normal_form_view"/>
<field name="act_window_id" ref="product_normal_action_sell"/>
</record>
<menuitem id="base.menu_product" name="Products" parent="base.menu_base_partner" sequence="9"/>
<menuitem action="product.product_normal_action_sell" id="product.menu_products" parent="base.menu_product" sequence="1"/>