odoo-addon-mrp-attachment-mgmt 16.0.1.0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. odoo/addons/mrp_attachment_mgmt/README.rst +109 -0
  2. odoo/addons/mrp_attachment_mgmt/__init__.py +1 -0
  3. odoo/addons/mrp_attachment_mgmt/__manifest__.py +19 -0
  4. odoo/addons/mrp_attachment_mgmt/i18n/es.po +98 -0
  5. odoo/addons/mrp_attachment_mgmt/i18n/it.po +94 -0
  6. odoo/addons/mrp_attachment_mgmt/i18n/mrp_attachment_mgmt.pot +63 -0
  7. odoo/addons/mrp_attachment_mgmt/models/__init__.py +4 -0
  8. odoo/addons/mrp_attachment_mgmt/models/mrp_bom.py +33 -0
  9. odoo/addons/mrp_attachment_mgmt/models/mrp_production.py +10 -0
  10. odoo/addons/mrp_attachment_mgmt/models/mrp_workorder.py +24 -0
  11. odoo/addons/mrp_attachment_mgmt/models/product.py +35 -0
  12. odoo/addons/mrp_attachment_mgmt/readme/CONFIGURE.rst +3 -0
  13. odoo/addons/mrp_attachment_mgmt/readme/CONTRIBUTORS.rst +4 -0
  14. odoo/addons/mrp_attachment_mgmt/readme/DESCRIPTION.rst +2 -0
  15. odoo/addons/mrp_attachment_mgmt/readme/USAGE.rst +10 -0
  16. odoo/addons/mrp_attachment_mgmt/static/description/icon.png +0 -0
  17. odoo/addons/mrp_attachment_mgmt/static/description/index.html +448 -0
  18. odoo/addons/mrp_attachment_mgmt/tests/__init__.py +3 -0
  19. odoo/addons/mrp_attachment_mgmt/tests/common.py +93 -0
  20. odoo/addons/mrp_attachment_mgmt/tests/test_mrp_attachment_mgmt.py +40 -0
  21. odoo/addons/mrp_attachment_mgmt/views/mrp_bom_view.xml +22 -0
  22. odoo/addons/mrp_attachment_mgmt/views/mrp_production_views.xml +30 -0
  23. odoo/addons/mrp_attachment_mgmt/views/product_views.xml +39 -0
  24. odoo/addons/mrp_attachment_mgmt/views/workorder_attachments_views.xml +30 -0
  25. odoo_addon_mrp_attachment_mgmt-16.0.1.0.0.2.dist-info/METADATA +127 -0
  26. odoo_addon_mrp_attachment_mgmt-16.0.1.0.0.2.dist-info/RECORD +28 -0
  27. odoo_addon_mrp_attachment_mgmt-16.0.1.0.0.2.dist-info/WHEEL +5 -0
  28. odoo_addon_mrp_attachment_mgmt-16.0.1.0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,448 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6
+ <title>Mrp Attachment Mgmt</title>
7
+ <style type="text/css">
8
+
9
+ /*
10
+ :Author: David Goodger (goodger@python.org)
11
+ :Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
12
+ :Copyright: This stylesheet has been placed in the public domain.
13
+
14
+ Default cascading style sheet for the HTML output of Docutils.
15
+
16
+ See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
17
+ customize this style sheet.
18
+ */
19
+
20
+ /* used to remove borders from tables and images */
21
+ .borderless, table.borderless td, table.borderless th {
22
+ border: 0 }
23
+
24
+ table.borderless td, table.borderless th {
25
+ /* Override padding for "table.docutils td" with "! important".
26
+ The right padding separates the table cells. */
27
+ padding: 0 0.5em 0 0 ! important }
28
+
29
+ .first {
30
+ /* Override more specific margin styles with "! important". */
31
+ margin-top: 0 ! important }
32
+
33
+ .last, .with-subtitle {
34
+ margin-bottom: 0 ! important }
35
+
36
+ .hidden {
37
+ display: none }
38
+
39
+ .subscript {
40
+ vertical-align: sub;
41
+ font-size: smaller }
42
+
43
+ .superscript {
44
+ vertical-align: super;
45
+ font-size: smaller }
46
+
47
+ a.toc-backref {
48
+ text-decoration: none ;
49
+ color: black }
50
+
51
+ blockquote.epigraph {
52
+ margin: 2em 5em ; }
53
+
54
+ dl.docutils dd {
55
+ margin-bottom: 0.5em }
56
+
57
+ object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
58
+ overflow: hidden;
59
+ }
60
+
61
+ /* Uncomment (and remove this text!) to get bold-faced definition list terms
62
+ dl.docutils dt {
63
+ font-weight: bold }
64
+ */
65
+
66
+ div.abstract {
67
+ margin: 2em 5em }
68
+
69
+ div.abstract p.topic-title {
70
+ font-weight: bold ;
71
+ text-align: center }
72
+
73
+ div.admonition, div.attention, div.caution, div.danger, div.error,
74
+ div.hint, div.important, div.note, div.tip, div.warning {
75
+ margin: 2em ;
76
+ border: medium outset ;
77
+ padding: 1em }
78
+
79
+ div.admonition p.admonition-title, div.hint p.admonition-title,
80
+ div.important p.admonition-title, div.note p.admonition-title,
81
+ div.tip p.admonition-title {
82
+ font-weight: bold ;
83
+ font-family: sans-serif }
84
+
85
+ div.attention p.admonition-title, div.caution p.admonition-title,
86
+ div.danger p.admonition-title, div.error p.admonition-title,
87
+ div.warning p.admonition-title, .code .error {
88
+ color: red ;
89
+ font-weight: bold ;
90
+ font-family: sans-serif }
91
+
92
+ /* Uncomment (and remove this text!) to get reduced vertical space in
93
+ compound paragraphs.
94
+ div.compound .compound-first, div.compound .compound-middle {
95
+ margin-bottom: 0.5em }
96
+
97
+ div.compound .compound-last, div.compound .compound-middle {
98
+ margin-top: 0.5em }
99
+ */
100
+
101
+ div.dedication {
102
+ margin: 2em 5em ;
103
+ text-align: center ;
104
+ font-style: italic }
105
+
106
+ div.dedication p.topic-title {
107
+ font-weight: bold ;
108
+ font-style: normal }
109
+
110
+ div.figure {
111
+ margin-left: 2em ;
112
+ margin-right: 2em }
113
+
114
+ div.footer, div.header {
115
+ clear: both;
116
+ font-size: smaller }
117
+
118
+ div.line-block {
119
+ display: block ;
120
+ margin-top: 1em ;
121
+ margin-bottom: 1em }
122
+
123
+ div.line-block div.line-block {
124
+ margin-top: 0 ;
125
+ margin-bottom: 0 ;
126
+ margin-left: 1.5em }
127
+
128
+ div.sidebar {
129
+ margin: 0 0 0.5em 1em ;
130
+ border: medium outset ;
131
+ padding: 1em ;
132
+ background-color: #ffffee ;
133
+ width: 40% ;
134
+ float: right ;
135
+ clear: right }
136
+
137
+ div.sidebar p.rubric {
138
+ font-family: sans-serif ;
139
+ font-size: medium }
140
+
141
+ div.system-messages {
142
+ margin: 5em }
143
+
144
+ div.system-messages h1 {
145
+ color: red }
146
+
147
+ div.system-message {
148
+ border: medium outset ;
149
+ padding: 1em }
150
+
151
+ div.system-message p.system-message-title {
152
+ color: red ;
153
+ font-weight: bold }
154
+
155
+ div.topic {
156
+ margin: 2em }
157
+
158
+ h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
159
+ h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
160
+ margin-top: 0.4em }
161
+
162
+ h1.title {
163
+ text-align: center }
164
+
165
+ h2.subtitle {
166
+ text-align: center }
167
+
168
+ hr.docutils {
169
+ width: 75% }
170
+
171
+ img.align-left, .figure.align-left, object.align-left, table.align-left {
172
+ clear: left ;
173
+ float: left ;
174
+ margin-right: 1em }
175
+
176
+ img.align-right, .figure.align-right, object.align-right, table.align-right {
177
+ clear: right ;
178
+ float: right ;
179
+ margin-left: 1em }
180
+
181
+ img.align-center, .figure.align-center, object.align-center {
182
+ display: block;
183
+ margin-left: auto;
184
+ margin-right: auto;
185
+ }
186
+
187
+ table.align-center {
188
+ margin-left: auto;
189
+ margin-right: auto;
190
+ }
191
+
192
+ .align-left {
193
+ text-align: left }
194
+
195
+ .align-center {
196
+ clear: both ;
197
+ text-align: center }
198
+
199
+ .align-right {
200
+ text-align: right }
201
+
202
+ /* reset inner alignment in figures */
203
+ div.align-right {
204
+ text-align: inherit }
205
+
206
+ /* div.align-center * { */
207
+ /* text-align: left } */
208
+
209
+ .align-top {
210
+ vertical-align: top }
211
+
212
+ .align-middle {
213
+ vertical-align: middle }
214
+
215
+ .align-bottom {
216
+ vertical-align: bottom }
217
+
218
+ ol.simple, ul.simple {
219
+ margin-bottom: 1em }
220
+
221
+ ol.arabic {
222
+ list-style: decimal }
223
+
224
+ ol.loweralpha {
225
+ list-style: lower-alpha }
226
+
227
+ ol.upperalpha {
228
+ list-style: upper-alpha }
229
+
230
+ ol.lowerroman {
231
+ list-style: lower-roman }
232
+
233
+ ol.upperroman {
234
+ list-style: upper-roman }
235
+
236
+ p.attribution {
237
+ text-align: right ;
238
+ margin-left: 50% }
239
+
240
+ p.caption {
241
+ font-style: italic }
242
+
243
+ p.credits {
244
+ font-style: italic ;
245
+ font-size: smaller }
246
+
247
+ p.label {
248
+ white-space: nowrap }
249
+
250
+ p.rubric {
251
+ font-weight: bold ;
252
+ font-size: larger ;
253
+ color: maroon ;
254
+ text-align: center }
255
+
256
+ p.sidebar-title {
257
+ font-family: sans-serif ;
258
+ font-weight: bold ;
259
+ font-size: larger }
260
+
261
+ p.sidebar-subtitle {
262
+ font-family: sans-serif ;
263
+ font-weight: bold }
264
+
265
+ p.topic-title {
266
+ font-weight: bold }
267
+
268
+ pre.address {
269
+ margin-bottom: 0 ;
270
+ margin-top: 0 ;
271
+ font: inherit }
272
+
273
+ pre.literal-block, pre.doctest-block, pre.math, pre.code {
274
+ margin-left: 2em ;
275
+ margin-right: 2em }
276
+
277
+ pre.code .ln { color: grey; } /* line numbers */
278
+ pre.code, code { background-color: #eeeeee }
279
+ pre.code .comment, code .comment { color: #5C6576 }
280
+ pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
281
+ pre.code .literal.string, code .literal.string { color: #0C5404 }
282
+ pre.code .name.builtin, code .name.builtin { color: #352B84 }
283
+ pre.code .deleted, code .deleted { background-color: #DEB0A1}
284
+ pre.code .inserted, code .inserted { background-color: #A3D289}
285
+
286
+ span.classifier {
287
+ font-family: sans-serif ;
288
+ font-style: oblique }
289
+
290
+ span.classifier-delimiter {
291
+ font-family: sans-serif ;
292
+ font-weight: bold }
293
+
294
+ span.interpreted {
295
+ font-family: sans-serif }
296
+
297
+ span.option {
298
+ white-space: nowrap }
299
+
300
+ span.pre {
301
+ white-space: pre }
302
+
303
+ span.problematic {
304
+ color: red }
305
+
306
+ span.section-subtitle {
307
+ /* font-size relative to parent (h1..h6 element) */
308
+ font-size: 80% }
309
+
310
+ table.citation {
311
+ border-left: solid 1px gray;
312
+ margin-left: 1px }
313
+
314
+ table.docinfo {
315
+ margin: 2em 4em }
316
+
317
+ table.docutils {
318
+ margin-top: 0.5em ;
319
+ margin-bottom: 0.5em }
320
+
321
+ table.footnote {
322
+ border-left: solid 1px black;
323
+ margin-left: 1px }
324
+
325
+ table.docutils td, table.docutils th,
326
+ table.docinfo td, table.docinfo th {
327
+ padding-left: 0.5em ;
328
+ padding-right: 0.5em ;
329
+ vertical-align: top }
330
+
331
+ table.docutils th.field-name, table.docinfo th.docinfo-name {
332
+ font-weight: bold ;
333
+ text-align: left ;
334
+ white-space: nowrap ;
335
+ padding-left: 0 }
336
+
337
+ /* "booktabs" style (no vertical lines) */
338
+ table.docutils.booktabs {
339
+ border: 0px;
340
+ border-top: 2px solid;
341
+ border-bottom: 2px solid;
342
+ border-collapse: collapse;
343
+ }
344
+ table.docutils.booktabs * {
345
+ border: 0px;
346
+ }
347
+ table.docutils.booktabs th {
348
+ border-bottom: thin solid;
349
+ text-align: left;
350
+ }
351
+
352
+ h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
353
+ h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
354
+ font-size: 100% }
355
+
356
+ ul.auto-toc {
357
+ list-style-type: none }
358
+
359
+ </style>
360
+ </head>
361
+ <body>
362
+ <div class="document" id="mrp-attachment-mgmt">
363
+ <h1 class="title">Mrp Attachment Mgmt</h1>
364
+
365
+ <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
366
+ !! This file is generated by oca-gen-addon-readme !!
367
+ !! changes will be overwritten. !!
368
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369
+ !! source digest: sha256:aa8781c1fbe86a94327f0904ae05e3bdb29653fef631ae1d22bd1bbf337d0dd1
370
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
371
+ <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/16.0/mrp_attachment_mgmt"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_attachment_mgmt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/manufacture&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372
+ <p>This module allows to get all attachments of a bill of materials (all levels) on a view.
373
+ This module allows to get all attachments of a work orders products to produce on a view.</p>
374
+ <p><strong>Table of contents</strong></p>
375
+ <div class="contents local topic" id="contents">
376
+ <ul class="simple">
377
+ <li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
378
+ <li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
379
+ <li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
380
+ <li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
381
+ <li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
382
+ <li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
383
+ <li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
384
+ </ul>
385
+ </li>
386
+ </ul>
387
+ </div>
388
+ <div class="section" id="configuration">
389
+ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
390
+ <p>To configure this module, you need to:</p>
391
+ <ol class="arabic simple">
392
+ <li>Go to <em>Manufacturing -&gt; Configuration -&gt; Settings</em> and check “Work Orders” option.</li>
393
+ </ol>
394
+ </div>
395
+ <div class="section" id="usage">
396
+ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
397
+ <ol class="arabic simple">
398
+ <li>Go to <em>Manufacturing -&gt; Operation &gt; Work Orders</em> and click in window open button (after the “Start” and “Block” options).</li>
399
+ <li>The smart-button “Attachments” display the attachments of the related product.</li>
400
+ <li>Go to <em>Manufacturing -&gt; Products &gt; Bill of material -&gt; Desk Combination</em>.</li>
401
+ <li>Go to “Attachment” icon related to “Office Chair Black” component and upload some file.</li>
402
+ <li>The smart-button “Attachments” (from Bill of material) display the attachments of all components.</li>
403
+ <li>Go to <em>Manufacturing -&gt; Products &gt; Products -&gt; Desk Combination</em>.</li>
404
+ <li>The smart-button “Bom Attachments” display the attachments of all components from Bill of material.</li>
405
+ </ol>
406
+ </div>
407
+ <div class="section" id="bug-tracker">
408
+ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
409
+ <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
410
+ In case of trouble, please check there if your issue has already been reported.
411
+ If you spotted it first, help us to smash it by providing a detailed and welcomed
412
+ <a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_attachment_mgmt%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
413
+ <p>Do not contact contributors directly about support or help with technical issues.</p>
414
+ </div>
415
+ <div class="section" id="credits">
416
+ <h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
417
+ <div class="section" id="authors">
418
+ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
419
+ <ul class="simple">
420
+ <li>Tecnativa</li>
421
+ </ul>
422
+ </div>
423
+ <div class="section" id="contributors">
424
+ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
425
+ <ul class="simple">
426
+ <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
427
+ <li>Víctor Martínez</li>
428
+ <li>Pedro M. Baeza</li>
429
+ </ul>
430
+ </li>
431
+ </ul>
432
+ </div>
433
+ <div class="section" id="maintainers">
434
+ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
435
+ <p>This module is maintained by the OCA.</p>
436
+ <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
437
+ <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
438
+ mission is to support the collaborative development of Odoo features and
439
+ promote its widespread use.</p>
440
+ <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
441
+ <p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
442
+ <p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/16.0/mrp_attachment_mgmt">OCA/manufacture</a> project on GitHub.</p>
443
+ <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
444
+ </div>
445
+ </div>
446
+ </div>
447
+ </body>
448
+ </html>
@@ -0,0 +1,3 @@
1
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
2
+
3
+ from . import test_mrp_attachment_mgmt
@@ -0,0 +1,93 @@
1
+ # Copyright 2022 Tecnativa - Víctor Martínez
2
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3
+ import base64
4
+
5
+ from odoo import fields
6
+ from odoo.tests import Form, common
7
+
8
+
9
+ class TestMrpAttachmentMgmtBase(common.TransactionCase):
10
+ @classmethod
11
+ def setUpClass(cls):
12
+ super().setUpClass()
13
+ cls.component_a = cls.env["product.product"].create(
14
+ {
15
+ "name": "Test Component A",
16
+ "type": "product",
17
+ }
18
+ )
19
+ cls.component_b = cls.env["product.product"].create(
20
+ {
21
+ "name": "Test Component B",
22
+ "type": "product",
23
+ }
24
+ )
25
+ cls.component_c = cls.env["product.product"].create(
26
+ {
27
+ "name": "Test Component C",
28
+ "type": "product",
29
+ }
30
+ )
31
+ cls.product = cls.env["product.product"].create(
32
+ {
33
+ "name": "Test Product",
34
+ "type": "product",
35
+ }
36
+ )
37
+ cls.workcenter = cls.env["mrp.workcenter"].create(
38
+ {
39
+ "name": "Test workcenter",
40
+ "resource_calendar_id": cls.env.ref(
41
+ "resource.resource_calendar_std"
42
+ ).id,
43
+ }
44
+ )
45
+ cls.bom = cls._create_mrp_bom(
46
+ cls,
47
+ cls.product,
48
+ [(cls.component_a, 1), (cls.component_b, 1), (cls.component_c, 1)],
49
+ )
50
+ cls.mrp_production = cls._create_mrp_production(
51
+ cls, [(cls.component_a, 1), (cls.component_b, 1), (cls.component_c, 1)]
52
+ )
53
+ cls.workorder = fields.first(cls.mrp_production.workorder_ids)
54
+ cls.attachment_model = cls.env["ir.attachment"]
55
+
56
+ def _create_mrp_production(self, components):
57
+ mrp_production_form = Form(self.env["mrp.production"])
58
+ mrp_production_form.product_id = self.product
59
+ mrp_production_form.bom_id = self.bom
60
+ for component in components:
61
+ with mrp_production_form.move_raw_ids.new() as move_form:
62
+ move_form.product_id = component[0]
63
+ move_form.product_uom_qty = component[1]
64
+ mrp_production = mrp_production_form.save()
65
+ mrp_production.action_confirm()
66
+ return mrp_production
67
+
68
+ def _create_mrp_bom(self, product, components):
69
+ mrp_bom_form = Form(self.env["mrp.bom"])
70
+ mrp_bom_form.product_tmpl_id = product.product_tmpl_id
71
+ bom_with_attachments = mrp_bom_form.save()
72
+ self.env.user.groups_id += self.env.ref("mrp.group_mrp_routings")
73
+ with Form(bom_with_attachments) as bom:
74
+ for component in components:
75
+ with bom.bom_line_ids.new() as line_form:
76
+ line_form.product_id = component[0]
77
+ line_form.product_qty = component[1]
78
+ with bom.operation_ids.new() as operation_form:
79
+ operation_form.name = "Operation 1"
80
+ operation_form.workcenter_id = self.workcenter
81
+ operation_form.bom_id = bom_with_attachments
82
+ return bom_with_attachments
83
+
84
+ def _create_attachment(self, product, name=False):
85
+ name = name if name else "Test file %s" % product.name
86
+ return self.attachment_model.create(
87
+ {
88
+ "name": name,
89
+ "res_model": product._name,
90
+ "res_id": product.id,
91
+ "datas": base64.b64encode(b"\xff data"),
92
+ }
93
+ )
@@ -0,0 +1,40 @@
1
+ # Copyright 2022 Tecnativa - Víctor Martínez
2
+ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3
+ from odoo.exceptions import UserError
4
+
5
+ from .common import TestMrpAttachmentMgmtBase
6
+
7
+
8
+ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase):
9
+ @classmethod
10
+ def setUpClass(cls):
11
+ super().setUpClass()
12
+
13
+ def test_misc_bom_documents(self):
14
+ attachment_a = self._create_attachment(self.component_a)
15
+ self.env["mrp.document"].create({"ir_attachment_id": attachment_a.id})
16
+ attachment_b = self._create_attachment(self.component_b)
17
+ action = self.bom.action_see_bom_documents()
18
+ attachment_bom_items = self.attachment_model.search(action["domain"])
19
+ self.assertEqual(len(attachment_bom_items), 2)
20
+ self.assertIn(attachment_a.id, attachment_bom_items.ids)
21
+ self.assertIn(attachment_b.id, attachment_bom_items.ids)
22
+ self.assertNotIn(self.component_c.id, attachment_bom_items.mapped("res_id"))
23
+ action = self.product.action_see_bom_documents()
24
+ attachment_product_items = self.attachment_model.search(action["domain"])
25
+ self.assertEqual(attachment_bom_items, attachment_product_items)
26
+ action = self.product.product_tmpl_id.action_see_bom_documents()
27
+ attachment_template_items = self.attachment_model.search(action["domain"])
28
+ self.assertEqual(attachment_template_items, attachment_product_items)
29
+
30
+ def test_mrp_workorder_attachments(self):
31
+ with self.assertRaises(UserError):
32
+ self.workorder.action_see_workorder_attachments()
33
+ attachment = self._create_attachment(self.product)
34
+ action = self.workorder.action_see_workorder_attachments()
35
+ self.assertIn(attachment.id, self.attachment_model.search(action["domain"]).ids)
36
+
37
+ def test_mrp_production_attachments(self):
38
+ attachment = self._create_attachment(self.product)
39
+ action = self.mrp_production.action_show_attachments()
40
+ self.assertIn(attachment.id, self.attachment_model.search(action["domain"]).ids)
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <odoo>
3
+ <record id="mrp_bom_see_attachments_form_view" model="ir.ui.view">
4
+ <field name="name">mrp.bom.attachments.mrp.bom.form.view</field>
5
+ <field name="model">mrp.bom</field>
6
+ <field name="inherit_id" ref="mrp.mrp_bom_form_view" />
7
+ <field name="arch" type="xml">
8
+ <xpath
9
+ expr="//button[@name='%(mrp.action_report_mrp_bom)d']"
10
+ position="after"
11
+ >
12
+ <button
13
+ class="oe_stat_button"
14
+ name="action_see_bom_documents"
15
+ type="object"
16
+ icon="fa-files-o"
17
+ string="Attachments"
18
+ />
19
+ </xpath>
20
+ </field>
21
+ </record>
22
+ </odoo>
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <odoo>
3
+ <record id="mrp_production_form_view" model="ir.ui.view">
4
+ <field name="name">mrp.production.form - Add attachments smart-button</field>
5
+ <field name="model">mrp.production</field>
6
+ <field name="inherit_id" ref="mrp.mrp_production_form_view" />
7
+ <field name="arch" type="xml">
8
+ <xpath expr="///button[@name='action_see_move_scrap']" position="after">
9
+ <button
10
+ class="oe_stat_button"
11
+ name="action_show_attachments"
12
+ type="object"
13
+ icon="fa-files-o"
14
+ string="Attachments"
15
+ />
16
+ </xpath>
17
+ </field>
18
+ </record>
19
+ <record id="action_show_production_attachments" model="ir.actions.server">
20
+ <field name="name">Attachments</field>
21
+ <field name="model_id" ref="mrp.model_mrp_production" />
22
+ <field name="binding_model_id" ref="mrp.model_mrp_production" />
23
+ <field name="binding_view_types">list</field>
24
+ <field name="state">code</field>
25
+ <field name="code">
26
+ if records:
27
+ action = records.action_show_attachments()
28
+ </field>
29
+ </record>
30
+ </odoo>
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <odoo>
3
+ <record id="mrp_bom_see_attachments_product_template_form_view" model="ir.ui.view">
4
+ <field name="name">mrp.bom.attachments.product.template.form.view</field>
5
+ <field name="model">product.template</field>
6
+ <field name="inherit_id" ref="mrp.product_template_form_view_bom_button" />
7
+ <field name="arch" type="xml">
8
+ <xpath expr="///button[@name='action_used_in_bom']" position="after">
9
+ <button
10
+ class="oe_stat_button"
11
+ name="action_see_bom_documents"
12
+ type="object"
13
+ icon="fa-files-o"
14
+ string="Bom Attachments"
15
+ groups="mrp.group_mrp_user"
16
+ attrs="{'invisible': [('bom_count','!=',1)]}"
17
+ />
18
+ </xpath>
19
+ </field>
20
+ </record>
21
+ <record id="mrp_bom_see_attachments_product_product_form_view" model="ir.ui.view">
22
+ <field name="name">mrp.bom.attachments.product.product.form.view</field>
23
+ <field name="model">product.product</field>
24
+ <field name="inherit_id" ref="mrp.product_product_form_view_bom_button" />
25
+ <field name="arch" type="xml">
26
+ <xpath expr="///button[@name='action_used_in_bom']" position="after">
27
+ <button
28
+ class="oe_stat_button"
29
+ name="action_see_bom_documents"
30
+ type="object"
31
+ icon="fa-files-o"
32
+ string="Bom Attachments"
33
+ groups="mrp.group_mrp_user"
34
+ attrs="{'invisible': [('bom_count','!=',1)]}"
35
+ />
36
+ </xpath>
37
+ </field>
38
+ </record>
39
+ </odoo>