-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REF] sale_order_volume: Many post-migration improvements
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
- Loading branch information
1 parent
6cd4235
commit aeea8f8
Showing
5 changed files
with
48 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from . import product_category_volume | ||
from . import res_config_settings | ||
from . import sale_order_line | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# © 2016 Robin Keunen, Coop IT Easy SCRL. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductCategoryVolume(models.Model): | ||
_name = "product.category.volume" | ||
_description = "Product Volume by Category" | ||
|
||
sale_order_id = fields.Many2one(comodel_name="sale.order", string="Sale Order") | ||
category_id = fields.Many2one( | ||
comodel_name="product.category", string="Product Category" | ||
) | ||
volume = fields.Float(string="Volume (m³)") | ||
pallet_count = fields.Integer(string="# Pallets") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
volume = fields.Float(compute="_compute_volume", store=True) | ||
|
||
@api.depends("product_id.volume", "product_uom_qty") | ||
def _compute_volume(self): | ||
for line in self: | ||
line.volume = line.product_id.volume * line.product_uom_qty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,10 @@ | |
# Robin Keunen <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
import unittest | ||
|
||
from odoo.tests import TransactionCase | ||
|
||
|
||
class SaleOrderVolumeCase(TransactionCase): | ||
@unittest.expectedFailure | ||
def test_sale_order_volumes(self): | ||
sale_order = self.browse_ref("sale.sale_order_4") | ||
product = self.browse_ref("product.product_delivery_01") | ||
|
@@ -28,7 +25,7 @@ def test_sale_order_volumes(self): | |
) | ||
|
||
self.assertEqual(service_volume.volume, 0) | ||
self.assertEqual(service_volume.pallet_count, 1) | ||
self.assertEqual(service_volume.pallet_count, 0) | ||
self.assertEqual(office_furniture_volume.volume, 15.6) | ||
# (15.6 (volume) // 1.75 (pallet volume)) + 1 = 9 | ||
self.assertEqual(office_furniture_volume.pallet_count, 9) |