diff --git a/setup/stock_demand_estimate_matrix/odoo/addons/stock_demand_estimate_matrix b/setup/stock_demand_estimate_matrix/odoo/addons/stock_demand_estimate_matrix new file mode 120000 index 000000000..73de46a1c --- /dev/null +++ b/setup/stock_demand_estimate_matrix/odoo/addons/stock_demand_estimate_matrix @@ -0,0 +1 @@ +../../../../stock_demand_estimate_matrix \ No newline at end of file diff --git a/setup/stock_demand_estimate_matrix/setup.py b/setup/stock_demand_estimate_matrix/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_demand_estimate_matrix/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_demand_estimate_matrix/models/date_range.py b/stock_demand_estimate_matrix/models/date_range.py index ed13b490d..96418aa53 100644 --- a/stock_demand_estimate_matrix/models/date_range.py +++ b/stock_demand_estimate_matrix/models/date_range.py @@ -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") diff --git a/stock_demand_estimate_matrix/models/stock_demand_estimate.py b/stock_demand_estimate_matrix/models/stock_demand_estimate.py index 20d2ace9c..c1f3d80b1 100644 --- a/stock_demand_estimate_matrix/models/stock_demand_estimate.py +++ b/stock_demand_estimate_matrix/models/stock_demand_estimate.py @@ -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 diff --git a/stock_demand_estimate_matrix/tests/test_stock_demand_estimate.py b/stock_demand_estimate_matrix/tests/test_stock_demand_estimate.py index 4da8134dc..e33457216 100644 --- a/stock_demand_estimate_matrix/tests/test_stock_demand_estimate.py +++ b/stock_demand_estimate_matrix/tests/test_stock_demand_estimate.py @@ -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): diff --git a/stock_demand_estimate_matrix/wizards/stock_demand_estimate_wizard.py b/stock_demand_estimate_matrix/wizards/stock_demand_estimate_wizard.py index d0fc2b1ff..dee9d79bd 100644 --- a/stock_demand_estimate_matrix/wizards/stock_demand_estimate_wizard.py +++ b/stock_demand_estimate_matrix/wizards/stock_demand_estimate_wizard.py @@ -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):