Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4613][ADD] quality_control_oca, quality_control_stock_oca #139

Open
wants to merge 13 commits into
base: 16.0
Choose a base branch
from

Conversation

yostashiro
Copy link
Member

4613

Supersedes #136 and #137.

@yostashiro yostashiro force-pushed the 4613-add2-quality_control_stock_oca branch 4 times, most recently from c1f0c4c to 3e47632 Compare June 10, 2024 08:56
…or confirmed moves

This commit adds the timing field in the QC trigger line to enable
following scenarios:

- When timing is 'Before', an inspection is generated wfor each related
  move when a picking with the trigger is confirmed.
- When timing is 'Plan Ahead', a 'Plan' inspection is generated for
  each related move when a picking with the trigger is confirmed. A
  plan inspection is just a plan, and cannot be updated except for the
  date. A plan inspection gets converted into an executable inspection
  once the picking is done.
@yostashiro yostashiro force-pushed the 4613-add2-quality_control_stock_oca branch from 3e47632 to d87bfa4 Compare June 10, 2024 09:25
Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: LGTM

@yostashiro yostashiro force-pushed the 4613-add2-quality_control_stock_oca branch from 924bf9b to 766dd03 Compare June 16, 2024 05:36
@yostashiro
Copy link
Member Author

Wasn't sure the approach of the last commit to avoid the CacheMiss error was the correct one. @AungKoKoLin1997 Can you please help check.

I was getting errors of the following kind from stock_move_line_serial_unique before the last commit:

2024-06-16 05:28:44,952 1040527 ERROR 06axlstest5 odoo.addons.stock_move_line_serial_unique.tests.test_stock_move_line_serial_unique: ERROR: TestStockQuantSerialUnique.test_picking_in_serials_with_and_without_stock
Traceback (most recent call last):
  File "/project_directory/odoo/odoo/api.py", line 1007, in get
    cache_value = field_cache[record._ids[0]]
KeyError: 287

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/project_directory/odoo/odoo/fields.py", line 1161, in __get__
    value = env.cache.get(record, self)
  File "/project_directory/odoo/odoo/api.py", line 1014, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'stock.move(287,).picking_type_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/project_directory/axls-oca/stock_move_line_serial_unique/tests/test_stock_move_line_serial_unique.py", line 89, in test_picking_in_serials_with_and_without_stock
    picking_in.button_validate()
  File "/project_directory/odoo/addons/stock/models/stock_picking.py", line 1115, in button_validate
    pickings_to_backorder.with_context(cancel_backorder=False)._action_done()
  File "/project_directory/axls-oca/quality_control_stock_oca/models/stock_picking.py", line 80, in _action_done
    res = super()._action_done()
  File "/project_directory/odoo/addons/stock/models/stock_picking.py", line 917, in _action_done
    todo_moves._action_done(cancel_backorder=self.env.context.get('cancel_backorder'))
  File "/project_directory/odoo/addons/stock/models/stock_move.py", line 1815, in _action_done
    moves_ids_todo |= move._create_extra_move().ids
  File "/project_directory/odoo/addons/stock/models/stock_move.py", line 1792, in _create_extra_move
    extra_move = extra_move._action_confirm(merge_into=self)
  File "/project_directory/axls-oca/quality_control_stock_oca/models/stock_move.py", line 72, in _action_confirm
    move.trigger_inspection(["before", "plan_ahead"])
  File "/project_directory/axls-oca/quality_control_stock_oca/models/stock_move.py", line 44, in trigger_inspection
    qc_trigger = get_qc_trigger(self.picking_type_id)
  File "/project_directory/odoo/odoo/fields.py", line 2804, in __get__
    return super().__get__(records, owner)
  File "/project_directory/odoo/odoo/fields.py", line 1191, in __get__
    raise MissingError("\n".join([
odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: stock.move(287,), User: 1)

Comment on lines 68 to 69
res = super()._action_confirm(merge=merge, merge_into=merge_into)
for move in self:
Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yostashiro I understand the intention of using @lru_cache() decorator for get_qc_trigger.
But I still don't understand why we can't use for move in res instead of checking picking_type_id in cache.
I think using confirmed moves instead of self is more structured and avoid unnecessary issues.

@kanda999 kanda999 force-pushed the 4613-add2-quality_control_stock_oca branch from 4f1a390 to 0ed43b8 Compare July 23, 2024 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants