add field quantity_mix_required
This commit is contained in:
parent
ae1caf3697
commit
310121c00b
|
@ -15,3 +15,6 @@ class ProductionValidationWarning(UserWarning):
|
|||
|
||||
class DeleteSaleError(ValidationError):
|
||||
pass
|
||||
|
||||
class ProductMixRequiredError(UserError):
|
||||
pass
|
||||
|
|
|
@ -15,5 +15,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<record model="ir.message" id="msg_delete_error">
|
||||
<field name="text">The sale '%(sale)s' can not delete </field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_quantity_mix_error">
|
||||
<field name="text">The quantity '%(quantity)s' must be less than '%(product_mix)s' in products mix </field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
12
product.py
12
product.py
|
@ -2,14 +2,24 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields, ModelSQL
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
from .exceptions import ProductMixRequiredError
|
||||
from trytond.i18n import gettext
|
||||
|
||||
class Product(metaclass=PoolMeta):
|
||||
__name__ = 'product.product'
|
||||
products_mix = fields.Many2Many('product.product-mix.option',
|
||||
'product', 'option', 'Mix')
|
||||
tasks = fields.One2Many('production.configuration_task', 'product', 'Tasks')
|
||||
quantity_mix_required = fields.Integer('Quantity Mix Required')
|
||||
|
||||
@fields.depends('products_mix', 'quantity_mix_required')
|
||||
def on_change_quantity_mix_required(self, name=None):
|
||||
if self.products_mix and self.quantity_mix_required and len(self.products_mix) < self.quantity_mix_required:
|
||||
raise ProductMixRequiredError(
|
||||
gettext(
|
||||
"sale_pos_frontend_rest.msg_quantity_mix_error",
|
||||
product_mix=len(self.products_mix),
|
||||
quantity=self.quantity_mix_required))
|
||||
|
||||
class ProductMixOption(ModelSQL):
|
||||
'Product Mix Option'
|
||||
|
|
|
@ -1,27 +0,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.
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import unittest
|
||||
import doctest
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
from trytond.tests.test_tryton import suite as test_suite
|
||||
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
|
||||
from trytond.tests.test_tryton import doctest_checker
|
||||
|
||||
|
||||
class CommissionWaitingTestCase(ModuleTestCase):
|
||||
'Test Commission Waiting module'
|
||||
module = 'commission_global'
|
||||
|
||||
|
||||
def suite():
|
||||
suite = test_suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
CommissionWaitingTestCase))
|
||||
suite.addTests(doctest.DocFileSuite('scenario_commission_global.rst',
|
||||
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
|
||||
checker=doctest_checker,
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
return suite
|
|
@ -5,5 +5,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<xpath expr="/form/notebook/page[@id='general']/field[@name='categories']"
|
||||
position="after">
|
||||
<field name="products_mix" colspan="2"/>
|
||||
<label name="quantity_mix_required" />
|
||||
<field name="quantity_mix_required" />
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue