Issue 11703

Title
ModifyHeader wizard doesn't display all the current values of Purchase/Sale
Priority
bug
Status
resolved
Nosy list
ced, mrichez, reviewbot, roundup-bot, tbruyere
Assigned to
ced
Keywords
review

Created on 2022-09-13.15:41:10 by mrichez, last changed 5 days ago by roundup-bot.

Messages

New changeset 33511e3d1759 by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/tryton-env/rev/33511e3d1759
New changeset 5665e78186f4 by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/trytond/rev/5665e78186f4
New changeset 74168631a891 by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/tryton/rev/74168631a891
New changeset a963f1896290 by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/sao/rev/a963f1896290
New changeset 7089fc30a1ec by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/proteus/rev/7089fc30a1ec
New changeset 8f0ce648a628 by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/modules/sale/rev/8f0ce648a628
New changeset 6beb3c3a4247 by Cédric Krier in branch 'default':
Add straight values to wizard state view
https://hg.tryton.org/modules/purchase/rev/6beb3c3a4247
New changeset 90b4c204b53a by Cédric Krier in branch '6.4':
Ignore initial on_change call from modify header wizard
https://hg.tryton.org/tryton-env/rev/90b4c204b53a
New changeset 66e5451115cc by Cédric Krier in branch '6.4':
Ignore initial on_change call from modify header wizard
https://hg.tryton.org/modules/sale/rev/66e5451115cc
New changeset 634c519f79e9 by Cédric Krier in branch '6.4':
Ignore initial on_change call from modify header wizard
https://hg.tryton.org/modules/purchase/rev/634c519f79e9
Author: [hidden] (mrichez)
Date: 2022-09-26.13:00:48

Ok :-) (not yet backported)

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-26.12:22:09

It should be fixed by issue11706.

Author: [hidden] (mrichez)
Date: 2022-09-26.11:51:27

It's just a display problem. When saving it keeps the original values. So it's the recname displayed which is incorrect.

Author: [hidden] (mrichez)
Date: 2022-09-26.11:44:40

Something strange in the defaults values: Fields having problems are duplicated with a dot at the end.

'currency': 2, 'currency.': {'rec_name': 'Euro'},

And the field with a "dot" has not the corresponding value of the id in the field without a "dot".

Currency id 2 if for Dollar but rec_name for currency. is 'Euro'.

So i supect, id behind field is correct, but display value is default value (incorrect)

The same for payment_term: id is correct, but rec_name is default value.

Here's the defaults data when opening wizard:

(Pdb) defaults
{'company': 1, 'company.': {'rec_name': 'Preciball SA'}, 'currency': 2, 'currency.': {'rec_name': 'Euro'}, 'invoice_method': 'order', 'invoice_state': 'none', 'payment_term': 2, 'payment_term.': {'rec_name': '30 Days'}, 'shipment_method': 'order', 'shipment_state': 'none', 'state': 'draft', 'warehouse': 5, 'warehouse.': {'rec_name': 'Warehouse'}, 'comment': '', 'confirmed_by': None, 'contact': None, 'description': '', 'invoice_address': 2, 'invoice_party': None, 'lines': [], 'number': None, 'origin': None, 'party': 2, 'party_lang': 'en', 'quoted_by': None, 'reference': '', 'sale_date': datetime.date(2022, 9, 26), 'shipment_address': 2, 'shipment_party': None, 'shipping_date': None, 'tax_amount': Decimal('0'), 'total_amount': Decimal('50.00'), 'untaxed_amount': Decimal('50.00'), 'company.rec_name': 'Preciball SA', 'currency.rec_name': 'US Dollar', 'payment_term.rec_name': '60 Days', 'warehouse.rec_name': 'Warehouse', 'invoice_address.rec_name': 'Customer1', 'party.rec_name': 'Customer1', 'shipment_address.rec_name': 'Customer1'}
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-26.10:52:10

So what? They are all changed in default_start.

Author: [hidden] (mrichez)
Date: 2022-09-26.10:48:46

All the defaults of the model are loaded here: https://hg.tryton.org/trytond/file/tip/trytond/wizard/wizard.py#l92

before the defaults of the wizard.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-26.10:36:14

Those values are not filled by the default values of the model but by values of the record. This is the point of default_start.

Author: [hidden] (mrichez)
Date: 2022-09-26.10:27:52
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-26.10:15:55

But who is calling this method?

Author: [hidden] (mrichez)
Date: 2022-09-26.10:04:18

I just made test on a clean 6.4.
I add a trace (using pdb) on method "def default_currency()" and another trace on method "def on_change()".
When clicking on button modify_header, first trace is raised for the default_currency() method, then second trace is raised for the on_change() method...

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-26.09:57:31

This is not what I see. The wizard does not call the default value: https://hg.tryton.org/tryton/file/default/tryton/gui/window/wizard.py#l109

Author: [hidden] (mrichez)
Date: 2022-09-26.09:27:25

Default values are first called when opening the wizard form, then on_change is called (returning []) but default values are already there on the form.

Exemple:

  • Default currency is Euro.
  • Sale with Customer , currency is Dollar.
  • Opening modify header -> default_currency is called -> Currency is now Euro
  • On_change is called on wizard form -> returning nothing []
  • Currency displayed on wizard form is Euro instead of Dollar
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-26.08:52:01

There should be no problem as long as the on_change call returns nothing.

Author: [hidden] (mrichez)
Date: 2022-09-26.08:23:43

Don't know.... (on_change_party ?) I go on with tests...

INFO:tryton.rpc:model.sale.sale.on_change({'party': 1263, 'warehouse': 5, 'shipment_cost_method': 'order', 'carrier': 1, 'incoterm': None, 'shipment_address': 1263, 'company': 1, 'id': -1, 'invoice_party': None, 'currency': 143, 'lines': [], 'shipment_party': None, 'payment_term': 32}, ['company', 'currency', 'incoterm_location_required', 'invoice_method', 'invoice_state', 'payment_term', 'revision', 'shipment_cost_method', 'shipment_method', 'shipment_state', 'state', 'warehouse', 'advance_payment_conditions', 'advance_payment_term', 'amendments', 'available_carriers', 'available_incoterms', 'carrier', 'comment', 'confirmed_by', 'contact', 'description', 'incoterm', 'incoterm_location', 'invoice_address', 'invoice_comment', 'invoice_party', 'lines', 'number', 'origin', 'packing_comment', 'packing_instruction', 'party', 'party_lang', 'payment_term_comment', 'quoted_by', 'reference', 'sale_date', 'shipment_address', 'shipment_cost', 'shipment_party', 'shipping_date', 'shipping_invoice_instruction', 'tax_amount', 'total_amount', 'total_weight', 'untaxed_amount', 'weight_uom'], {'client': '2dc395ac-f372-4a4a-9e7b-08828fac2011', 'warehouse': 5, 'warehouse.rec_name': 'Warehouse Callenelle', 'company_filter': 'one', 'employee': 12, 'employee.rec_name': 'Maxime Richez', 'company': 1, 'company.rec_name': 'PRECIBALL SA', 'language': 'en', 'language_direction': 'ltr', 'groups': [7, 8, 34, 33, 1, 4, 10, 5, 2, 11, 6, 3, 29, 9, 12, 17, 16, 22, 20, 24, 23, 36, 25, 21, 26, 18, 19, 35, 14, 13, 15, 30], 'roles': [], 'locale': {'date': '%m/%d/%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': '.', 'mon_decimal_point': ',', 'mon_thousands_sep': '.'}, 'active_id': 24, 'active_ids': [24], 'active_model': 'sale.sale', 'action_id': 265})
---------------------------------------

INFO:tryton.rpc:model.sale.sale.on_change_with({'warehouse': 5, 'shipment_address': 1263, 'id': -1, 'party': 1263, 'carrier': 1, 'shipment_cost_method': 'order', 'company': 1, 'incoterm': None}, ['available_incoterms', 'incoterm_location_required', 'available_carriers', 'party_lang'], {'client': '2dc395ac-f372-4a4a-9e7b-08828fac2011', 'warehouse': 5, 'warehouse.rec_name': 'Warehouse Callenelle', 'company_filter': 'one', 'employee': 12, 'employee.rec_name': 'Maxime Richez', 'company': 1, 'company.rec_name': 'PRECIBALL SA', 'language': 'en', 'language_direction': 'ltr', 'groups': [7, 8, 34, 33, 1, 4, 10, 5, 2, 11, 6, 3, 29, 9, 12, 17, 16, 22, 20, 24, 23, 36, 25, 21, 26, 18, 19, 35, 14, 13, 15, 30], 'roles': [], 'locale': {'date': '%m/%d/%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': '.', 'mon_decimal_point': ',', 'mon_thousands_sep': '.'}, 'active_id': 24, 'active_ids': [24], 'active_model': 'sale.sale', 'action_id': 265})
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 1@carrier at 140187239402032>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 2@carrier at 140187239401744>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 3@carrier at 140187239400880>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 14@incoterm.incoterm at 140187239401936>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 15@incoterm.incoterm at 140187239401792>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 16@incoterm.incoterm at 140187239400640>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 17@incoterm.incoterm at 140187239400736>
INFO:tryton.gui.window.view_form.model.record:Modified fields ['id'] of <Record 18@incoterm.incoterm at 140187239402560>
INFO:tryton.rpc:model.currency.currency.get_digits(143, {'client': '2dc395ac-f372-4a4a-9e7b-08828fac2011', 'warehouse': 5, 'warehouse.rec_name': 'Warehouse Callenelle', 'company_filter': 'one', 'employee': 12, 'employee.rec_name': 'Maxime Richez', 'company': 1, 'company.rec_name': 'PRECIBALL SA', 'language': 'en', 'language_direction': 'ltr', 'groups': [7, 8, 34, 33, 1, 4, 10, 5, 2, 11, 6, 3, 29, 9, 12, 17, 16, 22, 20, 24, 23, 36, 25, 21, 26, 18, 19, 35, 14, 13, 15, 30], 'roles': [], 'locale': {'date': '%m/%d/%Y', 'grouping': [3, 0], 'decimal_point': ',', 'thousands_sep': '.', 'mon_decimal_point': ',', 'mon_thousands_sep': '.'}})
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-23.16:09:42

So what is changing the value?

Author: [hidden] (mrichez)
Date: 2022-09-23.15:44:09

I've tested patch on 6.4 (433471003) but still getting default values instead of current values...
I made a trace: on_change is called and method is returning [] (and not calling super() )

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-14.17:20:57

And here is review431591006 which implement the option to set straight values on wizard view (without calling on_change's).

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-14.15:35:29

Here is review433471003 which could be backported.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-14.15:30:42

Indeed the proper way to fix this is that in such case the wizard does not call the on_change's as it was before rev c631581ef1bb.
So I think we should have two kind of values to set on a wizard, the defaults that trigger on_change's and data which are just set. The data should be set after the defaults.

As this is a change the is not backportable, a solution for existing series could be to ignore the on_change call when it is done from the wizard action id.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-13.15:54:28

This is because the wizard is calling the on_change's when setting the default value.
The problem is that the on_change_party always reset the currency to the default one. There is also a problem with the addresses, payment term and invoice method.
Indeed I think those on_change should clear everything when the party is removed and set default value when no value (or invalid value) is set.

Author: [hidden] (mrichez)
Date: 2022-09-13.15:41:09

We notice that some values of the purchase/sale are not the same of the values in the ModifyHeader wizard (currency, payment conditions, ...)

How to reproduce:

  • Set a Company with Euro as default currency.
  • Create a Supplier with Dollar as supplier_currency
  • Create a purchase with this supplier (purchase currency is Dollar)
  • Add a line with a product
  • Run the Modify Header wizard -> Currency displayed in the wizard form is Euro
History
Date User Action Args
2022-10-01 14:46:47roundup-botsetmessages: + msg78475
2022-10-01 14:46:43roundup-botsetmessages: + msg78474
2022-10-01 14:46:39roundup-botsetmessages: + msg78473
2022-10-01 14:46:36roundup-botsetmessages: + msg78472
2022-10-01 14:46:32roundup-botsetmessages: + msg78471
2022-10-01 14:46:28roundup-botsetmessages: + msg78470
2022-10-01 14:46:24roundup-botsetmessages: + msg78469
2022-10-01 14:44:56roundup-botsetmessages: + msg78467
2022-10-01 14:44:46roundup-botsetmessages: + msg78465
2022-10-01 14:44:42roundup-botsetmessages: + msg78464
nosy: + roundup-bot
status: testing -> resolved

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