summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-10-15 10:06:12 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-10-15 10:06:12 +0700
commita831d928c740497c777b966020aa2f198bf0066a (patch)
tree2a3ed3458d7ce18f37d28af28cfa10240981d9f2
parente2860d19aebbd64b4c38fb18dd18d6dbcc932744 (diff)
add line number in stock picking (DO and Receipt)
-rw-r--r--indoteknik_custom/models/stock_move.py2
-rw-r--r--indoteknik_custom/models/stock_picking.py9
-rw-r--r--indoteknik_custom/views/stock_picking.xml12
3 files changed, 22 insertions, 1 deletions
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index c2786762..869053d7 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -4,6 +4,8 @@ from odoo import fields, models
class StockMove(models.Model):
_inherit = 'stock.move'
+ line_no = fields.Integer('No', default=0)
+
def _create_account_move_line(self, credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost):
self.ensure_one()
if self.picking_id.is_internal_use:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index fb17d142..221aff31 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -43,6 +43,15 @@ class StockPicking(models.Model):
copy=False
)
+ def calculate_line_no(self):
+ line_no = 0
+ for picking in self:
+ for line in picking.move_ids_without_package:
+ if line.product_id.type == 'product':
+ line_no += 1
+ line.line_no = line_no
+ # _logger.info('Calculate PO Line No %s' % line.id)
+
def _compute_summary_qty(self):
sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0
for picking in self:
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index bc3f56d9..5f78ea57 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -6,6 +6,14 @@
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
+ <div class="oe_title" position="after">
+ <button name="calculate_line_no"
+ string="Line No"
+ type="object"
+ class="oe_highlight oe_edit_only"
+ attrs="{'invisible': ['|', ('state', '=', 'confirmed'), ('state', '=', 'done'), ('state', '=', 'cancel')]}"
+ />
+ </div>
<field name="backorder_id" position="after">
<field name="is_internal_use"
string="Internal Use"
@@ -27,7 +35,9 @@
}"
/>
</field>
-
+ <field name="product_id" position="before">
+ <field name="line_no" attrs="{'readonly': 1}"/>
+ </field>
<page name="note" position="after">
<page string="E-Faktur" name="efaktur" attrs="{'invisible': [['is_internal_use', '=', False]]}">
<group>