Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] delivery_carrier_manual_weight: allow to set is_manual_weight on picking #910

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading