Skip to content

Commit

Permalink
Merge pull request #29 from Tecnativa/15.0-imp-tms_sale_quick_input
Browse files Browse the repository at this point in the history
[15.0][IMP] tms_sale_quick_input: Changes to Fast Order Entry
  • Loading branch information
sergio-teruel authored Jun 14, 2024
2 parents 1fb9584 + 6b64aa2 commit da221a5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tms_sale_quick_input/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class SaleOrderLine(models.Model):
compute="_compute_shipping_volume",
inverse="_inverse_shipping_volume",
)
shipping_lineal_length = fields.Float(
digits="TMS Lineal Length",
string="Lineal Length for Shipping",
compute="_compute_shipping_lineal_length",
inverse="_inverse_shipping_lineal_length",
groups="tms.group_tms_lineal_length",
)
shipping_weight = fields.Float(
digits="TMS Weight",
string="Weight for Shipping",
Expand Down Expand Up @@ -158,6 +165,13 @@ def _compute_shipping_volume(self):
def _inverse_shipping_volume(self):
self.set_field_to_packages("shipping_volume")

@api.depends("tms_package_ids.shipping_lineal_length")
def _compute_shipping_lineal_length(self):
self.get_field_from_packages_numeric("shipping_lineal_length")

def _inverse_shipping_lineal_length(self):
self.set_field_to_packages("shipping_lineal_length")

@api.depends("tms_package_ids.shipping_weight")
def _compute_shipping_weight(self):
self.get_field_from_packages_numeric("shipping_weight")
Expand Down Expand Up @@ -255,6 +269,7 @@ def _update_package(self):
"name": "/",
"partner_id": self.order_partner_id.id,
"pickup_date": self.pickup_date,
"forecast_unload_date": self.forecast_unload_date,
}
)
packages = packages.create(vals)
Expand Down
4 changes: 4 additions & 0 deletions tms_sale_quick_input/tests/test_tms_sale_quick_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def setUpClass(cls):
"shipping_origin_id": cls.shipping_origin.id,
"shipping_destination_id": cls.shipping_destination.id,
"shipping_volume": 10,
"shipping_lineal_length": 30,
"shipping_weight": 20,
"number_of_packages": 2,
"pallet_qty": 1,
Expand All @@ -44,6 +45,7 @@ def test_01_computes_work(self):
sale_order_line = sale_order_line_form.save()
self.assertEqual(sale_order_line.shipping_place_id, self.shipping_origin)
self.assertEqual(sale_order_line.shipping_volume, 10)
self.assertEqual(sale_order_line.shipping_lineal_length, 30)
self.assertEqual(sale_order_line.shipping_weight, 20)
self.assertEqual(sale_order_line.number_of_packages, 2)
self.assertEqual(sale_order_line.pallet_qty, 1)
Expand All @@ -61,6 +63,7 @@ def _test_02_inverse_work(self):
sale_order_line_form.tms_package_ids.add(package_2)
sale_order_line_form.shipping_place_id = self.shipping_origin
sale_order_line_form.shipping_volume = 90
sale_order_line_form.shipping_lineal_length = 100
sale_order_line_form.shipping_weight = 150
sale_order_line_form.number_of_packages = 30
sale_order_line_form.pallet_qty = 2
Expand All @@ -73,6 +76,7 @@ def _test_02_inverse_work(self):
sale_order_line.shipping_destination_id, self.shipping_destination
)
self.assertEqual(package_2.shipping_volume, 90)
self.assertEqual(package_2.shipping_lineal_length, 100)
self.assertEqual(package_2.shipping_weight, 150)
self.assertEqual(package_2.number_of_packages, 30)
self.assertEqual(package_2.pallet_qty, 2)
Expand Down
19 changes: 18 additions & 1 deletion tms_sale_quick_input/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
optional="hide"
attrs="{'readonly': [('editable_package_rel', '=', False)]}"
/>
<field
name="shipping_lineal_length"
optional="hide"
attrs="{'readonly': [('editable_package_rel', '=', False)]}"
/>
<field
name="number_of_packages"
optional="hide"
Expand Down Expand Up @@ -67,6 +72,7 @@
<field name="price_total" position="after">
<field name="editable_package_rel" invisible="1" />
<field name="pickup_date" optional="show" />
<field name="forecast_unload_date" optional="show" />
<field name="release_id" optional="show" />
<field name="acceptance_id" optional="show" />
<field name="unload_service" optional="show" />
Expand All @@ -86,7 +92,8 @@
context="{'default_partner_id': order_partner_id,
'default_shipping_origin_id': shipping_origin_id,
'default_shipping_destination_id': shipping_destination_id,
'default_pickup_date': pickup_date}"
'default_pickup_date': pickup_date,
'default_forecast_unload_date': forecast_unload_date}"
optional="show"
/>
<button name="action_tms_package_form" type="object" icon="fa-dropbox" />
Expand All @@ -100,6 +107,11 @@
optional="hide"
attrs="{'readonly': [('editable_package_rel', '=', False)]}"
/>
<field
name="shipping_lineal_length"
optional="hide"
attrs="{'readonly': [('editable_package_rel', '=', False)]}"
/>
<field
name="number_of_packages"
optional="hide"
Expand Down Expand Up @@ -154,6 +166,11 @@
<field name="sale_type_id" />
<separator />
<filter string="Pickup date" name="filter_pickup_date" date="pickup_date" />
<filter
name="from_today"
string="From today"
domain="[('pickup_date', '>=', (datetime.datetime.combine(context_today(), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S'))]"
/>
<separator />
<filter
name="not_invoiced"
Expand Down

0 comments on commit da221a5

Please sign in to comment.