Browse Source

update _get_image, _set_image

for image_medium
pull/52/head
cellsnake 9 years ago
parent
commit
66200b7c4a
  1. 21
      pos_remove_pos_category/product.py
  2. 10
      pos_remove_pos_category/views/pos_category.xml

21
pos_remove_pos_category/product.py

@ -44,9 +44,11 @@ class ProductTemplate(models.Model):
class ProductCategory(models.Model):
_inherit = 'product.category'
image = fields.Binary(help='Show Image Category in Form View',
inverse='_save_image_medium')
image_medium = fields.Binary(help='Show image category button in POS')
image = fields.Binary(help='Show Image Category in Form View')
image_medium = fields.Binary(help='Show image category button in POS',
compute="_get_image",
inverse="_set_image",
store=True)
available_in_pos = fields.Boolean(
string="Available in the Point of Sale",
default=True,
@ -55,15 +57,12 @@ class ProductCategory(models.Model):
"whatever their checkbox state.")
@api.multi
def _save_image_medium(self):
for record in self:
if record.image:
temp = tools.image_get_resized_images(record.image)
record.image_medium = temp['image_medium']
else:
record.image_medium = None
return True
def _get_image(self):
return dict((rec.id, tools.image_get_resized_images(rec.image)) for rec in self)
@api.one
def _set_image(self):
return self.write({'image': tools.image_resize_image_big(self.image_medium)})
_auto_end_original = models.BaseModel._auto_end

10
pos_remove_pos_category/views/pos_category.xml

@ -1,17 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="pos_remove_pos_category assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript"
src="/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js"></script>
<script type="text/javascript" src="/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js"></script>
</xpath>
<!--<xpath expr="//script[@src='/point_of_sale/static/src/js/widgets.js']"
position="attributes">
<attribute name="src">/pos_remove_pos_category/static/src/js/widgets2.js</attribute>
</xpath> -->
</template>
<record id="product_category_form_view" model="ir.ui.view">
@ -25,7 +19,7 @@
</xpath>
<field name="name" position="after">
<div class="oe_bottom" style="margin-top: 10px;">
<field name="image"
<field name="image_medium"
widget="image"
class="oe_left oe_avatar"
options='{"size": [100, 100]}'/>

Loading…
Cancel
Save