From 5c2fa974258b999e419a3ef211676560ab1c8442 Mon Sep 17 00:00:00 2001 From: Parthiv Patel Date: Wed, 12 Apr 2023 08:34:29 +0000 Subject: [PATCH] [PATCH] Upstream patch - 12042023 --- addons/delivery/models/sale_order.py | 2 +- addons/delivery/tests/test_delivery_cost.py | 27 +++++++++++++++++-- addons/gamification/models/res_users.py | 2 +- .../tests/test_employee_deletion.py | 2 +- addons/mail/views/ir_model_views.xml | 2 +- addons/sms/tests/test_sms_template.py | 2 +- addons/stock/views/stock_picking_views.xml | 2 +- addons/survey/tests/test_survey_security.py | 2 +- addons/web_unsplash/controllers/main.py | 2 +- 9 files changed, 33 insertions(+), 10 deletions(-) diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 9eba239fed..c2491beee9 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -154,7 +154,7 @@ class SaleOrder(models.Model): def _get_estimated_weight(self): self.ensure_one() weight = 0.0 - for order_line in self.order_line.filtered(lambda l: l.product_id.type in ['product', 'consu'] and not l.is_delivery and not l.display_type): + for order_line in self.order_line.filtered(lambda l: l.product_id.type in ['product', 'consu'] and not l.is_delivery and not l.display_type and l.product_uom_qty > 0): weight += order_line.product_qty * order_line.product_id.weight return weight diff --git a/addons/delivery/tests/test_delivery_cost.py b/addons/delivery/tests/test_delivery_cost.py index 6e2e621016..3efb5db43e 100644 --- a/addons/delivery/tests/test_delivery_cost.py +++ b/addons/delivery/tests/test_delivery_cost.py @@ -17,7 +17,7 @@ class TestDeliveryCost(common.TransactionCase): self.partner_18 = self.env['res.partner'].create({'name': 'My Test Customer'}) self.pricelist = self.env.ref('product.list0') - self.product_4 = self.env['product.product'].create({'name': 'A product to deliver'}) + self.product_4 = self.env['product.product'].create({'name': 'A product to deliver', 'weight': 1.0}) self.product_uom_unit = self.env.ref('uom.product_uom_unit') self.product_delivery_normal = self.env['product.product'].create({ 'name': 'Normal Delivery Charges', @@ -39,7 +39,7 @@ class TestDeliveryCost(common.TransactionCase): self.product_uom_hour = self.env.ref('uom.product_uom_hour') self.account_data = self.env.ref('account.data_account_type_revenue') self.account_tag_operating = self.env.ref('account.account_tag_operating') - self.product_2 = self.env['product.product'].create({'name': 'Zizizaproduct'}) + self.product_2 = self.env['product.product'].create({'name': 'Zizizaproduct', 'weight': 1.0}) self.product_category = self.env.ref('product.product_category_all') self.free_delivery = self.env.ref('delivery.free_delivery_carrier') # as the tests hereunder assume all the prices in USD, we must ensure @@ -327,3 +327,26 @@ class TestDeliveryCost(common.TransactionCase): {'product_id': self.product_2.id, 'is_delivery': False, 'product_uom_qty': 1, 'qty_delivered': 1}, {'product_id': self.normal_delivery.product_id.id, 'is_delivery': True, 'product_uom_qty': 1, 'qty_delivered': 0}, ]) + + def test_estimated_weight(self): + """ + Test that negative qty SO lines are not included in the estimated weight calculation + of delivery carriers (since it's used when calculating their rates). + """ + sale_order = self.SaleOrder.create({ + 'partner_id': self.partner_18.id, + 'name': 'SO - neg qty', + 'order_line': [ + (0, 0, { + 'product_id': self.product_4.id, + 'product_uom_qty': 1, + 'product_uom': self.product_uom_unit.id, + }), + (0, 0, { + 'product_id': self.product_2.id, + 'product_uom_qty': -1, + 'product_uom': self.product_uom_unit.id, + })], + }) + shipping_weight = sale_order._get_estimated_weight() + self.assertEqual(shipping_weight, self.product_4.weight, "Only positive quantity products' weights should be included in estimated weight") diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py index 64dca5b4db..8a4f9ede83 100644 --- a/addons/gamification/models/res_users.py +++ b/addons/gamification/models/res_users.py @@ -7,7 +7,7 @@ from flectra import api, fields, models class Users(models.Model): _inherit = 'res.users' - karma = fields.Integer('Karma', default=0) + karma = fields.Integer('Karma', default=0, copy=False) karma_tracking_ids = fields.One2many('gamification.karma.tracking', 'user_id', string='Karma Changes', groups="base.group_system") badge_ids = fields.One2many('gamification.badge.user', 'user_id', string='Badges', copy=False) gold_badge = fields.Integer('Gold badges count', compute="_get_user_badge_level") diff --git a/addons/hr_org_chart/tests/test_employee_deletion.py b/addons/hr_org_chart/tests/test_employee_deletion.py index becbdf43a0..e4a1330f56 100644 --- a/addons/hr_org_chart/tests/test_employee_deletion.py +++ b/addons/hr_org_chart/tests/test_employee_deletion.py @@ -4,7 +4,7 @@ from flectra.tests import Form, tagged, TransactionCase from flectra.exceptions import MissingError -@tagged('post_install') +@tagged('post_install', '-at_install') class TestEmployeeDeletion(TransactionCase): def test_employee_deletion(self): diff --git a/addons/mail/views/ir_model_views.xml b/addons/mail/views/ir_model_views.xml index 15a0aef0cb..aeedc8b81d 100644 --- a/addons/mail/views/ir_model_views.xml +++ b/addons/mail/views/ir_model_views.xml @@ -33,7 +33,7 @@ - + diff --git a/addons/sms/tests/test_sms_template.py b/addons/sms/tests/test_sms_template.py index 23da265b23..305c51c935 100644 --- a/addons/sms/tests/test_sms_template.py +++ b/addons/sms/tests/test_sms_template.py @@ -8,7 +8,7 @@ from flectra.tests import tagged from flectra.tools import mute_logger -@tagged('post_install') +@tagged('post_install', '-at_install') class TestSmsTemplateAccessRights(SavepointCase): @classmethod diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 689afe33e1..6dca9a5fb3 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -135,7 +135,7 @@ stock.picking - + diff --git a/addons/survey/tests/test_survey_security.py b/addons/survey/tests/test_survey_security.py index 173f231232..50c5eec8ec 100644 --- a/addons/survey/tests/test_survey_security.py +++ b/addons/survey/tests/test_survey_security.py @@ -326,7 +326,7 @@ class TestAccess(common.TestSurveyCommon): (answer_own | answer_other | self.answer_0).unlink() -@tagged('post_install') +@tagged('post_install', '-at_install') class TestSurveySecurityControllers(common.TestSurveyCommon, HttpCase): def test_survey_start_short(self): # avoid name clash with existing data diff --git a/addons/web_unsplash/controllers/main.py b/addons/web_unsplash/controllers/main.py index d9d6e57183..904315c870 100644 --- a/addons/web_unsplash/controllers/main.py +++ b/addons/web_unsplash/controllers/main.py @@ -81,7 +81,7 @@ class Web_Unsplash(http.Controller): for key, value in unsplashurls.items(): url = value.get('url') try: - if not url.startswith('https://images.unsplash.com/'): + if not url.startswith(('https://images.unsplash.com/', 'https://plus.unsplash.com/')): logger.exception("ERROR: Unknown Unsplash URL!: " + url) raise Exception(_("ERROR: Unknown Unsplash URL!")) req = requests.get(url)