Problem with sale_price_list after migration to 6.0

Hi guys!..
I’m experiencing a weird behavior in the sale_price_list module after migrating to version 6.0.

I’m getting the following AssertionError:

75286 123145509908480 [2021-06-28 23:38:22,432] ERROR trytond.protocols.dispatcher <class 'trytond.pool.product.product'>.read(*([6, 7, 8, 10, 12, 14, 16, 17, 19], ['active', 'code', 'cost_price_uom', 'default_uom', 'default_uom_digits', 'forecast_quantity', 'list_price_uom', 'name', 'quantity', 'sale_price_uom', 'template', 'default_uom.rec_name', 'template.rec_name', 'rec_name', '_timestamp', '_write', '_delete'], {'client': 'cb554993-dc45-4806-9232-008280d15465', 'shops': [2], 'shop': 2, 'shop.rec_name': 'Tienda Principal', 'company_filter': 'one', 'company': None, 'company.rec_name': 'Distribuciones Siglo 21', 'language': 'es_419', 'language_direction': 'ltr', 'groups': [1, 19, 14, 5, 8, 2, 20, 16, 6, 21, 3, 12, 28, 22, 15, 4, 29, 31, 25, 10, 26, 9, 13, 27, 23, 24, 17, 18, 30, 11], 'locale': {'date': '%d/%m/%Y', 'grouping': [3, 3, 0], 'decimal_point': '.', 'thousands_sep': ','}, 'company_work_time': {'h': 3600, 'm': 60, 's': 1, 'Y': 6912000, 'M': 576000, 'w': 144000, 'd': 28800}, 'price_list': 1, 'locations': [4], 'stock_date_end': None, 'stock_skip_warehouse': True, 'currency': 143, 'customer': 23, 'sale_date': None, 'uom': 1, 'taxes': [], 'quantity': None}), **{}) from testuser3@
Traceback (most recent call last):
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/protocols/", line 181, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/model/", line 868, in read
    sub_ids, cls, field_list, values=sub_results)
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/model/fields/", line 105, in get
    return dict((name, call(name)) for name in names)
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/model/fields/", line 105, in <genexpr>
    return dict((name, call(name)) for name in names)
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/model/fields/", line 98, in call
    return method(records, name)
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/modules/sale/", line 111, in get_sale_price_uom
    return cls.get_sale_price(products, quantity=quantity)
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/modules/sale/", line 147, in get_sale_price
  File "/Users/fflores/PycharmProjects/tryton-env/trytond/trytond/modules/sale_price_list/", line 24, in _get_sale_unit_price
    assert == User(Transaction().user).company

I did a basic debugging with a breakpoint in the assert sentence finding that the company of the user is evaluated to None (I’ve verified that the user has indeed that company as main company)… even more strange is the fact that some times after the program stops in the breakpoint, it starts workin properly (as if the object is updating it’s property after the evaluation of the assert)… I’ve checked the response time of the database and is in the order of a few milliseconds (to make sure that it’s not due to some kind of timeout from the db or something similar)…

Have you seen something similar?.. any clues to find a solution?

Thanks in advance,

If you read the log you will see that the company context is set to None and this is causing the issue.

You should try to find in which cases and why this company is set to None.
Reading the code I see that the company used in the call is the company if the line, which is a Function field returnting the company of the parent sale.

Does you sale have any company set? If not, this is the expected behaviour

1 Like

Indeed it may be linked to Issue 10539: Set lines readonly if no company is set - Tryton issue tracker
The workaround is to set a company before editing the lines.

1 Like

Thank you guys!.. My problem was that I was using a custom sale form (the Zikzakmedia’s sale_pos form ) which happens to have an editable tree for the sale lines… it happens that the sale_line_tree view doesn’t had the “sale” field, causing that the context for the product field in sale line evaluated company as null in sao web client… my particular fix was to modify the view definition for sale_line_tree to include the sale as a hidden field… It took me a while realize that since, I don’t fully understand the way that sao uses to store the model (is it only on html fields?).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.