Add missing function to product_template_attribute dependency.

This commit is contained in:
Juanjo Garcia 2022-07-27 15:08:20 +02:00
parent 9852334153
commit ddd47e3f2c
4 changed files with 41 additions and 29 deletions

View File

@ -21,5 +21,7 @@ def register():
Pool.register(
configuration.Configuration,
configuration.ConfigurationProductESale,
product.TemplateAttribute,
product.ProductAttribute,
module='product_esale', type_='model',
depends=['product_template_attribute'])

View File

@ -94,22 +94,6 @@ class Template(metaclass=PoolMeta):
def default_esale_sequence():
return 1
@staticmethod
def default_attribute_set():
'''Product Template Attribute'''
Config = Pool().get('product.configuration')
pconfig = Config(1)
if hasattr(pconfig, 'attribute_set') and pconfig.attribute_set:
return pconfig.attribute_set.id
@staticmethod
def default_default_uom():
'''Default UOM'''
Config = Pool().get('product.configuration')
config = Config(1)
if hasattr(config, 'default_uom') and config.default_uom:
return config.default_uom.id
@fields.depends('name', 'esale_slug')
def on_change_esale_available(self):
try:
@ -319,6 +303,26 @@ class Template(metaclass=PoolMeta):
return options
class TemplateAttribute(metaclass=PoolMeta):
__name__ = 'product.template'
@staticmethod
def default_attribute_set():
'''Product Template Attribute'''
Config = Pool().get('product.configuration')
pconfig = Config(1)
if hasattr(pconfig, 'attribute_set') and pconfig.attribute_set:
return pconfig.attribute_set.id
@staticmethod
def default_default_uom():
'''Default UOM'''
Config = Pool().get('product.configuration')
config = Config(1)
if hasattr(config, 'default_uom') and config.default_uom:
return config.default_uom.id
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
esale_available = fields.Function(fields.Boolean('eSale'),
@ -356,15 +360,6 @@ class Product(metaclass=PoolMeta):
def default_esale_sequence():
return 1
@staticmethod
def default_attributes():
'''Product Attribute Options'''
Config = Pool().get('product.configuration')
pconfig = Config(1)
if (hasattr(pconfig, 'attribute_set_options') and
pconfig.attribute_set_options):
return attribute2dict(pconfig.attribute_set_options)
@classmethod
def search(cls, domain, offset=0, limit=None, order=None, count=False,
query=False):
@ -507,6 +502,19 @@ class Product(metaclass=PoolMeta):
return prods
class ProductAttribute(metaclass=PoolMeta):
__name__ = 'product.product'
@staticmethod
def default_attributes():
'''Product Attribute Options'''
Config = Pool().get('product.configuration')
pconfig = Config(1)
if (hasattr(pconfig, 'attribute_set_options') and
pconfig.attribute_set_options):
return attribute2dict(pconfig.attribute_set_options)
class ProductMenu(ModelSQL):
'Product - Menu'
__name__ = 'product.template-esale.catalog.menu'

View File

@ -75,10 +75,6 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
<label name="cost_price"/>
<field name="cost_price"/>
</page>
<page string="Attributes" id="attributes">
<label name="attribute_set"/>
<field name="attribute_set"/>
</page>
<page string="General" id="general">
<label name="type"/>
<field name="type"/>

View File

@ -6,4 +6,10 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
<newline/>
<field name="template_attributes" colspan="6"/>
</xpath>
<xpath expr="/form/notebook" position="inside">
<page string="Attributes" id="attributes">
<label name="attribute_set"/>
<field name="attribute_set"/>
</page>
</xpath>
</data>