AttributeError: '' Model has no attribute '_save_values'


I get some code from to create dynamically a sale from a trade but when I try to save I get the error mentionned in the title.

def get_sale_line(self, sale):
    SaleLine = Pool().get('sale.line')
    sale_line = SaleLine(
    sale_line.quantity = self.position_quantity
    sale_line.unit = self.position_unit
    sale_line.unit_price = self.pricings[0].pricing_price
    return sale_line

def _get_sale(self):
    Sale = Pool().get('')
    return Sale(
        description='test description',
        invoice_address='test address',
        shipment_address='test address',
        comment='test comment',

def create_sale(self):
    sale = self._get_sale()
    sale_lines = []
    sale.lines = sale_lines
    return sale

The error comes with this instruction:

sale = positions[0].create_sale()[sale])

Any ideas ?

Tks in advance.

Without the proper traceback, it is difficult to help.

Traceback (most recent call last):
  File "/trytond/model/", line 390, in _getitem
    return getattr(self, field)
AttributeError: '' object has no attribute '_save_values'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/trytond/model/", line 313, in __getattr__
    return self._values[name]
  File "/trytond/model/", line 392, in _getitem
    raise KeyError(field)
KeyError: '_save_values'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/trytond/", line 109, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/", line 43, in rpc
    return methods.get(request.rpc_method, _dispatch)(
  File "/trytond/", line 75, in wrapper
    return func(request, *args, **kwargs)
  File "/trytond/protocols/", line 197, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/", line 204, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/", line 720, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/model/", line 37, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/trytond/modules/trade/", line 238, in quote
  File "/trytond/modules/trade/", line 287, in _process_invoice[sale])
  File "/trytond/model/", line 33, in newfunc
    return self.func(owner, *args, **kwargs)
  File "/trytond/model/", line 1947, in save
    save_values[record] = record._save_values
  File "/trytond/model/", line 1608, in __getattr__
    return super(ModelStorage, self).__getattr__(name)
  File "/trytond/model/", line 315, in __getattr__
    raise AttributeError("'%s' Model has no attribute '%s': %s"
AttributeError: '' Model has no attribute '_save_values': < object at 0x7f82b4b8a040>

In fact first I wanted to create account.invoice from my trade module to connect with Tryton module. I had this error for account.invoice when trying to save. So I decided to generate a sale to use the method of Tryton to generate the invoice but now the error is on

An AttributeError must be raised in ModelStorage._save_values which is hidden by the property decorator. It is probably a wrong type for a field or something like that.

We should not have used a property for this attribute: Replace _save_values and _changed_values property by method call (#13317) · Issues · Tryton / Tryton · GitLab

1 Like

Ok tks I’ll investigate field side

Yes it was a problem of field type invoice_address well done Cédric, the error message misled me