mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_demand_estimate_matrix: black, isort, prettier
This commit is contained in:
@@ -0,0 +1 @@
|
||||
../../../../stock_demand_estimate_matrix
|
||||
6
setup/stock_demand_estimate_matrix/setup.py
Normal file
6
setup/stock_demand_estimate_matrix/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
@@ -8,7 +8,9 @@ class DateRange(models.Model):
|
||||
_inherit = "date.range"
|
||||
|
||||
days = fields.Integer(
|
||||
string="Days between dates", compute="_compute_days", readonly=True,
|
||||
string="Days between dates",
|
||||
compute="_compute_days",
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.depends("date_start", "date_end")
|
||||
|
||||
@@ -12,7 +12,10 @@ class StockDemandEstimate(models.Model):
|
||||
)
|
||||
|
||||
@api.depends(
|
||||
"date_range_id", "manual_duration", "manual_date_from", "manual_date_to",
|
||||
"date_range_id",
|
||||
"manual_duration",
|
||||
"manual_date_from",
|
||||
"manual_date_to",
|
||||
)
|
||||
def _compute_dates(self):
|
||||
date_range_records = self.filtered(lambda r: r.date_range_id)
|
||||
@@ -28,7 +31,9 @@ class StockDemandEstimate(models.Model):
|
||||
res = super(StockDemandEstimate, self - date_range_records).name_get()
|
||||
for rec in date_range_records:
|
||||
name = "{} - {} - {}".format(
|
||||
rec.date_range_id.name, rec.product_id.name, rec.location_id.name,
|
||||
rec.date_range_id.name,
|
||||
rec.product_id.name,
|
||||
rec.location_id.name,
|
||||
)
|
||||
res.append((rec.id, name))
|
||||
return res
|
||||
|
||||
@@ -22,8 +22,16 @@ class TestStockDemandEstimate(SavepointCase):
|
||||
cls.company = cls.env.ref("base.main_company")
|
||||
|
||||
# Create users:
|
||||
cls.manager = cls._create_user("user_1", [cls.g_stock_manager], cls.company,).id
|
||||
cls.user = cls._create_user("user_2", [cls.g_stock_user], cls.company,).id
|
||||
cls.manager = cls._create_user(
|
||||
"user_1",
|
||||
[cls.g_stock_manager],
|
||||
cls.company,
|
||||
).id
|
||||
cls.user = cls._create_user(
|
||||
"user_2",
|
||||
[cls.g_stock_user],
|
||||
cls.company,
|
||||
).id
|
||||
cls.drt_monthly = cls.env["date.range.type"].create(
|
||||
{"name": "Month", "allow_overlap": False}
|
||||
)
|
||||
@@ -84,7 +92,9 @@ class TestStockDemandEstimate(SavepointCase):
|
||||
sheets = self.env["stock.demand.estimate.sheet"].search([])
|
||||
for sheet in sheets:
|
||||
self.assertEqual(
|
||||
len(sheet.line_ids), 12, "There should be 12 lines.",
|
||||
len(sheet.line_ids),
|
||||
12,
|
||||
"There should be 12 lines.",
|
||||
)
|
||||
self.assertEqual(
|
||||
fields.Date.to_string(sheet.date_start),
|
||||
@@ -97,7 +107,9 @@ class TestStockDemandEstimate(SavepointCase):
|
||||
"The date end should be 1943-12-31",
|
||||
)
|
||||
self.assertEqual(
|
||||
sheet.location_id.id, self.location.id, "Wrong location",
|
||||
sheet.location_id.id,
|
||||
self.location.id,
|
||||
"Wrong location",
|
||||
)
|
||||
for line in sheet.line_ids:
|
||||
line.product_uom_qty = 1
|
||||
@@ -119,7 +131,9 @@ class TestStockDemandEstimate(SavepointCase):
|
||||
[("date_range_id", "in", ranges.ids)]
|
||||
)
|
||||
self.assertEqual(
|
||||
len(estimates), 12, "There should be 12 estimate records.",
|
||||
len(estimates),
|
||||
12,
|
||||
"There should be 12 estimate records.",
|
||||
)
|
||||
for estimate in estimates:
|
||||
self.assertEqual(
|
||||
@@ -151,7 +165,9 @@ class TestStockDemandEstimate(SavepointCase):
|
||||
for sheet in sheets:
|
||||
for line in sheet.line_ids:
|
||||
self.assertEqual(
|
||||
line.product_uom_qty, 1, "The quantity should be 1",
|
||||
line.product_uom_qty,
|
||||
1,
|
||||
"The quantity should be 1",
|
||||
)
|
||||
|
||||
def test_02_invalid_dates(self):
|
||||
|
||||
@@ -10,23 +10,38 @@ class StockDemandEstimateSheet(models.TransientModel):
|
||||
_name = "stock.demand.estimate.sheet"
|
||||
_description = "Stock Demand Estimate Sheet"
|
||||
|
||||
date_start = fields.Date(string="Date From", readonly=True,)
|
||||
date_end = fields.Date(string="Date to", readonly=True,)
|
||||
date_start = fields.Date(
|
||||
string="Date From",
|
||||
readonly=True,
|
||||
)
|
||||
date_end = fields.Date(
|
||||
string="Date to",
|
||||
readonly=True,
|
||||
)
|
||||
date_range_type_id = fields.Many2one(
|
||||
string="Date Range Type", comodel_name="date.range.type", readonly=True,
|
||||
string="Date Range Type",
|
||||
comodel_name="date.range.type",
|
||||
readonly=True,
|
||||
)
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location", string="Location", readonly=True,
|
||||
comodel_name="stock.location",
|
||||
string="Location",
|
||||
readonly=True,
|
||||
)
|
||||
line_ids = fields.Many2many(
|
||||
string="Estimates",
|
||||
comodel_name="stock.demand.estimate.sheet.line",
|
||||
relation="stock_demand_estimate_line_rel",
|
||||
)
|
||||
product_ids = fields.Many2many(string="Products", comodel_name="product.product",)
|
||||
product_ids = fields.Many2many(
|
||||
string="Products",
|
||||
comodel_name="product.product",
|
||||
)
|
||||
|
||||
@api.onchange(
|
||||
"date_start", "date_end", "date_range_type_id",
|
||||
"date_start",
|
||||
"date_end",
|
||||
"date_range_type_id",
|
||||
)
|
||||
def _onchange_dates(self):
|
||||
for sheet in self:
|
||||
@@ -166,15 +181,28 @@ class DemandEstimateWizard(models.TransientModel):
|
||||
_name = "stock.demand.estimate.wizard"
|
||||
_description = "Stock Demand Estimate Wizard"
|
||||
|
||||
date_start = fields.Date(string="Date From", required=True,)
|
||||
date_end = fields.Date(string="Date To", required=True,)
|
||||
date_start = fields.Date(
|
||||
string="Date From",
|
||||
required=True,
|
||||
)
|
||||
date_end = fields.Date(
|
||||
string="Date To",
|
||||
required=True,
|
||||
)
|
||||
date_range_type_id = fields.Many2one(
|
||||
string="Date Range Type", comodel_name="date.range.type", required=True,
|
||||
string="Date Range Type",
|
||||
comodel_name="date.range.type",
|
||||
required=True,
|
||||
)
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location", string="Location", required=True,
|
||||
comodel_name="stock.location",
|
||||
string="Location",
|
||||
required=True,
|
||||
)
|
||||
product_ids = fields.Many2many(
|
||||
comodel_name="product.product",
|
||||
string="Products",
|
||||
)
|
||||
product_ids = fields.Many2many(comodel_name="product.product", string="Products",)
|
||||
|
||||
@api.onchange("date_range_type_id")
|
||||
def _onchange_date_range_type_id(self):
|
||||
|
||||
Reference in New Issue
Block a user