summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-10-15 09:08:15 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-10-15 09:08:15 +0700
commite2860d19aebbd64b4c38fb18dd18d6dbcc932744 (patch)
tree991a382484ca72d4924c0a5b9a1fc628c612ec47
parent8685a05ab59c53dfaf3ab70798b1d5abb5c0bdaf (diff)
add sum qty and count item in header stock picking
-rw-r--r--indoteknik_custom/models/stock_picking.py18
-rw-r--r--indoteknik_custom/views/stock_picking.xml4
2 files changed, 22 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 6be532b5..fb17d142 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -10,6 +10,10 @@ class StockPicking(models.Model):
is_efaktur_exported = fields.Boolean(string='Is eFaktur Exported')
date_efaktur_exported = fields.Datetime(string='eFaktur Exported Date')
delivery_status = fields.Char(string='Delivery Status', compute='compute_delivery_status', readonly=True)
+ summary_qty_detail = fields.Float('Total Qty Detail', compute='_compute_summary_qty')
+ summary_qty_operation = fields.Float('Total Qty Operation', compute='_compute_summary_qty')
+ count_line_detail = fields.Float('Total Item Detail', compute='_compute_summary_qty')
+ count_line_operation = fields.Float('Total Item Operation', compute='_compute_summary_qty')
# Delivery Order
driver_departure_date = fields.Datetime(
@@ -39,6 +43,20 @@ class StockPicking(models.Model):
copy=False
)
+ def _compute_summary_qty(self):
+ sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0
+ for picking in self:
+ for detail in picking.move_line_ids_without_package: # detailed operations
+ sum_qty_detail += detail.qty_done
+ count_line_detail += 1
+ for operation in picking.move_ids_without_package: # operations
+ sum_qty_operation += operation.product_uom_qty
+ count_line_operation += 1
+ picking.summary_qty_detail = sum_qty_detail
+ picking.count_line_detail = count_line_detail
+ picking.summary_qty_operation = sum_qty_operation
+ picking.count_line_operation = count_line_operation
+
@api.onchange('picking_type_id')
def _onchange_operation_type(self):
self.is_internal_use = self.picking_type_id.is_internal_use
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index 6ad2e4cd..bc3f56d9 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -13,8 +13,12 @@
attrs="{'readonly': True}"
force_save="1"
/>
+ <field name="summary_qty_detail"/>
+ <field name="count_line_detail"/>
</field>
<field name="origin" position="after">
+ <field name="summary_qty_operation"/>
+ <field name="count_line_operation"/>
<field name="account_id"
attrs="{
'readonly': [['state', 'in', ['done', 'cancel']]],