[imp] changes of cms branch.

bzr revid: amb@tinyerp.com-20131011073225-6xayq84ov0rsnffs
This commit is contained in:
Amit Bhavsar (Open ERP) 2013-10-11 13:02:25 +05:30
parent 5050231a9c
commit 1ca616ddfd
2 changed files with 114 additions and 92 deletions

View File

@ -289,6 +289,15 @@ class product_template(osv.osv):
_name = "product.template"
_description = "Product Template"
def _get_image(self, cr, uid, ids, name, args, context=None):
result = dict.fromkeys(ids, False)
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = tools.image_get_resized_images(obj.image, avoid_resize_medium=True)
return result
def _set_image(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
_columns = {
'name': fields.char('Name', size=128, required=True, translate=True, select=True),
'product_manager': fields.many2one('res.users','Product Manager'),
@ -328,6 +337,26 @@ class product_template(osv.osv):
'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure Type'),
'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Supplier'),
'company_id': fields.many2one('res.company', 'Company', select=1),
# image: all image fields are base64 encoded and PIL-supported
'image': fields.binary("Image",
help="This field holds the image used as image for the product, limited to 1024x1024px."),
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
string="Medium-sized image", type="binary", multi="_get_image",
store={
'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="Medium-sized image of the product. It is automatically "\
"resized as a 128x128px image, with aspect ratio preserved, "\
"only when the image exceeds one of those sizes. Use this field in form views or some kanban views."),
'image_small': fields.function(_get_image, fnct_inv=_set_image,
string="Small-sized image", type="binary", multi="_get_image",
store={
'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="Small-sized image of the product. It is automatically "\
"resized as a 64x64px image, with aspect ratio preserved. "\
"Use this field anywhere a small image is required."),
'product_variant_ids': fields.one2many('product.product', 'product_tmpl_id', 'Product Variants'),
}
def _get_uom_id(self, cr, uid, *args):
@ -519,15 +548,6 @@ class product_product(osv.osv):
return result
def _get_image(self, cr, uid, ids, name, args, context=None):
result = dict.fromkeys(ids, False)
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = tools.image_get_resized_images(obj.image, avoid_resize_medium=True)
return result
def _set_image(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
def _get_name_template_ids(self, cr, uid, ids, context=None):
result = set()
template_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', 'in', ids)])
@ -572,25 +592,6 @@ class product_product(osv.osv):
}, select=True),
'color': fields.integer('Color Index'),
# image: all image fields are base64 encoded and PIL-supported
'image': fields.binary("Image",
help="This field holds the image used as image for the product, limited to 1024x1024px."),
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
string="Medium-sized image", type="binary", multi="_get_image",
store={
'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="Medium-sized image of the product. It is automatically "\
"resized as a 128x128px image, with aspect ratio preserved, "\
"only when the image exceeds one of those sizes. Use this field in form views or some kanban views."),
'image_small': fields.function(_get_image, fnct_inv=_set_image,
string="Small-sized image", type="binary", multi="_get_image",
store={
'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="Small-sized image of the product. It is automatically "\
"resized as a 64x64px image, with aspect ratio preserved. "\
"Use this field anywhere a small image is required."),
'seller_info_id': fields.function(_calc_seller, type='many2one', relation="product.supplierinfo", string="Supplier Info", multi="seller_info"),
'seller_delay': fields.function(_calc_seller, type='integer', string='Supplier Lead Time', multi="seller_info", help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."),
'seller_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."),

View File

@ -694,74 +694,95 @@
<field name="model">product.template</field>
<field name="arch" type="xml">
<form string="Product Template" version="7.0">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
<label for="categ_id" class="oe_edit_only"/>
<h2><field name="categ_id"/></h2>
<notebook>
<page string="Information">
<group>
<group string="Product Type">
<field name="sale_ok"/>
</group>
<group string="Procurement">
<field name="type"/>
</group>
<group string="Base Prices">
<field name="list_price"/>
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
<field name="cost_method"/>
</group>
<group string="Weights">
<field digits="(14, 3)" name="volume" attrs="{'readonly':[('type','=','service')]}"/>
<field digits="(14, 3)" name="weight" attrs="{'readonly':[('type','=','service')]}"/>
<field digits="(14, 3)" name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
</group>
<group name="status" string="Status">
<field name="categ_id"/>
<field name="state"/>
<field name="product_manager" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_manager']}"/>
</group>
<group name="uom" string="Unit of Measure">
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
<field name="uom_po_id"/>
</group>
<group name="uos" groups="product.group_uom" string="Second Unit of Measure">
<field name="uos_id"/>
<field name="uos_coeff"/>
<field name="mes_type"/>
</group>
</group>
</page>
<page string="Procurement &amp; Locations">
<sheet>
<field name="image_medium" widget="image" class="oe_avatar oe_left"/>
<div class="oe_title">
<div class="oe_edit_only">
<label for="name" string="Product Name"/>
</div>
<h1>
<field name="name"/>
</h1>
<label for="categ_id" class="oe_edit_only"/>
<h2><field name="categ_id"/></h2>
</div>
<notebook>
<page string="Information">
<group>
<group name="delay" string="Delays">
<label for="produce_delay"/>
<div>
<field name="produce_delay" class="oe_inline"/> days
</div>
<field name="warranty"/>
<group string="Product Type">
<field name="sale_ok"/>
</group>
<group string="Procurement">
<field name="type"/>
</group>
<group string="Base Prices">
<field name="list_price"/>
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
<field name="cost_method"/>
</group>
<group string="Weights">
<field digits="(14, 3)" name="volume" attrs="{'readonly':[('type','=','service')]}"/>
<field digits="(14, 3)" name="weight" attrs="{'readonly':[('type','=','service')]}"/>
<field digits="(14, 3)" name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
</group>
<group name="status" string="Status">
<field name="categ_id"/>
<field name="state"/>
<field name="product_manager" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_manager']}"/>
</group>
<group name="uom" string="Unit of Measure">
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
<field name="uom_po_id"/>
</group>
<group name="uos" groups="product.group_uom" string="Second Unit of Measure">
<field name="uos_id"/>
<field name="uos_coeff"/>
<field name="mes_type"/>
</group>
<group colspan="4" string="Product Variants">
<field colspan="4" name="product_variant_ids" nolabel="1">
<tree string="Product Variants" editable="bottom">
<field name="active"/>
<field name="variants" required="1"/>
<field name="default_code"/>
<field name="price_margin"/>
<field name="price_extra"/>
</tree>
</field>
</group>
</group>
</page>
<page string="Procurement &amp; Locations">
<group>
<group name="delay" string="Delays">
<label for="produce_delay"/>
<div>
<field name="produce_delay" class="oe_inline"/> days
</div>
<field name="warranty"/>
</group>
</group>
</page>
<page string="Suppliers">
<field name="seller_ids"/>
</page>
<page string="Descriptions">
<separator string="Internal Description"/>
<field name="description"/>
<separator string="Sale Description"/>
<field name="description_sale"/>
<separator string="Purchase Description"/>
<field name="description_purchase"/>
</page>
</notebook>
</page>
<page string="Suppliers">
<field name="seller_ids"/>
</page>
<page string="Descriptions">
<separator string="Internal Description"/>
<field name="description"/>
<separator string="Sale Description"/>
<field name="description_sale"/>
<separator string="Purchase Description"/>
<field name="description_purchase"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>