From ca91f068b38e5bb33863ca301afef2d46d8a7093 Mon Sep 17 00:00:00 2001
From: Quentin Dupont
Date: Wed, 22 Jun 2022 10:14:36 +0200
Subject: [PATCH] [IMP] constrains, roadmap, flake8
---
.../README.rst | 7 +++++
.../__manifest__.py | 2 +-
.../models/mrp_bom.py | 2 +-
.../models/mrp_bom_line.py | 14 +++++++--
.../readme/ROADMAP.rst | 3 ++
.../static/description/index.html | 31 ++++++++++++-------
6 files changed, 43 insertions(+), 16 deletions(-)
create mode 100644 mrp_bom_widget_section_and_note_one2many/readme/ROADMAP.rst
diff --git a/mrp_bom_widget_section_and_note_one2many/README.rst b/mrp_bom_widget_section_and_note_one2many/README.rst
index 49d2439fe..76ec8c158 100644
--- a/mrp_bom_widget_section_and_note_one2many/README.rst
+++ b/mrp_bom_widget_section_and_note_one2many/README.rst
@@ -42,6 +42,13 @@ Usage
.. figure:: https://raw.githubusercontent.com/quentinDupont/manufacture/12.0_ADD_MRP_Widget_Sectionnote/mrp_bom_widget_section_and_note_one2many/static/description/mrp_bom_widget_add_section_and_note.gif
+Known issues / Roadmap
+======================
+
+mrp_bom_component_menu module (and maybe more) displays bom lines and it
+display lines of sections and note, with product_id empty. It should not display
+theses lines
+
Bug Tracker
===========
diff --git a/mrp_bom_widget_section_and_note_one2many/__manifest__.py b/mrp_bom_widget_section_and_note_one2many/__manifest__.py
index f2b5c5928..44c826b35 100644
--- a/mrp_bom_widget_section_and_note_one2many/__manifest__.py
+++ b/mrp_bom_widget_section_and_note_one2many/__manifest__.py
@@ -7,7 +7,7 @@
"name": "MRP Widget Section and Note in BoM",
"summary": "Add section and note in Bills of Materials",
"version": "12.0.1.1.0",
- "category": "GRAP - Incubator",
+ "category": "Manufacturing/Manufacturing",
"author": "GRAP,"
"Odoo Community Association (OCA)",
"website": "https://github.com/grap/grap-odoo-incubator",
diff --git a/mrp_bom_widget_section_and_note_one2many/models/mrp_bom.py b/mrp_bom_widget_section_and_note_one2many/models/mrp_bom.py
index 29e4eed82..c9f936cef 100644
--- a/mrp_bom_widget_section_and_note_one2many/models/mrp_bom.py
+++ b/mrp_bom_widget_section_and_note_one2many/models/mrp_bom.py
@@ -10,7 +10,7 @@ class MrpBom(models.Model):
_inherit = "mrp.bom"
# Split bom_line_ids in two fields handled thanks to domain
- # Keeping original field bom_line_ids to keep all the native functionnalities
+ # Keep original field bom_line_ids to keep all the native functionnalities
bom_line_ids = fields.One2many(domain=[("display_type", "=", False)])
bom_line_with_sectionnote_ids = fields.One2many(
diff --git a/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py b/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py
index 81d187436..bba6370fe 100644
--- a/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py
+++ b/mrp_bom_widget_section_and_note_one2many/models/mrp_bom_line.py
@@ -9,9 +9,8 @@ from odoo import fields, models
class MrpBomLine(models.Model):
_inherit = "mrp.bom.line"
- # To handle bom_line section & note, we have to make these fiels not required
+ # Returns mandatory for classic line thanks to _sql_constraints and view
product_id = fields.Many2one(required=False)
- product_qty = fields.Float(required=False)
# New fields to handle section & note
name = fields.Text(string="Description")
@@ -21,3 +20,14 @@ class MrpBomLine(models.Model):
default=False,
help="Technical field for UX purpose.",
)
+
+ _sql_constraints = [
+ ('bom_required_fields',
+ "CHECK(display_type IS NOT NULL OR"
+ "(product_id IS NOT NULL AND product_qty IS NOT NULL))",
+ "Missing required fields on bom line."),
+ ('non_bom_null_fields',
+ "CHECK(display_type IS NULL OR"
+ "(product_id IS NULL AND product_qty = 1))",
+ "Forbidden values on note and section bom line"),
+ ]
diff --git a/mrp_bom_widget_section_and_note_one2many/readme/ROADMAP.rst b/mrp_bom_widget_section_and_note_one2many/readme/ROADMAP.rst
new file mode 100644
index 000000000..3fa137b0c
--- /dev/null
+++ b/mrp_bom_widget_section_and_note_one2many/readme/ROADMAP.rst
@@ -0,0 +1,3 @@
+mrp_bom_component_menu module (and maybe more) displays bom lines and it
+display lines of sections and note, with product_id empty. It should not display
+theses lines
diff --git a/mrp_bom_widget_section_and_note_one2many/static/description/index.html b/mrp_bom_widget_section_and_note_one2many/static/description/index.html
index 4260f9cfd..3037942dc 100644
--- a/mrp_bom_widget_section_and_note_one2many/static/description/index.html
+++ b/mrp_bom_widget_section_and_note_one2many/static/description/index.html
@@ -378,12 +378,13 @@ section_and_note_fields_backend.js in account module.
+
+
+
mrp_bom_component_menu module (and maybe more) displays bom lines and it
+display lines of sections and note, with product_id empty. It should not display
+theses lines
+
-
+
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
@@ -409,28 +416,28 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
Do not contact contributors directly about support or help with technical issues.