first commit
This commit is contained in:
2
modules/product_image_attribute/__init__.py
Normal file
2
modules/product_image_attribute/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
15
modules/product_image_attribute/locale/bg.po
Normal file
15
modules/product_image_attribute/locale/bg.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/ca.po
Normal file
15
modules/product_image_attribute/locale/ca.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Grup d'atributs"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Atributs"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Nom dels atributs"
|
||||
15
modules/product_image_attribute/locale/cs.po
Normal file
15
modules/product_image_attribute/locale/cs.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/de.po
Normal file
15
modules/product_image_attribute/locale/de.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Attributssatz"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Attribute"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Attributnamen"
|
||||
15
modules/product_image_attribute/locale/es.po
Normal file
15
modules/product_image_attribute/locale/es.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Grupo de atributos"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Atributos"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Nombre de los atributos"
|
||||
15
modules/product_image_attribute/locale/es_419.po
Normal file
15
modules/product_image_attribute/locale/es_419.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/et.po
Normal file
15
modules/product_image_attribute/locale/et.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/fa.po
Normal file
15
modules/product_image_attribute/locale/fa.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/fi.po
Normal file
15
modules/product_image_attribute/locale/fi.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/fr.po
Normal file
15
modules/product_image_attribute/locale/fr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Ensemble d'attributs"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Attributs"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Noms des attributs"
|
||||
15
modules/product_image_attribute/locale/hu.po
Normal file
15
modules/product_image_attribute/locale/hu.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/id.po
Normal file
15
modules/product_image_attribute/locale/id.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/it.po
Normal file
15
modules/product_image_attribute/locale/it.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Insieme di attributi"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Attributi"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Nomi attributi"
|
||||
15
modules/product_image_attribute/locale/lo.po
Normal file
15
modules/product_image_attribute/locale/lo.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/lt.po
Normal file
15
modules/product_image_attribute/locale/lt.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/nl.po
Normal file
15
modules/product_image_attribute/locale/nl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Set attributen"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "attributen"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Attributennaam"
|
||||
15
modules/product_image_attribute/locale/pl.po
Normal file
15
modules/product_image_attribute/locale/pl.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
16
modules/product_image_attribute/locale/pt.po
Normal file
16
modules/product_image_attribute/locale/pt.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Grupo de Atributos"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Atributos"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Nome dos Atributos"
|
||||
15
modules/product_image_attribute/locale/ro.po
Normal file
15
modules/product_image_attribute/locale/ro.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr "Set Proprietăți"
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Proprietați"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr "Denumire Proprietate"
|
||||
15
modules/product_image_attribute/locale/ru.po
Normal file
15
modules/product_image_attribute/locale/ru.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
16
modules/product_image_attribute/locale/sl.po
Normal file
16
modules/product_image_attribute/locale/sl.po
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr "Atributi"
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/tr.po
Normal file
15
modules/product_image_attribute/locale/tr.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/uk.po
Normal file
15
modules/product_image_attribute/locale/uk.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
15
modules/product_image_attribute/locale/zh_CN.po
Normal file
15
modules/product_image_attribute/locale/zh_CN.po
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.image,attribute_set:"
|
||||
msgid "Attribute Set"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes:"
|
||||
msgid "Attributes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "field:product.image,attributes_name:"
|
||||
msgid "Attributes Name"
|
||||
msgstr ""
|
||||
67
modules/product_image_attribute/product.py
Normal file
67
modules/product_image_attribute/product.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
|
||||
class Product(metaclass=PoolMeta):
|
||||
__name__ = 'product.product'
|
||||
|
||||
@property
|
||||
def images_used(self):
|
||||
for image in super().images_used:
|
||||
if not image.product and image.attributes:
|
||||
if not self.attributes:
|
||||
continue
|
||||
for key, value in image.attributes.items():
|
||||
if value != self.attributes.get(key):
|
||||
break
|
||||
else:
|
||||
yield image
|
||||
else:
|
||||
yield image
|
||||
|
||||
|
||||
class Image(metaclass=PoolMeta):
|
||||
__name__ = 'product.image'
|
||||
|
||||
attributes = fields.Dict('product.attribute', "Attributes",
|
||||
domain=[
|
||||
('sets', '=', Eval('attribute_set', -1)),
|
||||
],
|
||||
states={
|
||||
'invisible': ~Eval('attribute_set') | Eval('product'),
|
||||
})
|
||||
attributes_name = fields.Function(fields.Char(
|
||||
"Attributes Name",
|
||||
states={
|
||||
'invisible': ~Eval('attribute_set'),
|
||||
}),
|
||||
'on_change_with_attributes_name')
|
||||
|
||||
attribute_set = fields.Function(
|
||||
fields.Many2One('product.attribute.set', "Attribute Set"),
|
||||
'on_change_with_attribute_set')
|
||||
|
||||
@fields.depends('template', '_parent_template.attribute_set')
|
||||
def on_change_with_attribute_set(self, name=None):
|
||||
return self.template.attribute_set if self.template else None
|
||||
|
||||
@fields.depends('attribute_set', 'attributes')
|
||||
def on_change_with_attributes_name(self, name=None):
|
||||
if not self.attribute_set or not self.attributes:
|
||||
return
|
||||
|
||||
def key(attribute):
|
||||
return getattr(attribute, 'sequence', attribute.name)
|
||||
|
||||
values = []
|
||||
for attribute in sorted(self.attribute_set.attributes, key=key):
|
||||
if attribute.name in self.attributes:
|
||||
value = self.attributes[attribute.name]
|
||||
values.append(gettext('product_attribute.msg_label_value',
|
||||
label=attribute.string,
|
||||
value=attribute.format(value)))
|
||||
return " | ".join(filter(None, values))
|
||||
24
modules/product_image_attribute/product.xml
Normal file
24
modules/product_image_attribute/product.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="image_view_list">
|
||||
<field name="model">product.image</field>
|
||||
<field name="inherit" ref="product_image.image_view_list"/>
|
||||
<field name="name">image_list</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="image_view_form">
|
||||
<field name="model">product.image</field>
|
||||
<field name="inherit" ref="product_image.image_view_form"/>
|
||||
<field name="name">image_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="image_view_list_form">
|
||||
<field name="model">product.image</field>
|
||||
<field name="inherit" ref="product_image.image_view_list_form"/>
|
||||
<field name="name">image_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
2
modules/product_image_attribute/tests/__init__.py
Normal file
2
modules/product_image_attribute/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
76
modules/product_image_attribute/tests/test_module.py
Normal file
76
modules/product_image_attribute/tests/test_module.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import unittest
|
||||
import urllib.request
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import (
|
||||
TEST_NETWORK, ModuleTestCase, with_transaction)
|
||||
|
||||
|
||||
class ProductImageAttributeTestCase(ModuleTestCase):
|
||||
'Test Product Image Attribute module'
|
||||
module = 'product_image_attribute'
|
||||
|
||||
@unittest.skipUnless(TEST_NETWORK, "requires network")
|
||||
@with_transaction()
|
||||
def test_image_attribute(self):
|
||||
"Test image with attribute"
|
||||
pool = Pool()
|
||||
Attribute = pool.get('product.attribute')
|
||||
AttributeSet = pool.get('product.attribute.set')
|
||||
Image = pool.get('product.image')
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
attribute1 = Attribute(name='attr1', string="Attribute 1")
|
||||
attribute1.type_ = 'char'
|
||||
attribute1.save()
|
||||
attribute2 = Attribute(name='attr2', string="Attribute 2")
|
||||
attribute2.type_ = 'integer'
|
||||
attribute2.save()
|
||||
attribute_set = AttributeSet(name="Attribute Set")
|
||||
attribute_set.attributes = [attribute1, attribute2]
|
||||
attribute_set.save()
|
||||
template = Template(name="Template")
|
||||
template.default_uom, = Uom.search([], limit=1)
|
||||
template.attribute_set = attribute_set
|
||||
template.save()
|
||||
product = Product(template=template)
|
||||
product.attributes = {
|
||||
'attr1': 'foo',
|
||||
'attr2': 2,
|
||||
}
|
||||
product.save()
|
||||
image1 = Image(template=template)
|
||||
image1.image = urllib.request.urlopen(
|
||||
'https://downloads.tryton.org/tests/product-image/chair.jpg'
|
||||
).read()
|
||||
image1.save()
|
||||
image2 = Image(template=template, product=product)
|
||||
image2.image = urllib.request.urlopen(
|
||||
'https://downloads.tryton.org/tests/product-image/chair.jpg'
|
||||
).read()
|
||||
image2.save()
|
||||
image3 = Image(template=template)
|
||||
image3.image = urllib.request.urlopen(
|
||||
'https://downloads.tryton.org/tests/product-image/chair.jpg'
|
||||
).read()
|
||||
image3.attributes = {
|
||||
'attr1': 'foo',
|
||||
}
|
||||
image3.save()
|
||||
image4 = Image(template=template)
|
||||
image4.image = urllib.request.urlopen(
|
||||
'https://downloads.tryton.org/tests/product-image/chair.jpg'
|
||||
).read()
|
||||
image4.attributes = {
|
||||
'attr1': 'bar',
|
||||
}
|
||||
image4.save()
|
||||
|
||||
self.assertEqual(list(product.images_used), [image2, image1, image3])
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
14
modules/product_image_attribute/tryton.cfg
Normal file
14
modules/product_image_attribute/tryton.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
[tryton]
|
||||
version=7.8.0
|
||||
depends:
|
||||
ir
|
||||
product
|
||||
product_attribute
|
||||
product_image
|
||||
xml:
|
||||
product.xml
|
||||
|
||||
[register]
|
||||
model:
|
||||
product.Product
|
||||
product.Image
|
||||
8
modules/product_image_attribute/view/image_form.xml
Normal file
8
modules/product_image_attribute/view/image_form.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="//field[@name='product']" position="after">
|
||||
<field name="attributes" colspan="2"/>
|
||||
</xpath>
|
||||
</data>
|
||||
8
modules/product_image_attribute/view/image_list.xml
Normal file
8
modules/product_image_attribute/view/image_list.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="//field[@name='product']" position="after">
|
||||
<field name="attributes_name" expand="1"/>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in New Issue
Block a user