OCA / stock-logistics-barcode

https://odoo-community.org/psc-teams/logistics-18
GNU Affero General Public License v3.0
155 stars 321 forks source link

[16.0] [MIG] stock_barcodes #587

Closed FranzPoize closed 2 months ago

angelmoya commented 4 months ago

Functional testing:

Set Barcode options: Odoo-Picking-IN-options

Set this barcode option on incoming picking type.

Configura one product tracking as serial number.

Purchase this product to create a incoming picking.

Go to incoming picking and get this error trying to open barcode interface:

Traceback (most recent call last): File "/opt/odoo/odoo/http.py", line 1633, in _serve_db return service_model.retrying(self._serve_ir_http, self.env) File "/opt/odoo/odoo/service/model.py", line 133, in retrying result = func() File "/opt/odoo/odoo/http.py", line 1660, in _serve_ir_http response = self.dispatcher.dispatch(rule.endpoint, args) File "/opt/odoo/odoo/http.py", line 1864, in dispatch result = self.request.registry['ir.http']._dispatch(endpoint) File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch result = endpoint(request.params) File "/opt/odoo/odoo/http.py", line 697, in route_wrapper result = endpoint(self, *args, *params_ok) File "/opt/odoo/addons/web/controllers/dataset.py", line 46, in call_button action = self._call_kw(model, method, args, kwargs) File "/opt/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/odoo/odoo/api.py", line 468, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/opt/odoo/odoo/api.py", line 453, in _call_kw_multi result = method(recs, args, kwargs) File "/mnt/data/odoo-addons-dir/stock_barcodes/models/stock_picking.py", line 35, in action_barcode_scan wiz.determine_todo_action() File "/mnt/data/odoo-addons-dir/stock_barcodes/wizard/stock_barcodes_read_picking.py", line 188, in determine_todo_action self.fill_todo_records() File "/mnt/data/odoo-addons-dir/stock_barcodes/wizard/stock_barcodes_read_picking.py", line 181, in fill_todo_records self.env["wiz.stock.barcodes.read.todo"].fill_records(self, [move_lines]) File "/mnt/data/odoo-addons-dir/stock_barcodes/wizard/stock_barcodes_read_todo.py", line 163, in fill_records todo_vals[key] = self._prepare_fill_record_values( File "/mnt/data/odoo-addons-dir/stock_barcodes/wizard/stock_barcodes_read_todo.py", line 88, in _prepare_fill_record_values "product_uom_qty": line.product_uom_qty, AttributeError: 'stock.move.line' object has no attribute 'product_uom_qty'

FranzPoize commented 3 months ago

Thank you @chienandalu for your review

  • There are no diffs

Yes unfortunately the differences in behavior between the legacy front and owl are truly unreconcialable... First of all the file name are changed to use the new odoo-module. Also for example most of the logic for hotkey management was in kanban renderer. In the new frontend there can be many kanban renderer instances which would have registered their own global management of hotkey this needed to be completely refactored.

  • There's missing documentation from the former code and for the new it isn't explained.

I hope it's fixed in the latest push

  • There are overrides that copy the original method (a thus the inheritance is broken for those)

Yes that is not inevitable but is the least ugly way to do what needs to be done I'll go in more detail in the review comment

FranzPoize commented 3 months ago

Yes this PR includes all the changes up to 28th of february not sure I'll have the bandwidth to add the more recent changes if somebody can help with that I'd be glad.

I'll fix the codecov issue

chienandalu commented 3 months ago

Yes this PR includes all the changes up to 28th of february not sure I'll have the bandwidth to add the more recent changes if somebody can help with that I'd be glad.

I'll fix the codecov issue

We can do this: finish your ongoing fixes and then we can supersed the migration from the 15.0 branch and putting on top your migration commit fixing conflicts and finishing whatever needs to be fixed from there. What do you think?

chienandalu commented 3 months ago

Hi, @FranzPoize what do you think about what I proposed?:

We can do this: finish your ongoing fixes and then we can supersed the migration from the 15.0 branch and putting on top your migration commit fixing conflicts and finishing whatever needs to be fixed from there. What do you think?

FranzPoize commented 2 months ago

@chienandalu I'm having a real trouble figuring how the code works.

When you use the barcode button on a picking type. It calls action_barcode_scan on the stock_picking_type models there is 3 methods that are called:

  1. First called is create this call set_candidate_picking if there is a picking_id but there is no picking_id in the parameters (even when we click on the new button on a picking type). It then calls action_show_step which sets the correct step because most filled_default are still correctly set (by _prepare_barcode_wiz_vals)

  2. Second is determine_todo_action, if the barcode option is guided, this calls fill_todo_records if there is no todo_line_ids (and there isn't) which calls _get_stock_move_lines. Since there is no picking_id, _get_stock_move_lines has to return an empty list. In this method all the default are filled but since there is no todo_line_ids all those value are set to empty sets. This then calls action_show_step again which remove the properly set step because the default value are now all empty.

  3. Third a call to fill_pending_moves this call fill_todo_records again which still does nothing.

So during action_barcode_scan:

This means no step at the end in some case (which are real convoluted but not so much).

Or simpler use the demo Picking internals barcode option on internal transfer and click on the barcode on the internal transfer picking type.

rousseldenis commented 2 months ago

/ocabot migration stock_barcodes

FranzPoize commented 2 months ago

Found the commit that adds a new call to action_show_step in determine_todo_action 50b0c67107c2c618ceff60752222305df10659b5

This seems to break the option/step finding since if there is no todo_line_ids ,which there isn't in all case where you click on a barcode button on a picking type.

My question is it suppose to work without a picking_id in the stock_barcodes_read_picking ? There is a picking_ids field but it is not used anywhere in the code.

@chienandalu @sergio-teruel

pedrobaeza commented 2 months ago

To be taken into account: #605

FranzPoize commented 2 months ago

The frontend has been completely redone this should be resolved in 16.0

Le jeu. 2 mai 2024 à 12:56, Pedro M. Baeza @.***> a écrit :

To be taken into account: #605 https://github.com/OCA/stock-logistics-barcode/pull/605

— Reply to this email directly, view it on GitHub https://github.com/OCA/stock-logistics-barcode/pull/587#issuecomment-2090201915, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHNHZYLAG6HRJBVBNBBTRTZAILU3AVCNFSM6AAAAABD6PUX2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJQGIYDCOJRGU . You are receiving this because you were mentioned.Message ID: @.***>

sergio-teruel commented 2 months ago

To be taken into account: https://github.com/OCA/stock-logistics-barcode/pull/604

sergio-teruel commented 2 months ago

@chienandalu I'm having a real trouble figuring how the code works.

When you use the barcode button on a picking type. It calls action_barcode_scan on the stock_picking_type models there is 3 methods that are called:

  • create
  • determine_todo_action
  • fill_pending_moves
  1. First called is create this call set_candidate_picking if there is a picking_id but there is no picking_id in the parameters (even when we click on the new button on a picking type). It then calls action_show_step which sets the correct step because most filled_default are still correctly set (by _prepare_barcode_wiz_vals)
  2. Second is determine_todo_action, if the barcode option is guided, this calls fill_todo_records if there is no todo_line_ids (and there isn't) which calls _get_stock_move_lines. Since there is no picking_id, _get_stock_move_lines has to return an empty list. In this method all the default are filled but since there is no todo_line_ids all those value are set to empty sets. This then calls action_show_step again which remove the properly set step because the default value are now all empty.
  3. Third a call to fill_pending_moves this call fill_todo_records again which still does nothing.

So during action_barcode_scan:

  • create sets the proper default values
  • action_show_step is called twice once it sets a step (during) create and the second time it undoes what it did because determine_todo_action unset all the default values
  • fill_todo_records is called twice and twice it does nothing

This means no step at the end in some case (which are real convoluted but not so much).

  • Set the barcode option as guided
  • Leave no step with a step number of 0 (if a step with a 0 selected is action_show_step it will trigger the lineself.step = options_required[:1].stepbecause not 0 is True).
  • And click on the barcode of the picking_type

Or simpler use the demo Picking internals barcode option on internal transfer and click on the barcode on the internal transfer picking type.

The next week in Spanish OCA days we will work about it...

pedrobaeza commented 2 months ago

Superseded by #610, that was the result of the Spanish OCA days,