Tryton - Issues

 

Issue8742

Title Set parent field in One2Many records
Priority feature Status resolved
Superseder Nosy List albertca, ced, reviewbot, roundup-bot
Type feature request Components trytond
Assigned To ced Keywords review
Reviews 262301002
View: 262301002

Created on 2019-10-19.11:13:25 by ced, last changed by roundup-bot.

Messages
New changeset 03b33e96aad3 by Cédric Krier in branch 'default':
Do not consider as changed the reverse field of One2Many
https://hg.tryton.org/tryton-env/rev/03b33e96aad3
New changeset 54d266c10ad0 by Cédric Krier in branch 'default':
Do not consider as changed the reverse field of One2Many
https://hg.tryton.org/trytond/rev/54d266c10ad0
msg53291 (view) Author: [hidden] (albertca) (Tryton committer) Date: 2019-11-17.20:49:29
I reopen it because account_invoice scenarios are still failing after the second commit:

======================================================================
FAIL: /home/albert/d/default2/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst
Doctest: scenario_invoice.rst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.7/doctest.py", line 2196, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for scenario_invoice.rst
  File "/home/albert/d/default2/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst", line 0

----------------------------------------------------------------------
File "/home/albert/d/default2/trytond/trytond/modules/account_invoice/tests/scenario_invoice.rst", line 142, in scenario_invoice.rst
Failed example:
    line.product = product
Exception raised:
    Traceback (most recent call last):
      File "/home/albert/d/default2/trytond/trytond/model/model.py", line 277, in __getattr__
        return self._values[name]
    KeyError: '_changed_values'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.7/doctest.py", line 1329, in __run
        compileflags, 1), test.globs)
      File "<doctest scenario_invoice.rst[95]>", line 1, in <module>
        line.product = product
      File "/home/albert/d/default2/proteus/proteus/__init__.py", line 280, in __set__
        super(Many2OneDescriptor, self).__set__(instance, value)
      File "/home/albert/d/default2/proteus/proteus/__init__.py", line 128, in __set__
        instance._on_change([self.name])
      File "/home/albert/d/default2/proteus/proteus/__init__.py", line 1170, in _on_change
        self._parent._on_change([self._parent_field_name])
      File "/home/albert/d/default2/proteus/proteus/__init__.py", line 1136, in _on_change
        changes = getattr(self._proxy, 'on_change')(values, names, context)
      File "/home/albert/d/default2/proteus/proteus/config.py", line 193, in __call__
        result = rpc.result(meth(inst, *args, **kwargs))
      File "/home/albert/d/default2/trytond/trytond/model/modelview.py", line 730, in on_change
        return [self._changed_values]
      File "/home/albert/d/default2/trytond/trytond/model/modelstorage.py", line 1403, in __getattr__
        return super(ModelStorage, self).__getattr__(name)
      File "/home/albert/d/default2/trytond/trytond/model/model.py", line 280, in __getattr__
        % (self.__name__, name, self._values))
    AttributeError: 'account.invoice' Model has no attribute '_changed_values': {'type': 'out', 'accounting_date': None, 'taxes': (Pool().get('account.invoice.tax')(**{'amount': Decimal('0.00'), 'base': Decimal('0.00'), 'create_date': datetime.datetime(2019, 11, 17, 19, 40, 35, 752628), 'create_uid': 1, 'manual': False, 'description': 'Tax 0.10', 'legal_notice': None, 'tax': 1, 'account': 7, 'sequence': None, 'invoice': -40}),), 'invoice_date': None, 'party': Pool().get('party.party')(2), 'lines': (Pool().get('account.invoice.line')(**{'account': 6, 'amount': Decimal('0.00'), 'company': 1, 'create_date': datetime.datetime(2019, 11, 17, 19, 40, 35, 698288), 'create_uid': 1, 'currency': 1, 'currency_digits': 2, 'description': None, 'invoice_state': 'draft', 'invoice_taxes': [], 'invoice_type': None, 'note': None, 'origin': None, 'party': None, 'party_lang': None, 'product': 1, 'product_uom_category': 1, 'quantity': None, 'rec_name': None, 'sequence': None, 'taxes': [1], 'type': 'line', 'unit': 1, 'unit_digits': 0, 'unit_price': None, 'write_date': None, 'write_uid': None, 'invoice': -40}),), 'currency': Pool().get('currency.currency')(1), 'untaxed_amount': Decimal('0.00'), 'tax_amount': Decimal('0.00'), 'total_amount': Decimal('0.00')}
New changeset 224943154596 by Cédric Krier in branch 'default':
Do not try to save reverse field of One2Many
https://hg.tryton.org/tryton-env/rev/224943154596
New changeset ded7271ed68f by Cédric Krier in branch 'default':
Do not try to save reverse field of One2Many
https://hg.tryton.org/trytond/rev/ded7271ed68f
msg53262 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-11-16.15:36:06
I re-open it because it breaks account tests. This is because the tests set in test_tax_compute as tax.childs a list of taxes already saved. This cause an infinite loop in _save_values because the "parent" is not removed when calling target._save_values.
New changeset 3f3b453e2410 by Cédric Krier in branch 'default':
Fill the reverse field in the One2Many setter
https://hg.tryton.org/tryton-env/rev/3f3b453e2410
New changeset 34c08e80e6a9 by Cédric Krier in branch 'default':
Fill the reverse field in the One2Many setter
https://hg.tryton.org/trytond/rev/34c08e80e6a9
review262301002 updated at https://codereview.tryton.org/262301002/#ps286101002
msg52573 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-10-19.11:13:24
It may be useful to have the parent field filled when setting records of One2Many. This allows to reuse the same code for saved and unsaved.
This will not be in conflict with the One2Many API because One2Many.set already force this value.
History
Date User Action Args
2019-11-17 23:47:43roundup-botsetmessages: + msg53293
2019-11-17 23:47:37roundup-botsetstatus: unread -> resolved
messages: + msg53292
2019-11-17 20:49:30albertcasetstatus: resolved -> unread
nosy: + albertca
messages: + msg53291
2019-11-16 15:50:14roundup-botsetmessages: + msg53264
2019-11-16 15:50:08roundup-botsetstatus: in-progress -> resolved
messages: + msg53263
2019-11-16 15:37:15cedsetstatus: chatting -> in-progress
2019-11-16 15:36:07cedsetstatus: resolved -> chatting
messages: + msg53262
2019-11-16 14:35:01roundup-botsetmessages: + msg53255
2019-11-16 14:34:55roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg53254
2019-10-19 11:42:56reviewbotsetnosy: + reviewbot
messages: + msg52575

Showing 10 items. Show all history (warning: this could be VERY long)