mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2025-02-25 18:55:21 -06:00
[PATCH] Upstream patch - 12042023
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<field name="inherit_id" ref="base.view_model_fields_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="copied" position="after">
|
||||
<field name="tracking" attrs="{'readonly': [('state','!=', 'manual')]}"/>
|
||||
<field name="tracking" attrs="{'invisible': [('ttype', '=', 'binary')], 'readonly': [('state','!=', 'manual')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="priority" eval="2"/>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Calendar View" date_start="scheduled_date" color="partner_id" event_limit="5">
|
||||
<calendar string="Calendar View" date_start="scheduled_date" color="partner_id" event_limit="5" quick_add="False">
|
||||
<field name="partner_id" filters="1"/>
|
||||
<field name="origin"/>
|
||||
<field name="picking_type_id"/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user