Images should be a template attribute, not variant's attribute

This commit is contained in:
Sergi Almacellas Abellana 2013-10-28 13:57:41 +01:00
parent b9a5cba504
commit 066cc7f89d
5 changed files with 16 additions and 14 deletions

View File

@ -8,5 +8,5 @@ from .product import *
def register():
Pool.register(
Attachment,
Product,
Template,
module='product_images', type_='model')

View File

@ -4,7 +4,7 @@ from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
__all__ = ['Attachment', 'Product']
__all__ = ['Attachment', 'Template']
__metaclass__ = PoolMeta
@ -14,8 +14,8 @@ class Attachment:
product_image = fields.Boolean('Product Image')
class Product:
__name__ = 'product.product'
class Template:
__name__ = 'product.template'
images = fields.One2Many('ir.attachment', 'resource', 'Images', domain=[
('product_image', '=', True),
@ -25,10 +25,10 @@ class Product:
}, depends=['id'])
@classmethod
def delete(cls, products):
def delete(cls, templates):
pool = Pool()
Attachment = pool.get('ir.attachment')
attachments = [a for p in products for a in p.images]
attachments = [a for t in templates for a in t.images]
Attachment.delete(attachments)
super(Product, cls).delete(products)
super(Template, cls).delete(templates)

View File

@ -18,14 +18,14 @@
<!-- product.product -->
<record model="ir.ui.view" id="product_view_form">
<field name="model">product.product</field>
<field name="inherit" ref="product.product_view_form"/>
<field name="model">product.template</field>
<field name="inherit" ref="product.template_view_form"/>
<field name="name">product_form</field>
</record>
<record model="ir.ui.view" id="product_view_list">
<field name="model">product.product</field>
<field name="inherit" ref="product.product_view_tree"/>
<field name="model">product.template</field>
<field name="inherit" ref="product.template_view_tree"/>
<field name="name">product_list</field>
</record>
</data>

View File

@ -2,7 +2,9 @@
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='description']" position="after">
<field name="images" colspan="6" mode="tree,form"/>
<xpath expr="/form/notebook" position="inside">
<page id="images" string="Images">
<field name="images" colspan="6" mode="tree,form"/>
</page>
</xpath>
</data>

View File

@ -2,7 +2,7 @@
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='rec_name']" position="after">
<xpath expr="/tree/field[@name='default_uom']" position="after">
<field name="images"/>
</xpath>
</data>