-
-
Notifications
You must be signed in to change notification settings - Fork 363
Expand file tree
/
Copy pathstock_lot.py
More file actions
30 lines (25 loc) · 933 Bytes
/
stock_lot.py
File metadata and controls
30 lines (25 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Kévin Roche <kevin.roche@akretion.com>
# @author Guillaume MASSON <guillaume.masson@groupevoltaire.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
class StockLot(models.Model):
_inherit = "stock.lot"
def prepare_intercompany_lot_values(self, company):
return {
"name": self.name,
"product_id": self.product_id.id,
"company_id": company.id,
}
def get_inter_company_lot(self, company):
self.ensure_one()
lot = self.sudo().search(
[
("name", "=", self.name),
("product_id", "=", self.product_id.id),
("company_id", "=", company.id),
]
)
if not lot:
lot = self.sudo().create(self.prepare_intercompany_lot_values(company))
return lot