Configuration default value from XML data (not default method)

This commit is contained in:
resteve 2015-04-07 14:12:57 +02:00
parent 70401abd84
commit 25cbf449d0
5 changed files with 11 additions and 35 deletions

View File

@ -2,6 +2,7 @@
# copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval, Bool
__all__ = ['Configuration']
__metaclass__ = PoolMeta
@ -12,8 +13,6 @@ class Configuration:
compute_quantity_method = fields.Property(fields.Selection([
('quantity', 'Quantity'),
('forecast_quantity', 'Forecast Quantity'),
], 'Compute Quantity Method'))
@staticmethod
def default_compute_quantity_method():
return 'quantity'
], 'Compute Quantity Method', states={
'required': Bool(Eval('context', {}).get('company')),
}))

View File

@ -3,12 +3,16 @@
copyright notices and license terms. -->
<tryton>
<data>
<!-- stock.configuration -->
<record model="ir.ui.view" id="stock_configuration_view_form">
<field name="model">stock.configuration</field>
<field name="inherit"
ref="stock.stock_configuration_view_form"/>
<field name="inherit" ref="stock.stock_configuration_view_form"/>
<field name="name">configuration_form</field>
</record>
<record model="ir.property" id="property_compute_quantity_method">
<field name="field"
search="[('model.model', '=', 'stock.configuration'), ('name', '=', 'compute_quantity_method')]" />
<field name="value">,quantity</field>
</record>
</data>
</tryton>

View File

@ -2,14 +2,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.supply.by.product.wizard:"
msgid ""
"The computed quantity method is not configured. Please, configure it before "
"run this wizard."
msgstr ""
"El mètode de càlcul de quantitat no està configurat. Si us plau, configureu-"
"lo abans d'executar aquest assistent."
msgctxt "field:stock.configuration,compute_quantity_method:"
msgid "Compute Quantity Method"
msgstr "Mètode de càlcul de quantitat"

View File

@ -2,14 +2,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:stock.supply.by.product.wizard:"
msgid ""
"The computed quantity method is not configured. Please, configure it before "
"run this wizard."
msgstr ""
"El método de cálculo de cantidad no está configurado. Por favor, configurelo"
" antes de usar este asistente."
msgctxt "field:stock.configuration,compute_quantity_method:"
msgid "Compute Quantity Method"
msgstr "Método de cálculo de cantidad"

View File

@ -50,15 +50,6 @@ class StockSupplyByProductWizard(Wizard):
])
request = StateAction('stock_supply.act_purchase_request_form')
@classmethod
def __setup__(cls):
super(StockSupplyByProductWizard, cls).__setup__()
cls._error_messages.update({
'compute_quantity_method_error': 'The computed quantity '
'method is not configured. Please, configure it before run '
'this wizard.',
})
def do_request(self, action):
pool = Pool()
PurchaseRequest = pool.get('purchase.request')
@ -70,8 +61,6 @@ class StockSupplyByProductWizard(Wizard):
products = Products.browse(products)
supplier = self.start.supplier
compute_quantity_method = Configuration(1).compute_quantity_method
if not compute_quantity_method:
self.raise_user_error('compute_quantity_method_error')
vlist = []
for product in products: