Skip to content

Commit

Permalink
[16.0][IMP] delivery_carrier_manual_weight: allow to set `is_manual_w…
Browse files Browse the repository at this point in the history
…eight` on picking
  • Loading branch information
FrancescoBallerini committed Dec 1, 2024
1 parent fc20867 commit 1df0483
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions delivery_carrier_manual_weight/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
class StockPicking(models.Model):
_inherit = "stock.picking"

is_manual_weight = fields.Boolean(related="carrier_id.is_manual_weight")
is_manual_weight = fields.Boolean(
string="Manual Weights",
compute="_compute_is_manual_weight",
store=True,
readonly=False,
)
weight_manual = fields.Float(string="Weight (Manual)", digits="Stock Weight")
shipping_weight_manual = fields.Float(string="Weight for Shipping (Manual)")

@api.depends("move_ids", "carrier_id", "weight_manual")
@api.depends("carrier_id")
def _compute_is_manual_weight(self):
for rec in self:
rec.is_manual_weight = rec.carrier_id.is_manual_weight

@api.depends("move_ids", "carrier_id", "weight_manual", "is_manual_weight")
def _cal_weight(self):
manual_weight = self.filtered(lambda p: p.carrier_id.is_manual_weight)
manual_weight = self.filtered(lambda p: p.is_manual_weight)
for rec in manual_weight:
rec.weight = rec.weight_manual
return super(StockPicking, self - manual_weight)._cal_weight()
Expand All @@ -24,9 +34,10 @@ def _cal_weight(self):
"weight_bulk",
"carrier_id",
"shipping_weight_manual",
"is_manual_weight",
)
def _compute_shipping_weight(self):
manual_weight = self.filtered(lambda p: p.carrier_id.is_manual_weight)
manual_weight = self.filtered(lambda p: p.is_manual_weight)
for rec in manual_weight:
rec.shipping_weight = rec.shipping_weight_manual
return super(StockPicking, self - manual_weight)._compute_shipping_weight()
2 changes: 1 addition & 1 deletion delivery_carrier_manual_weight/views/delivery_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form" />
<field name="arch" type="xml">
<label for="weight" position="before">
<field name="is_manual_weight" invisible="1" />
<field name="is_manual_weight" />
<label
for="weight_manual"
attrs="{'invisible': [('is_manual_weight', '=', False)]}"
Expand Down

0 comments on commit 1df0483

Please sign in to comment.