* Paul J Stevens [2011-05-12 09:45 +0200]:
sale.py#l887> unit_price = fields.Numeric('Unit Price', digits=(16, 4),
sale.py#l888> states={
sale.py#l889> 'invisible': Not(Equal(Eval('type'), 'line')),
sale.py#l890> 'required': Equal(Eval('type'), 'line'),
sale.py#l891> })
Brian,
afaik, you need to override the unit_price field by writing a small
tryton module with a sale.py along these lines:
class SaleLine(ModelSQL, ModelView):
_name = 'sale.line'
_rec_name = 'description'
_description = __doc__
unit_price = fields.Numeric('Unit Price', digits=(16, 4),
states={
'invisible': Not(Equal(Eval('type'), 'line')),
})
SaleLine()
basically dropping the required-ness for unit-price.
Take a look at
http://hg2.tryton.org/2.0/modules/sale/file/5b251acf9448/sale.py#l1328
for a better solution. This will not redefine states globally and is
also better for modularity.
I too find myself in need of being able to add zero-priced invoice lines
to invoices from time to time - which is not supported by tryton
out-of-the-box.
This makes me wonder if perhaps the whole required state machinery needs
to be able to allow zero values on numeric fields to satisfy the
requirement. I'm well aware of where this comes from: in python numeric
values of zero evaluate to False. However, is a business context an
explicit zero-amount is *not* the same as an unspecified amount, or in
other words: 0 is not False, only False is False.
I am a strong supporter of this idea.
We are discussing it right now in fact. ;)
I will let Cédric explain his view on this subject but I think that
there is a difference between not having the information and knowing
that this information is 0.
--
Nicolas Évrard
B2CK SPRL
rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
E-mail/Jabber: [email protected]
Website: http://www.b2ck.com/
--
[email protected] mailing list