Browse Source

Feb 27 [UPDT] : Updated 'so_bom_selection'

pull/358/merge
AjmalCybro 2 months ago
parent
commit
be06f2bb30
  1. 2
      so_bom_selection/__manifest__.py
  2. 5
      so_bom_selection/doc/RELEASE_NOTES.md
  3. 60
      so_bom_selection/models/sale_order.py
  4. BIN
      so_bom_selection/static/description/assets/screenshots/1.png
  5. BIN
      so_bom_selection/static/description/assets/screenshots/2.png
  6. BIN
      so_bom_selection/static/description/assets/screenshots/3.png
  7. BIN
      so_bom_selection/static/description/assets/screenshots/4.png
  8. BIN
      so_bom_selection/static/description/assets/screenshots/5.png
  9. BIN
      so_bom_selection/static/description/assets/screenshots/6.png
  10. 3
      so_bom_selection/static/description/index.html

2
so_bom_selection/__manifest__.py

@ -21,7 +21,7 @@
################################################################################
{
'name': "Bill Of Material from Sale Order Line",
'version': '18.0.1.0.0',
'version': '18.0.1.0.1',
'category': 'Manufacturing',
'summary': 'Select the BOM in sale order line and generate the '
'manufacturing order of components',

5
so_bom_selection/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 18.0.1.0.0
#### ADD
- Initial commit for Bill Of Material from Sale Order Line
#### 20.02.2025
#### Version 18.0.1.0.1
#### UPT
- Update in the Confirm button action and Write function for Bill Of Material from Sale Order Line to fix the issue of creating two MOs

60
so_bom_selection/models/sale_order.py

@ -29,35 +29,45 @@ class SaleOrder(models.Model):
def action_confirm(self):
""" Create manufacturing order of components in selected BOM """
for rec in self.order_line:
if rec.bom_id and rec.bom_id.type != 'phantom' and rec.bom_id.type != 'subcontract':
mo = self.env["mrp.production"].create(
{
"product_id": rec.product_id.id,
"product_uom_id": rec.product_id.uom_id.id,
"origin": self.name,
'company_id': self.env.user.company_id.id,
"product_qty": rec.product_uom_qty,
"qty_to_produce": rec.product_uom_qty,
"bom_id": rec.bom_id.id,
"sale_line_id": rec.id,
}
)
moves_raw_values = mo._get_moves_raw_values()
list_move_raw = []
for move_raw_values in moves_raw_values:
list_move_raw += [(0, 0, move_raw_values)]
return super().action_confirm()
if rec.bom_id and rec.bom_id in rec.product_template_id.bom_ids:
# Store the original sequence order
original_sequences = {bom.id: bom.sequence for bom in rec.product_template_id.bom_ids}
# Set the selected BOM's sequence to 0
rec.bom_id.sequence = 0
# Get all other BOMs and update their sequence accordingly
other_boms = rec.product_template_id.bom_ids - rec.bom_id
sequence_counter = 1 # Start sequence from 1 for others
for bom in other_boms.sorted('sequence'):
bom.sequence = sequence_counter
sequence_counter += 1
result = super().action_confirm()
# Restore original sequences after the confirmation
for rec in self.order_line:
if rec.bom_id and rec.bom_id in rec.product_template_id.bom_ids:
for bom in rec.product_template_id.bom_ids:
if bom.id in original_sequences:
bom.sequence = original_sequences[bom.id]
manufacturing_order = self.env["mrp.production"].search(
[('origin', '=', self.name),
('state', '=', 'confirmed')])
if manufacturing_order:
for mo in manufacturing_order:
print(mo.product_qty)
mo.update({'qty_to_produce': mo.product_qty})
# mo.update({'state':'draft'})
return result
def write(self, values):
"""Super write method to change the manufacturing quantity
"""Super write method to change the qty_to_produce in the MO
based on sale order quantity"""
res = super().write(values)
for order_line in self.order_line:
if order_line.product_uom_qty:
mo = self.env["mrp.production"].search(
[('sale_line_id', '=', order_line.id),
('state', '=', 'draft')])
if mo:
mo.write({'product_qty': order_line.product_uom_qty})
mo.write({'qty_to_produce': order_line.product_uom_qty})
manufacturing_order = self.env["mrp.production"].search(
[('origin', '=', self.name),
('state', '=', 'confirmed')])
if manufacturing_order:
for mo in manufacturing_order:
mo.write({'qty_to_produce': mo.product_qty})
return res

BIN
so_bom_selection/static/description/assets/screenshots/1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 94 KiB

BIN
so_bom_selection/static/description/assets/screenshots/2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 136 KiB

BIN
so_bom_selection/static/description/assets/screenshots/3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 136 KiB

BIN
so_bom_selection/static/description/assets/screenshots/4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 131 KiB

BIN
so_bom_selection/static/description/assets/screenshots/5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 130 KiB

BIN
so_bom_selection/static/description/assets/screenshots/6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 134 KiB

3
so_bom_selection/static/description/index.html

@ -462,7 +462,8 @@
<div class="p-md-5 p-3 position-relative">
<div class="row">
<div class="col-md-12">
<h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size: 40px;
<h1 style="
font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size: 40px;
font-weight: 700;">
<span style="color:#121212; font-size:calc(1.1rem + 1vw)"> Manufacturing Order created for components with source as corresponding Sale Order
</span>

Loading…
Cancel
Save