Skip to content

Commit

Permalink
[14.0][IMP] custom_p: Add changes in confirm multicompany.
Browse files Browse the repository at this point in the history
  • Loading branch information
Berezi committed Jan 16, 2025
1 parent 2feabf8 commit 0df8366
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_p/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"sale_order_usability",
"sale_order_line_gross_weight",
"custom_breeding_apps",
"custom_descarga",
"sale_order_confirm_multicompany",
],
"data": [
"security/ir.model.access.csv",
Expand Down
27 changes: 27 additions & 0 deletions custom_p/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ class SaleOrder(models.Model):
copy=False,
)

def button_confirm_pickings(self):
if self.auto_purchase_order_id:
for line in self.order_line:
if line.auto_purchase_line_id:
lot = self.env["stock.production.lot"]
if line.lot_id:
lot_name = line.lot_id.name
company = line.sudo().auto_purchase_line_id.company_id
product = line.product_id
lot_domain = [
("name", "=", lot_name),
("company_id", "=", company.id),
("product_id", "=", product.id),
]
lot = lot.sudo().search(lot_domain)
if not lot:
lot = lot.sudo().action_create_lot(
product, lot_name, company
)
line.auto_purchase_line_id.sudo().write(
{
"lot_id": lot.id or False,
"return_qty": line.return_qty,
}
)
return super().button_confirm_pickings()

def button_return_picking(self):
self.update_line_qty = True
return super().button_return_picking()
Expand Down

0 comments on commit 0df8366

Please sign in to comment.