first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View 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.

View 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 ""

View 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"

View 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 ""

View 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"

View 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"

View 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 ""

View 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 ""

View 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 ""

View 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 ""

View 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"

View 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 ""

View 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 ""

View 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"

View 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 ""

View 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 ""

View 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"

View 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 ""

View 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"

View 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"

View 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 ""

View 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 ""

View 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 ""

View 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 ""

View 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 ""

View 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))

View 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>

View 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.

View 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

View 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

View 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>

View 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>