odoo13-addon-ddmrp 13.0.1.33.3__py3-none-any.whl → 13.0.1.34.1.dev1__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.
@@ -282,11 +282,28 @@ msgstr "Metodo di calcolo"
282
282
  msgid "Cancel"
283
283
  msgstr "Annulla"
284
284
 
285
+ #. module: ddmrp
286
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_change_location_wizard
287
+ msgid "Change"
288
+ msgstr ""
289
+
290
+ #. module: ddmrp
291
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_change_location_wizard
292
+ msgid "Change Bom Location"
293
+ msgstr ""
294
+
285
295
  #. module: ddmrp
286
296
  #: model:ir.model.fields.selection,name:ddmrp.selection__ddmrp_duplicate_buffer__type__location
297
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_form_view
287
298
  msgid "Change Location"
288
299
  msgstr "Modifica ubicazione"
289
300
 
301
+ #. module: ddmrp
302
+ #: code:addons/ddmrp/models/mrp_bom.py:0
303
+ #, python-format
304
+ msgid "Change MRP BoM Location"
305
+ msgstr ""
306
+
290
307
  #. module: ddmrp
291
308
  #: model:ir.model.fields.selection,name:ddmrp.selection__ddmrp_duplicate_buffer__type__product
292
309
  msgid "Change Product"
@@ -303,6 +320,17 @@ msgid "Change quantity in manual procurements from Stock Buffers"
303
320
  msgstr ""
304
321
  "Modifica la quantità negli approvvigionamenti manuali dai buffer di materiale"
305
322
 
323
+ #. module: ddmrp
324
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_change_location_wizard
325
+ msgid ""
326
+ "Change the inventory location that it is considered to compute when a "
327
+ "product is buffered or not.\n"
328
+ " This can potentially change the Decoupled Lead Time "
329
+ "(DLT) value.\n"
330
+ " This change is only informative and won't affect any "
331
+ "process or buffer size or recommendations."
332
+ msgstr ""
333
+
306
334
  #. module: ddmrp
307
335
  #: model:ir.model.fields,field_description:ddmrp.field_res_config_settings__module_ddmrp_chatter
308
336
  msgid "Chatter in Stock Buffers"
@@ -373,6 +401,7 @@ msgstr "Crea approvvigionamento"
373
401
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__create_uid
374
402
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__create_uid
375
403
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__create_uid
404
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__create_uid
376
405
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__create_uid
377
406
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__create_uid
378
407
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__create_uid
@@ -386,6 +415,7 @@ msgstr "Creato da"
386
415
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__create_date
387
416
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__create_date
388
417
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__create_date
418
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__create_date
389
419
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__create_date
390
420
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__create_date
391
421
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__create_date
@@ -496,6 +526,7 @@ msgstr "Fabbisogno"
496
526
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__display_name
497
527
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__display_name
498
528
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__display_name
529
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__display_name
499
530
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__display_name
500
531
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__display_name
501
532
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__display_name
@@ -696,6 +727,7 @@ msgstr "Ha giacienza nell'ubicazione origine"
696
727
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__id
697
728
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__id
698
729
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__id
730
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__id
699
731
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__id
700
732
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__id
701
733
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__id
@@ -798,6 +830,7 @@ msgstr "LT"
798
830
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run____last_update
799
831
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer____last_update
800
832
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item____last_update
833
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location____last_update
801
834
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method____last_update
802
835
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer____last_update
803
836
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile____last_update
@@ -811,6 +844,7 @@ msgstr "Ultima modifica il"
811
844
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__write_uid
812
845
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__write_uid
813
846
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__write_uid
847
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__write_uid
814
848
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__write_uid
815
849
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__write_uid
816
850
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__write_uid
@@ -824,6 +858,7 @@ msgstr "Ultimo aggiornamento di"
824
858
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__write_date
825
859
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__write_date
826
860
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__write_date
861
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__write_date
827
862
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__write_date
828
863
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__write_date
829
864
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__write_date
@@ -875,11 +910,17 @@ msgstr "Buffer di materiale collegati"
875
910
 
876
911
  #. module: ddmrp
877
912
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__location_id
913
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__location_id
878
914
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__location_id
879
915
  #: model_terms:ir.ui.view,arch_db:ddmrp.stock_buffer_search
880
916
  msgid "Location"
881
917
  msgstr "Ubicazione"
882
918
 
919
+ #. module: ddmrp
920
+ #: model:ir.model,name:ddmrp.model_mrp_bom_change_location
921
+ msgid "MRP Bom Change Location"
922
+ msgstr ""
923
+
883
924
  #. module: ddmrp
884
925
  #: model:ir.model,name:ddmrp.model_mrp_move
885
926
  msgid "MRP Move"
@@ -1655,6 +1696,14 @@ msgstr "Buffer di materiale"
1655
1696
  msgid "Stock Buffers & Packagings"
1656
1697
  msgstr "Buffer di materiale & imballi"
1657
1698
 
1699
+ #. module: ddmrp
1700
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom__context_location_id
1701
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom__location_id
1702
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_line__context_location_id
1703
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_line__location_id
1704
+ msgid "Stock Location"
1705
+ msgstr ""
1706
+
1658
1707
  #. module: ddmrp
1659
1708
  #: model:ir.model,name:ddmrp.model_stock_move
1660
1709
  msgid "Stock Move"
@@ -260,11 +260,28 @@ msgstr "计算方法"
260
260
  msgid "Cancel"
261
261
  msgstr "取消"
262
262
 
263
+ #. module: ddmrp
264
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_change_location_wizard
265
+ msgid "Change"
266
+ msgstr ""
267
+
268
+ #. module: ddmrp
269
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_change_location_wizard
270
+ msgid "Change Bom Location"
271
+ msgstr ""
272
+
263
273
  #. module: ddmrp
264
274
  #: model:ir.model.fields.selection,name:ddmrp.selection__ddmrp_duplicate_buffer__type__location
275
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_form_view
265
276
  msgid "Change Location"
266
277
  msgstr ""
267
278
 
279
+ #. module: ddmrp
280
+ #: code:addons/ddmrp/models/mrp_bom.py:0
281
+ #, python-format
282
+ msgid "Change MRP BoM Location"
283
+ msgstr ""
284
+
268
285
  #. module: ddmrp
269
286
  #: model:ir.model.fields.selection,name:ddmrp.selection__ddmrp_duplicate_buffer__type__product
270
287
  msgid "Change Product"
@@ -280,6 +297,17 @@ msgstr ""
280
297
  msgid "Change quantity in manual procurements from Stock Buffers"
281
298
  msgstr ""
282
299
 
300
+ #. module: ddmrp
301
+ #: model_terms:ir.ui.view,arch_db:ddmrp.mrp_bom_change_location_wizard
302
+ msgid ""
303
+ "Change the inventory location that it is considered to compute when a "
304
+ "product is buffered or not.\n"
305
+ " This can potentially change the Decoupled Lead Time "
306
+ "(DLT) value.\n"
307
+ " This change is only informative and won't affect any "
308
+ "process or buffer size or recommendations."
309
+ msgstr ""
310
+
283
311
  #. module: ddmrp
284
312
  #: model:ir.model.fields,field_description:ddmrp.field_res_config_settings__module_ddmrp_chatter
285
313
  msgid "Chatter in Stock Buffers"
@@ -351,6 +379,7 @@ msgstr "创建补货"
351
379
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__create_uid
352
380
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__create_uid
353
381
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__create_uid
382
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__create_uid
354
383
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__create_uid
355
384
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__create_uid
356
385
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__create_uid
@@ -364,6 +393,7 @@ msgstr "创建人"
364
393
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__create_date
365
394
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__create_date
366
395
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__create_date
396
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__create_date
367
397
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__create_date
368
398
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__create_date
369
399
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__create_date
@@ -478,6 +508,7 @@ msgstr ""
478
508
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__display_name
479
509
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__display_name
480
510
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__display_name
511
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__display_name
481
512
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__display_name
482
513
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__display_name
483
514
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__display_name
@@ -676,6 +707,7 @@ msgstr ""
676
707
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__id
677
708
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__id
678
709
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__id
710
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__id
679
711
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__id
680
712
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__id
681
713
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__id
@@ -772,6 +804,7 @@ msgstr ""
772
804
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run____last_update
773
805
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer____last_update
774
806
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item____last_update
807
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location____last_update
775
808
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method____last_update
776
809
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer____last_update
777
810
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile____last_update
@@ -785,6 +818,7 @@ msgstr ""
785
818
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__write_uid
786
819
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__write_uid
787
820
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__write_uid
821
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__write_uid
788
822
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__write_uid
789
823
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__write_uid
790
824
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__write_uid
@@ -798,6 +832,7 @@ msgstr ""
798
832
  #: model:ir.model.fields,field_description:ddmrp.field_ddmrp_run__write_date
799
833
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer__write_date
800
834
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__write_date
835
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__write_date
801
836
  #: model:ir.model.fields,field_description:ddmrp.field_product_adu_calculation_method__write_date
802
837
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__write_date
803
838
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer_profile__write_date
@@ -853,11 +888,17 @@ msgstr "库存缓冲"
853
888
 
854
889
  #. module: ddmrp
855
890
  #: model:ir.model.fields,field_description:ddmrp.field_make_procurement_buffer_item__location_id
891
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_change_location__location_id
856
892
  #: model:ir.model.fields,field_description:ddmrp.field_stock_buffer__location_id
857
893
  #: model_terms:ir.ui.view,arch_db:ddmrp.stock_buffer_search
858
894
  msgid "Location"
859
895
  msgstr ""
860
896
 
897
+ #. module: ddmrp
898
+ #: model:ir.model,name:ddmrp.model_mrp_bom_change_location
899
+ msgid "MRP Bom Change Location"
900
+ msgstr ""
901
+
861
902
  #. module: ddmrp
862
903
  #: model:ir.model,name:ddmrp.model_mrp_move
863
904
  msgid "MRP Move"
@@ -1622,6 +1663,14 @@ msgstr "库存缓冲"
1622
1663
  msgid "Stock Buffers & Packagings"
1623
1664
  msgstr "库存缓冲计划"
1624
1665
 
1666
+ #. module: ddmrp
1667
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom__context_location_id
1668
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom__location_id
1669
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_line__context_location_id
1670
+ #: model:ir.model.fields,field_description:ddmrp.field_mrp_bom_line__location_id
1671
+ msgid "Stock Location"
1672
+ msgstr ""
1673
+
1625
1674
  #. module: ddmrp
1626
1675
  #: model:ir.model,name:ddmrp.model_stock_move
1627
1676
  #, fuzzy
@@ -1,9 +1,9 @@
1
- # Copyright 2017-20 ForgeFlow S.L. (http://www.forgeflow.com)
1
+ # Copyright 2017-24 ForgeFlow S.L. (http://www.forgeflow.com)
2
2
  # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3
3
 
4
4
  import logging
5
5
 
6
- from odoo import api, fields, models
6
+ from odoo import _, api, fields, models
7
7
 
8
8
  _logger = logging.getLogger(__name__)
9
9
 
@@ -19,21 +19,29 @@ class MrpBom(models.Model):
19
19
  buffer_id = fields.Many2one(
20
20
  comodel_name="stock.buffer", string="Stock Buffer", compute="_compute_buffer",
21
21
  )
22
- dlt = fields.Float(string="Decoupled Lead Time (days)", compute="_compute_dlt",)
22
+ dlt = fields.Float(string="Decoupled Lead Time (days)", compute="_compute_dlt")
23
+ context_location_id = fields.Many2one(
24
+ comodel_name="stock.location",
25
+ string="Stock Location",
26
+ compute="_compute_context_location",
27
+ )
28
+ # This is a legacy field that can be removed in v17
29
+ location_id = fields.Many2one(related="context_location_id")
23
30
 
24
31
  def _get_search_buffer_domain(self):
25
32
  product = self.product_id
26
33
  if not product:
27
34
  if self.product_tmpl_id.product_variant_ids:
28
35
  product = self.product_tmpl_id.product_variant_ids[0]
29
- domain = [("product_id", "=", product.id)]
30
- if self.location_id:
31
- domain.append(("location_id", "=", self.location_id.id))
36
+ domain = [
37
+ ("product_id", "=", product.id),
38
+ ("location_id", "=", self.context_location_id.id),
39
+ ]
32
40
  if self.company_id:
33
41
  domain.append(("company_id", "=", self.company_id.id))
34
42
  return domain
35
43
 
36
- @api.depends("product_id", "product_tmpl_id", "location_id")
44
+ @api.depends("product_id", "product_tmpl_id", "context_location_id")
37
45
  def _compute_buffer(self):
38
46
  for record in self:
39
47
  domain = record._get_search_buffer_domain()
@@ -49,6 +57,18 @@ class MrpBom(models.Model):
49
57
  for bom in self:
50
58
  bom.is_buffered = True if bom.buffer_id else False
51
59
 
60
+ @api.depends_context("location_id")
61
+ def _compute_context_location(self):
62
+ for rec in self:
63
+ if self.env.context.get("location_id", None):
64
+ rec.context_location_id = self.env.context.get("location_id")
65
+ else:
66
+ company_id = rec.company_id or self.env.company
67
+ warehouse_id = self.env["stock.warehouse"].search(
68
+ [("company_id", "=", company_id.id)], limit=1
69
+ )
70
+ rec.context_location_id = warehouse_id.lot_stock_id.id
71
+
52
72
  def _get_produce_delay(self):
53
73
  self.ensure_one()
54
74
  return self.product_id.produce_delay or self.product_tmpl_id.produce_delay
@@ -63,11 +83,11 @@ class MrpBom(models.Model):
63
83
  i += 1
64
84
  elif line.product_id.bom_ids:
65
85
  # If the a component is manufactured we continue exploding.
66
- location = line.location_id
86
+ location = line.context_location_id
67
87
  line_boms = line.product_id.bom_ids
68
88
  bom = line_boms.filtered(
69
- lambda bom: bom.location_id == location
70
- ) or line_boms.filtered(lambda bom: not bom.location_id)
89
+ lambda bom: bom.context_location_id == location
90
+ ) or line_boms.filtered(lambda bom: not bom.context_location_id)
71
91
  if bom:
72
92
  paths[i] += bom[0]._get_produce_delay()
73
93
  paths[i] += bom[0]._get_longest_path()
@@ -97,10 +117,21 @@ class MrpBom(models.Model):
97
117
  dlt += self._get_longest_path()
98
118
  return dlt
99
119
 
120
+ @api.depends("context_location_id")
121
+ @api.depends_context("location_id")
100
122
  def _compute_dlt(self):
101
123
  for rec in self:
102
124
  rec.dlt = rec._get_manufactured_dlt()
103
125
 
126
+ def action_change_context_location(self):
127
+ return {
128
+ "type": "ir.actions.act_window",
129
+ "name": _("Change MRP BoM Location"),
130
+ "res_model": "mrp.bom.change.location",
131
+ "view_mode": "form",
132
+ "target": "new",
133
+ }
134
+
104
135
 
105
136
  class MrpBomLine(models.Model):
106
137
  _inherit = "mrp.bom.line"
@@ -116,16 +147,25 @@ class MrpBomLine(models.Model):
116
147
  compute="_compute_is_buffered",
117
148
  )
118
149
  dlt = fields.Float(string="Decoupled Lead Time (days)", compute="_compute_dlt",)
150
+ context_location_id = fields.Many2one(related="bom_id.context_location_id")
151
+ # This is a legacy field that can be removed in v17
152
+ location_id = fields.Many2one(related="context_location_id")
119
153
 
120
154
  def _get_search_buffer_domain(self):
121
- product = self.product_id or self.product_tmpl_id.product_variant_ids[0]
122
- domain = [("product_id", "=", product.id)]
123
- if self.location_id:
124
- domain.append(("location_id", "=", self.location_id.id))
155
+ product = self.product_id
156
+ if not product:
157
+ if self.product_tmpl_id.product_variant_ids:
158
+ product = self.product_tmpl_id.product_variant_ids[0]
159
+ domain = [
160
+ ("product_id", "=", product.id),
161
+ ("location_id", "=", self.context_location_id.id),
162
+ ]
125
163
  if self.company_id:
126
164
  domain.append(("company_id", "=", self.company_id.id))
127
165
  return domain
128
166
 
167
+ @api.depends("context_location_id")
168
+ @api.depends_context("location_id")
129
169
  def _compute_is_buffered(self):
130
170
  for line in self:
131
171
  domain = line._get_search_buffer_domain()
@@ -214,6 +214,7 @@ class StockBuffer(models.Model):
214
214
  action = self.product_id.action_view_bom()
215
215
  boms = self._get_manufactured_bom(limit=100)
216
216
  action["domain"] = [("id", "in", boms.ids)]
217
+ action["context"] = {"location_id": self.location_id.id}
217
218
  return action
218
219
 
219
220
  @api.constrains("product_id")
@@ -909,18 +910,12 @@ class StockBuffer(models.Model):
909
910
  rec.order_spike_threshold = 0.5 * rec.red_zone_qty
910
911
 
911
912
  def _get_manufactured_bom(self, limit=1):
912
- locations = self.env["stock.location"].search(
913
- [("id", "child_of", [self.location_id.id])]
914
- )
915
913
  return self.env["mrp.bom"].search(
916
914
  [
917
915
  "|",
918
916
  ("product_id", "=", self.product_id.id),
919
917
  ("product_tmpl_id", "=", self.product_id.product_tmpl_id.id),
920
918
  "|",
921
- ("location_id", "in", locations.ids),
922
- ("location_id", "=", False),
923
- "|",
924
919
  ("company_id", "=", self.company_id.id),
925
920
  ("company_id", "=", False),
926
921
  ],
@@ -932,7 +927,7 @@ class StockBuffer(models.Model):
932
927
  for rec in self:
933
928
  if rec.buffer_profile_id.item_type == "manufactured":
934
929
  bom = rec._get_manufactured_bom()
935
- dlt = bom.dlt
930
+ dlt = bom.with_context(location_id=rec.location_id.id).dlt
936
931
  elif rec.buffer_profile_id.item_type == "distributed":
937
932
  dlt = rec.lead_days
938
933
  else:
@@ -1,9 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
2
  <odoo>
3
- <template
4
- id="report_mrpbomstructure_ddmrp"
5
- inherit_id="mrp_bom_location.report_mrpbomstructure_location"
6
- >
3
+ <template id="report_mrpbomstructure_ddmrp" inherit_id="mrp.report_mrp_bom">
7
4
  <xpath expr="//thead/tr/th[last()]" position="before">
8
5
  <th
9
6
  t-if="data['report_structure'] != 'bom_cost'"
@@ -49,10 +46,7 @@
49
46
  </td>
50
47
  </xpath>
51
48
  </template>
52
- <template
53
- id="report_mrp_bom_line"
54
- inherit_id="mrp_bom_location.report_mrp_bom_line"
55
- >
49
+ <template id="report_mrp_bom_line" inherit_id="mrp.report_mrp_bom_line">
56
50
  <xpath expr="//tr/td[last()]" position="before">
57
51
  <td class="o_mrp_prod_cost text-right">
58
52
  <span>
@@ -87,10 +81,7 @@
87
81
  </span>
88
82
  </xpath>
89
83
  </template>
90
- <template
91
- id="report_mrp_bom_pdf_line"
92
- inherit_id="mrp_bom_location.report_mrp_bom_pdf_line"
93
- >
84
+ <template id="report_mrp_bom_pdf_line" inherit_id="mrp.report_mrp_bom_pdf_line">
94
85
  <xpath expr="//tr" position="inside">
95
86
  <t t-if="l['type'] == 'bom'">
96
87
  <td
@@ -366,7 +366,7 @@ ul.auto-toc {
366
366
  !! This file is generated by oca-gen-addon-readme !!
367
367
  !! changes will be overwritten. !!
368
368
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369
- !! source digest: sha256:e8a6bb884c9e9b8864274a2d16d3aee2ee8dc35a6344180d071b47f3452af4f9
369
+ !! source digest: sha256:ba1e695dc9b1c5a409deb206d547983f609bf5f85f0441d448f75816ebdbb303
370
370
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
371
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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/ddmrp/tree/13.0/ddmrp"><img alt="OCA/ddmrp" src="https://img.shields.io/badge/github-OCA%2Fddmrp-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/ddmrp-13-0/ddmrp-13-0-ddmrp"><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/ddmrp&amp;target_branch=13.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372
372
  <p>Demand Driven Material Requirements Planning is a formal multi-echelon
@@ -0,0 +1,33 @@
1
+ odoo.define("ddmrp.mrp_bom_report", function(require) {
2
+ "use strict";
3
+
4
+ var core = require("web.core");
5
+ var MrpBomReport = require("mrp.mrp_bom_report");
6
+
7
+ var DdmrpBomReport = MrpBomReport.extend({
8
+ init: function(parent, action) {
9
+ this._super.apply(this, arguments);
10
+ this.given_context.location_id = action.context.location_id || false;
11
+ },
12
+ get_bom: function(event) {
13
+ var self = this;
14
+ var $parent = $(event.currentTarget).closest("tr");
15
+ var activeID = $parent.data("id");
16
+ var productID = $parent.data("product_id");
17
+ var lineID = $parent.data("line");
18
+ var qty = $parent.data("qty");
19
+ var level = $parent.data("level") || 0;
20
+ return this._rpc({
21
+ model: "report.mrp.report_bom_structure",
22
+ method: "get_bom",
23
+ args: [activeID, productID, parseFloat(qty), lineID, level + 1],
24
+ context: this.given_context,
25
+ }).then(function(result) {
26
+ self.render_html(event, $parent, result);
27
+ });
28
+ },
29
+ });
30
+
31
+ core.action_registry.add("mrp_bom_report", DdmrpBomReport);
32
+ return DdmrpBomReport;
33
+ });
@@ -432,7 +432,6 @@ class TestDdmrp(TestDdmrpCommon):
432
432
  def _check_red_zone(
433
433
  self, orderpoint, red_base_qty=0.0, red_safety_qty=0.0, red_zone_qty=0.0
434
434
  ):
435
-
436
435
  # red base_qty = dlt * adu * lead time factor
437
436
  self.assertEqual(orderpoint.red_base_qty, red_base_qty)
438
437
 
@@ -443,7 +442,6 @@ class TestDdmrp(TestDdmrpCommon):
443
442
  self.assertEqual(orderpoint.red_zone_qty, red_zone_qty)
444
443
 
445
444
  def _check_yellow_zone(self, orderpoint, yellow_zone_qty=0.0, top_of_yellow=0.0):
446
-
447
445
  # yellow_zone_qty = dlt * adu
448
446
  self.assertEqual(orderpoint.yellow_zone_qty, yellow_zone_qty)
449
447
 
@@ -459,7 +457,6 @@ class TestDdmrp(TestDdmrpCommon):
459
457
  green_zone_qty=0.0,
460
458
  top_of_green=0.0,
461
459
  ):
462
-
463
460
  # green_zone_oc = order_cycle * adu
464
461
  self.assertEqual(orderpoint.green_zone_oc, green_zone_oc)
465
462
 
@@ -849,7 +846,7 @@ class TestDdmrp(TestDdmrpCommon):
849
846
  "adu_calculation_method": self.adu_fixed.id,
850
847
  }
851
848
  )
852
- self.bom_a.location_id = self.supplier_location.id
849
+ self.bom_a.context_location_id = self.supplier_location.id
853
850
  self.assertTrue(self.bom_a.is_buffered)
854
851
  self.assertEqual(self.bom_a.buffer_id, new_buffer)
855
852
  new_bom = self.env["mrp.bom"].create(
@@ -962,13 +959,16 @@ class TestDdmrp(TestDdmrpCommon):
962
959
  self.assertTrue(bom_line)
963
960
  self.assertFalse(bom_line.is_buffered)
964
961
  # Add a buffer for a component but in a different company
962
+ warehouse2 = self.env["stock.warehouse"].search(
963
+ [("company_id", "=", self.second_company.id)], limit=1
964
+ )
965
965
  component_buffer = self.bufferModel.create(
966
966
  {
967
967
  "buffer_profile_id": self.buffer_profile_pur.id,
968
968
  "product_id": self.component_a1.id,
969
969
  "company_id": self.second_company.id,
970
- "warehouse_id": self.warehouse_sc.id,
971
- "location_id": self.stock_location_sc.id,
970
+ "warehouse_id": warehouse2.id,
971
+ "location_id": warehouse2.lot_stock_id.id,
972
972
  "adu_calculation_method": self.adu_fixed.id,
973
973
  }
974
974
  )
@@ -985,6 +985,54 @@ class TestDdmrp(TestDdmrpCommon):
985
985
  self.assertTrue(bom_line.is_buffered)
986
986
  self.assertEqual(bom_line.buffer_id, component_buffer)
987
987
 
988
+ def test_38_bom_dlt_computation_multi_location(self):
989
+ """
990
+ If AS01 bom has no location it means that it can be manufactured
991
+ in more than one location.
992
+ """
993
+ bom_fp01 = self.env.ref("ddmrp.mrp_bom_fp01")
994
+ buffer1_fp01 = self.env.ref("ddmrp.stock_buffer_fp01")
995
+ self.assertEqual(bom_fp01.dlt, 22.0)
996
+ self.assertEqual(bom_fp01.buffer_id, buffer1_fp01)
997
+ self.assertEqual(len(bom_fp01.bom_line_ids), 1)
998
+ self.assertEqual(bom_fp01.bom_line_ids.is_buffered, False)
999
+ # Now create buffers in another location and check in that context
1000
+ product_fp01 = self.env.ref("ddmrp.product_product_fp01")
1001
+ product_as01 = self.env.ref("ddmrp.product_product_as01")
1002
+ buffer2_fp01 = self.bufferModel.create(
1003
+ {
1004
+ "buffer_profile_id": self.buffer_profile_mmm.id,
1005
+ "product_id": product_fp01.id,
1006
+ "warehouse_id": self.warehouse.id,
1007
+ "location_id": self.supplier_location.id,
1008
+ "adu_calculation_method": self.adu_fixed.id,
1009
+ }
1010
+ )
1011
+ buffer_as01 = self.bufferModel.create(
1012
+ {
1013
+ "buffer_profile_id": self.buffer_profile_mmm.id,
1014
+ "product_id": product_as01.id,
1015
+ "warehouse_id": self.warehouse.id,
1016
+ "location_id": self.supplier_location.id,
1017
+ "adu_calculation_method": self.adu_fixed.id,
1018
+ }
1019
+ )
1020
+ bom_fp01.context_location_id = self.supplier_location.id
1021
+ bom_fp01.bom_line_ids._compute_is_buffered()
1022
+ bom_fp01._compute_dlt()
1023
+ bom_fp01.bom_line_ids._compute_dlt()
1024
+ self.assertEqual(bom_fp01.dlt, 2.0)
1025
+ self.assertEqual(bom_fp01.buffer_id, buffer2_fp01)
1026
+ self.assertEqual(len(bom_fp01.bom_line_ids), 1)
1027
+ self.assertEqual(bom_fp01.bom_line_ids.is_buffered, True)
1028
+ self.assertEqual(bom_fp01.bom_line_ids.buffer_id, buffer_as01)
1029
+ # Check at the same time the DLT of 2 buffers using the same bom:
1030
+ buffers = buffer1_fp01 + buffer2_fp01
1031
+ buffers.invalidate_cache()
1032
+ buffers._compute_dlt()
1033
+ self.assertEqual(buffer1_fp01.dlt, 22)
1034
+ self.assertEqual(buffer2_fp01.dlt, 2)
1035
+
988
1036
  def test_40_bokeh_charts(self):
989
1037
  """Check bokeh chart computation."""
990
1038
  date_move = datetime.today()
@@ -10,6 +10,10 @@
10
10
  type="text/javascript"
11
11
  src="/ddmrp/static/src/js/list_renderer_buffer_info.js"
12
12
  />
13
+ <script
14
+ type="text/javascript"
15
+ src="/ddmrp/static/src/js/mrp_bom_report.js"
16
+ />
13
17
  <link
14
18
  rel="stylesheet"
15
19
  type="text/scss"
@@ -7,10 +7,20 @@
7
7
  <field name="model">mrp.bom</field>
8
8
  <field name="inherit_id" ref="mrp.mrp_bom_form_view" />
9
9
  <field name="arch" type="xml">
10
- <field name="routing_id" position="before">
10
+ <field name="product_id" position="after">
11
11
  <field name="is_buffered" />
12
12
  <field name="buffer_id" />
13
- <field name="dlt" />
13
+ <label for="dlt" />
14
+ <div class="o_row">
15
+ <field name="dlt" />
16
+ (<field name="context_location_id" options="{'no_open': True}" />)
17
+ <button
18
+ title="Change Location"
19
+ name="action_change_context_location"
20
+ icon="fa-exchange"
21
+ type="object"
22
+ />
23
+ </div>
14
24
  </field>
15
25
  <xpath
16
26
  expr="//field[@name='bom_line_ids']/tree/field[@name='product_uom_id']"
@@ -19,6 +29,7 @@
19
29
  <field name="is_buffered" />
20
30
  <field name="buffer_id" />
21
31
  <field name="dlt" />
32
+ <field name="context_location_id" />
22
33
  </xpath>
23
34
  </field>
24
35
  </record>