Hi,
I'm trying to modify the amount value at slx_desconto on_change.
I did this:
I have a invoice.py file that has:
...
class InvoiceLine:
'Invoice Line'
__name__ = 'account.invoice.line'
slx_desconto = fields.Numeric(u'Desconto', digits=(16, 4),
states={
'invisible': Eval('type') != 'line'
},
depends=['type'],
on_change=['slx_desconto', 'amount']
)
def on_change_slx_desconto(self):
if self.type == 'line':
currency = (self.invoice.currency if self.invoice
else self.currency)
amount = (Decimal(str(self.quantity or '0.0'))
* (self.unit_price or Decimal('0.0')
- (self.slx_desconto) or Decimal('0.0')))
if currency:
return currency.round(amount)
return amount
return Decimal('0.0')
And I created "def on_change_slx_desconto(self):" to modify the way that
calculates the amount. But when I change the value, it raises this error:
Traceback (most recent call last):
File "/trytond/protocols/jsonrpc.py", line 123, in _marshaled_dispatch
response['result'] = dispatch_method(method, params)
File "/trytond/protocols/jsonrpc.py", line 156, in _dispatch
res = dispatch(*args)
File "/trytond/protocols/dispatcher.py", line 163, in dispatch
result = rpc.result(meth(inst, *args, **kwargs))
File "/trytond/modules/nfse_br/invoice.py", line 65, in
on_change_slx_desconto
if self.type == 'line':
File "/trytond/model/modelstorage.py", line 1191, in __getattr__
return super(ModelStorage, self).__getattr__(name)
File "/trytond/model/model.py", line 569, in __getattr__
% (self.__name__, name, self._values))
AttributeError: 'account.invoice.line' Model has no attribute 'type':
{'slx_desconto': Decimal('1'), 'amount': Decimal('10')}
It says that there is no 'type' on 'account.invoice.line'. Why?
--
Iasmini Gomes
Sílex Sistemas
[email protected]
www.silexsistemas.com.br