Add error message when trying to open stock from a template that is not marqued as unique variant
This commit is contained in:
parent
13f89bdac9
commit
d2aad1aa01
|
@ -2,10 +2,26 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:product.by_location:"
|
||||
msgid ""
|
||||
"The template \"%s\" must be marked as unique variant in order to be able to "
|
||||
"see it's stock"
|
||||
msgstr ""
|
||||
"La plantilla \"%s\" ha d'esta marcada com a variant única per poder "
|
||||
"consultar el seu estoc."
|
||||
|
||||
msgctxt "error:product.product:"
|
||||
msgid "The Template of the Product Variant must be unique."
|
||||
msgstr "La Plantilla a les Variants de producte ha de ser única."
|
||||
|
||||
msgctxt "error:stock.product_quantities_warehouse:"
|
||||
msgid ""
|
||||
"The template \"%s\" must be marked as unique variant in order to be able to "
|
||||
"see it's stock"
|
||||
msgstr ""
|
||||
"La plantilla \"%s\" ha d'esta marcada com a variant única per poder "
|
||||
"consultar el seu estoc."
|
||||
|
||||
msgctxt "field:product.configuration,unique_variant:"
|
||||
msgid "Unique variant"
|
||||
msgstr "Variant única"
|
||||
|
|
|
@ -2,10 +2,26 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "error:product.by_location:"
|
||||
msgid ""
|
||||
"The template \"%s\" must be marked as unique variant in order to be able to "
|
||||
"see it's stock"
|
||||
msgstr ""
|
||||
"La plantilla \"%s\" debe estar marcada como variante única para poder "
|
||||
"consultar su estoc."
|
||||
|
||||
msgctxt "error:product.product:"
|
||||
msgid "The Template of the Product Variant must be unique."
|
||||
msgstr "La Plantilla en las Variantes de producte debe ser única."
|
||||
|
||||
msgctxt "error:stock.product_quantities_warehouse:"
|
||||
msgid ""
|
||||
"The template \"%s\" must be marked as unique variant in order to be able to "
|
||||
"see it's stock"
|
||||
msgstr ""
|
||||
"La plantilla \"%s\" debe estar marcada como variante única para poder "
|
||||
"consultar su estoc."
|
||||
|
||||
msgctxt "field:product.configuration,unique_variant:"
|
||||
msgid "Unique variant"
|
||||
msgstr "Variante única"
|
||||
|
|
47
product.py
47
product.py
|
@ -116,13 +116,34 @@ class Product:
|
|||
class ProductByLocation:
|
||||
__name__ = 'product.by_location'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ProductByLocation, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'not_unique_variant': ('The template "%s" must be marked as '
|
||||
'unique variant in order to be able to see it\'s stock'),
|
||||
})
|
||||
|
||||
def default_start(self, fields):
|
||||
Template = Pool().get('product.template')
|
||||
try:
|
||||
res = super(ProductByLocation, self).default_start(fields)
|
||||
except AttributeError:
|
||||
res = {}
|
||||
context = Transaction().context
|
||||
if context['active_model'] == 'product.template':
|
||||
template = Template(context['active_id'])
|
||||
if not template.unique_variant:
|
||||
self.raise_user_error('not_unique_variant', template.rec_name)
|
||||
return res
|
||||
|
||||
def do_open(self, action):
|
||||
Template = Pool().get('product.template')
|
||||
|
||||
context = Transaction().context
|
||||
if context['active_model'] == 'product.template':
|
||||
template = Template(context['active_id'])
|
||||
if not template.unique_variant or not template.products:
|
||||
if not template.products:
|
||||
return None, {}
|
||||
product_id = template.products[0].id
|
||||
new_context = {
|
||||
|
@ -138,13 +159,35 @@ class ProductByLocation:
|
|||
class OpenProductQuantitiesByWarehouse:
|
||||
__name__ = 'stock.product_quantities_warehouse'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(OpenProductQuantitiesByWarehouse, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'not_unique_variant': ('The template "%s" must be marked as '
|
||||
'unique variant in order to be able to see it\'s stock'),
|
||||
})
|
||||
|
||||
def default_start(self, fields):
|
||||
Template = Pool().get('product.template')
|
||||
try:
|
||||
res = super(OpenProductQuantitiesByWarehouse, self).default_start(
|
||||
fields)
|
||||
except AttributeError:
|
||||
res = {}
|
||||
context = Transaction().context
|
||||
if context['active_model'] == 'product.template':
|
||||
template = Template(context['active_id'])
|
||||
if not template.unique_variant:
|
||||
self.raise_user_error('not_unique_variant', template.rec_name)
|
||||
return res
|
||||
|
||||
def do_open_(self, action):
|
||||
Template = Pool().get('product.template')
|
||||
|
||||
context = Transaction().context
|
||||
if context['active_model'] == 'product.template':
|
||||
template = Template(context['active_id'])
|
||||
if not template.unique_variant or not template.products:
|
||||
if not template.products:
|
||||
return None, {}
|
||||
product_id = template.products[0].id
|
||||
new_context = {
|
||||
|
|
Loading…
Reference in New Issue