-
-
Notifications
You must be signed in to change notification settings - Fork 787
[18.0][OU-ADD] mrp #5092
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
[18.0][OU-ADD] mrp #5092
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Copyright 2025 Hunki Enterprises BV | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from openupgradelib import openupgrade | ||
|
|
||
|
|
||
| def mrp_document_to_product_document(env): | ||
| """ | ||
| mrp.document has been replaced by product.document. | ||
| copy all records of mrp_document to product_document, keep a link | ||
| """ | ||
| link_column = openupgrade.get_legacy_name("mrp_document_id") | ||
| openupgrade.add_columns( | ||
| env, | ||
| [("product.document", link_column, "integer")], | ||
| ) | ||
| openupgrade.logged_query( | ||
| env.cr, | ||
| f""" | ||
| INSERT INTO product_document | ||
| (ir_attachment_id, active, sequence, {link_column}) | ||
| SELECT | ||
| ir_attachment_id, active, 10-COALESCE(priority, '0')::int, id | ||
| FROM mrp_document | ||
| """, | ||
| ) | ||
|
|
||
|
|
||
| @openupgrade.migrate() | ||
| def migrate(env, version): | ||
| mrp_document_to_product_document(env) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,36 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Copyright 2025 Hunki Enterprises BV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from openupgradelib import openupgrade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_columns = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("product.document", "attached_on_mrp", "char", "hidden"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| copy_columns = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "mrp_production": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("location_dest_id", "location_final_id", "integer"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MiquelRForgeFlow marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def mrp_workorder_sequence(env): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Precreate sequence field and fill with operation_id.sequence or 100 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openupgrade.add_columns(env, [("mrp.workorder", "sequence", "integer", 100)]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env.cr.execute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UPDATE mrp_workorder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SET sequence=COALESCE(mrp_routing_workcenter.sequence, mrp_workorder.sequence) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM mrp_routing_workcenter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WHERE mrp_workorder.operation_id=mrp_routing_workcenter.id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the point of this? In my version, work orders without operation_id are ordered by
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, should we update them by |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @openupgrade.migrate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def migrate(env, version): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openupgrade.add_columns(env, add_columns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openupgrade.copy_columns(env.cr, copy_columns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mrp_workorder_sequence(env) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| ---Models in module 'mrp'--- | ||
| obsolete model mrp.document (merged to product.document) | ||
|
|
||
| # DONE: copy records from mrp_document to product_document | ||
|
|
||
| new model mrp.batch.produce [transient] | ||
|
|
||
| # NOTHING TO DO | ||
|
|
||
| ---Fields in module 'mrp'--- | ||
| mrp / mrp.document / _inherits : DEL _inherits: {'ir.attachment': 'ir_attachment_id'}, stored: False | ||
| mrp / mrp.document / active (boolean) : DEL | ||
| mrp / mrp.document / ir_attachment_id (many2one) : DEL relation: ir.attachment, required | ||
| mrp / mrp.document / priority (selection) : DEL selection_keys: ['0', '1', '2', '3'] | ||
|
|
||
| # DONE: see above | ||
|
|
||
| mrp / mrp.production / location_final_id (many2one) : NEW relation: stock.location | ||
|
|
||
| # DONE: copy from location_dest_id | ||
|
|
||
| mrp / mrp.production / never_product_template_attribute_value_ids (many2many): NEW relation: product.template.attribute.value | ||
|
|
||
| # NOTHING TO DO: new feature | ||
|
|
||
| mrp / mrp.production / search_date_category (selection): NEW selection_keys: ['after', 'before', 'day_1', 'day_2', 'today', 'yesterday'], stored: False | ||
|
|
||
| # NOTHING TO DO: virtual search field | ||
|
|
||
| mrp / mrp.routing.workcenter / activity_ids (one2many) : NEW relation: mail.activity | ||
| mrp / mrp.routing.workcenter / message_follower_ids (one2many): NEW relation: mail.followers | ||
| mrp / mrp.routing.workcenter / message_ids (one2many) : NEW relation: mail.message | ||
| mrp / mrp.routing.workcenter / rating_ids (one2many) : NEW relation: rating.rating | ||
| mrp / mrp.routing.workcenter / website_message_ids (one2many): NEW relation: mail.message | ||
|
|
||
| # NOTHING TO DO: mail/activity mixin added, new feature | ||
|
|
||
| mrp / mrp.unbuild / bom_id (many2one) : now a function | ||
| mrp / mrp.unbuild / lot_id (many2one) : now a function | ||
|
|
||
| # NOTHING TO DO: function are defaults | ||
|
|
||
| mrp / mrp.workcenter / message_follower_ids (one2many): NEW relation: mail.followers | ||
| mrp / mrp.workcenter / message_ids (one2many) : NEW relation: mail.message | ||
| mrp / mrp.workcenter / rating_ids (one2many) : NEW relation: rating.rating | ||
| mrp / mrp.workcenter / website_message_ids (one2many): NEW relation: mail.message | ||
|
|
||
| # NOTHING TO DO: mail mixin added, new feature | ||
|
|
||
| mrp / mrp.workorder / _order : _order is now 'sequence, leave_id, date_start, id' ('leave_id, date_start, id') | ||
|
|
||
| # DONE: set from operation_id.sequence | ||
|
|
||
| mrp / mrp.workorder / production_date (datetime) : not related anymore | ||
| mrp / mrp.workorder / production_date (datetime) : now a function | ||
|
|
||
| # NOTHING TO DO | ||
|
|
||
| mrp / mrp.workorder / sequence (integer) : NEW hasdefault: default | ||
|
|
||
| # DONE: see above | ||
|
|
||
| mrp / product.document / attached_on_mrp (selection) : NEW required, selection_keys: ['bom', 'hidden'], hasdefault: default | ||
|
|
||
| # NOTHING TO DO: we can't detect if a document has been attached via the bom or the product itself, so we keep the default 'hidden' | ||
|
|
||
| mrp / stock.move / manual_consumption (boolean) : not a function anymore | ||
|
|
||
| # NOTHING TO DO: can be edited manually now | ||
|
|
||
| mrp / stock.picking.type / use_auto_consume_components_lots (boolean): DEL | ||
|
|
||
| # NOTHING TO DO: replaced by manual_consumption being manually editable above | ||
MiquelRForgeFlow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ---XML records in module 'mrp'--- | ||
| NEW ir.actions.act_window: mrp.action_mrp_batch_produce | ||
| NEW ir.actions.act_window: mrp.action_picking_tree_mrp_operation_graph | ||
| DEL ir.actions.act_window: mrp.act_assign_serial_numbers_production | ||
| NEW ir.actions.server: mrp.action_pause_workorders | ||
| NEW ir.actions.server: mrp.action_print_labels | ||
| NEW ir.actions.server: mrp.action_production_order_lock_unlock | ||
| NEW ir.actions.server: mrp.action_production_order_scrap | ||
| NEW ir.actions.server: mrp.action_start_workorders | ||
| NEW ir.model.access: mrp.access_mrp_batch_produce | ||
| NEW ir.model.access: mrp.access_stock_move_mrp_user | ||
| NEW ir.ui.view: mrp.mrp_production_workorder_tree_editable_view_mo_form | ||
| NEW ir.ui.view: mrp.product_document_form | ||
| NEW ir.ui.view: mrp.product_view_search_catalog | ||
| NEW ir.ui.view: mrp.view_mrp_batch_produce_form | ||
| NEW ir.ui.view: mrp.view_mrp_stock_move_operations | ||
| NEW ir.ui.view: mrp.view_stock_rule_form | ||
| DEL ir.ui.view: mrp.mrp_workorder_view_gantt | ||
| DEL ir.ui.view: mrp.view_assign_serial_numbers_production | ||
| DEL ir.ui.view: mrp.view_document_file_kanban_mrp | ||
| DEL ir.ui.view: mrp.view_mrp_document_form | ||
| DEL ir.ui.view: mrp.workcenter_line_gantt_production | ||
| NEW mail.message.subtype: mrp.mrp_mo_in_cancelled (noupdate) | ||
| NEW mail.message.subtype: mrp.mrp_mo_in_confirmed (noupdate) | ||
| NEW mail.message.subtype: mrp.mrp_mo_in_done (noupdate) | ||
| NEW mail.message.subtype: mrp.mrp_mo_in_progress (noupdate) | ||
| NEW mail.message.subtype: mrp.mrp_mo_in_to_close (noupdate) | ||
|
|
||
| # NOTHING TO DO | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It think https://github.com/OCA/OpenUpgrade/blob/17.0/openupgrade_scripts/scripts/product/17.0.1.2/post-migration.py#L61 also included the ones in mrp.document. So, in fact, I think we should just check
product_document.ir_attachment_idwithmpr_document.ir_attachment_idand where is match setattached_on_mrp = 'bom'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IA says:

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does it matter what the v17 migration did? This needs to work for just 17->18 too, so if there's anything to do, it's excluding attachments that are mrp.documents in the v17 migration.
Not sure how the word soup is helpful? We can't do anything about the field because this is set depending on the attachment being created via a bom or not, which we simply don't know, so I think defaulting to
hiddenis the right thing to doThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, just not set
hiddenfor them.