Skip to content

Commit

Permalink
--amend
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Nov 28, 2023
1 parent cd09aea commit 54bfb0c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions joint_buying_base/models/joint_buying_transport_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class JointBuyingTransportRequest(models.Model):

total_weight = fields.Float(
string="Weight",
compute="_compute_weight",
compute="_compute_total_weight",
store=True,
digits=dp.get_precision("Stock Weight"),
compute_sudo=True,
Expand Down Expand Up @@ -174,7 +174,7 @@ def _compute_amount_untaxed(self):
request.amount_untaxed = request.manual_amount_untaxed

@api.depends(lambda x: x._get_depends_total_weight())
def _compute_weight(self):
def _compute_total_weight(self):
for request in self:
request.total_weight = request.manual_total_weight

Expand Down
4 changes: 2 additions & 2 deletions joint_buying_product/models/joint_buying_transport_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def _compute_amount_untaxed(self):
for request in self.filtered(lambda x: x.order_id):
request.amount_untaxed = request.order_id.amount_untaxed

def _compute_weight(self):
def _compute_total_weight(self):
super(
JointBuyingTransportRequest, self.filtered(lambda x: not x.order_id)
)._compute_weight()
)._compute_total_weight()

for request in self.filtered(lambda x: x.order_id):
request.total_weight = request.order_id.total_weight
Expand Down
1 change: 1 addition & 0 deletions joint_buying_sale/demo/sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="product_uom_qty">3</field>
<field name="product_uom" ref="uom.product_uom_unit"/>
<field name="price_unit">15.00</field>
<field name="unit_weight">0.210</field>
</record>

<record id="sale_order_1_line_2" model="sale.order.line">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ def test_create_transport_request_sale(self):
self.assertIn("(3", first_description)
self.assertNotIn("(2222", first_description)

self.assertEqual(first_amount_untaxed, sale_order.amount_untaxed)
self.assertAlmostEqual(first_amount_untaxed, sale_order.amount_untaxed)

# self.assertEqual(first_total_weight, sale_order.xxx)
self.assertAlmostEqual(first_total_weight, sale_order.total_ordered_weight)

# Change value of order line qty and check recomputation
sale_order_line.product_uom_qty = 2222

self.assertNotEqual(first_amount_untaxed, request.description)
self.assertNotIn("(3", request.description)
self.assertIn("(2222", request.description)
self.assertNotEqual(first_amount_untaxed, request.description)

self.assertAlmostEqual(request.amount_untaxed, sale_order.amount_untaxed)
self.assertNotEqual(first_amount_untaxed, request.amount_untaxed)
self.assertEqual(request.amount_untaxed, sale_order.amount_untaxed)

first_total_weight = first_total_weight
# self.assertNotEqual(first_total_weight, request.total_weight)
# self.assertEqual(request.total_weight, sale_order.total_weight)
self.assertAlmostEqual(request.total_weight, sale_order.total_ordered_weight)
self.assertNotEqual(first_total_weight, request.total_weight)

0 comments on commit 54bfb0c

Please sign in to comment.