Skip to content

Commit

Permalink
[UPD] ssi_rma
Browse files Browse the repository at this point in the history
* Menambahkan info num of reception dan num of delivery pd rma mixin
  • Loading branch information
andhit-r committed Nov 26, 2024
1 parent aaaea6e commit 461ae88
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ssi_rma/models/rma_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,26 @@ class RMAMixin(models.AbstractModel):
comodel_name="stock.move",
compute="_compute_stock_document_ids",
store=False,
compute_sudo=True,
)
stock_picking_ids = fields.Many2many(
string="Stock Pickings",
comodel_name="stock.picking",
compute="_compute_stock_document_ids",
store=False,
compute_sudo=True,
)
num_of_reception = fields.Integer(
string="Num. of Reception",
compute="_compute_stock_document_ids",
store=True,
compute_sudo=True,
)
num_of_delivery = fields.Integer(
string="Num. of Delivery",
compute="_compute_stock_document_ids",
store=True,
compute_sudo=True,
)
uom_quantity = fields.Float(
string="UoM Quantity",
Expand Down Expand Up @@ -235,13 +249,26 @@ def _compute_line_edit_ok(self):
@api.depends(
"line_ids",
"line_ids.stock_move_ids",
"line_ids.stock_move_ids.picking_id.state",
)
def _compute_stock_document_ids(self):
for record in self:
num_reception = num_delivery = 0
rma_customer_in = self.env.ref("ssi_rma.picking_category_cri")
rma_customer_out = self.env.ref("ssi_rma.picking_category_cro")
record.stock_move_ids = record.mapped("line_ids.stock_move_ids")
record.stock_picking_ids = record.mapped(
"line_ids.stock_move_ids.picking_id"
)
for picking in record.stock_picking_ids.filtered(
lambda r: r.state == "done"
):
if picking.picking_type_category_id == rma_customer_in:
num_reception += 1
elif picking.picking_type_category_id == rma_customer_out:
num_delivery += 1
record.num_of_reception = num_reception
record.num_of_delivery = num_delivery

@api.depends(
"line_ids",
Expand Down
6 changes: 6 additions & 0 deletions ssi_rma/views/rma_mixin_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
icon="fa-sign-in"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="num_of_reception" />
</span>
<span class="o_stat_text">Reception</span>
</div>
</button>
Expand All @@ -139,6 +142,9 @@
icon="fa-sign-out"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="num_of_delivery" />
</span>
<span class="o_stat_text">Delivery</span>
</div>
</button>
Expand Down

0 comments on commit 461ae88

Please sign in to comment.