summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-02-10 11:04:07 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-02-10 11:04:07 +0700
commit337e769c7eab63275b4114f48e789bdcf808bdf1 (patch)
tree24f09636ecd83abcc22f53295c905d637801b437
parentbbf176b0ce51ade22b74d0df2023025a4cef3efa (diff)
add line no in so / po and stock picking
-rwxr-xr-xindoteknik_custom/models/purchase_order.py2
-rwxr-xr-xindoteknik_custom/models/sale_order.py1
-rw-r--r--indoteknik_custom/models/stock_picking.py23
-rwxr-xr-xindoteknik_custom/views/sale_order.xml7
4 files changed, 28 insertions, 5 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index b4d671b6..2f3d2ec4 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -169,6 +169,8 @@ class PurchaseOrder(models.Model):
self.approval_status = 'approved'
self.po_status = 'menunggu'
+ self.calculate_line_no()
+
return res
def po_approve(self):
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index e85454da..f21554f7 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -281,6 +281,7 @@ class SaleOrder(models.Model):
raise UserError("Harus diapprove oleh Manager")
else:
order.approval_status = 'approved'
+ order.calculate_line_no()
return res
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 8a0ad71e..180e2500 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -95,13 +95,25 @@ class StockPicking(models.Model):
pick.approval_return_status = 'pengajuan1'
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)
+ # order_lines = picking.group_id.order_line
+ name = picking.group_id.name
+ if picking.group_id.sale_id:
+ order = self.env['sale.order'].search([('name', '=', name)], limit=1)
+ else:
+ order = self.env['purchase.order'].search([('name', '=', name)], limit=1)
+
+ order_lines = order.order_line
+ set_line = 0
+
+ for order_line in order_lines:
+ if line.product_id == order_line.product_id:
+ set_line = order_line.line_no
+ break
+ else:
+ continue
+ line.line_no = set_line
def _compute_summary_qty(self):
sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0
@@ -153,6 +165,7 @@ class StockPicking(models.Model):
self.approval_status = 'approved'
res = super(StockPicking, self).button_validate()
+ self.calculate_line_no()
return res
@api.model
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 9dfd9805..1b6f31aa 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -7,6 +7,10 @@
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<button id="action_confirm" position="after">
+ <button name="calculate_line_no"
+ string="Create No"
+ type="object"
+ />
<button name="sale_order_approve"
string="Ask Approval"
type="object"
@@ -50,6 +54,9 @@
<field name="purchase_tax_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}" domain="[('type_tax_use','=','purchase')]"/>
<field name="item_percent_margin"/>
</xpath>
+ <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="before">
+ <field name="line_no" readonly="1"/>
+ </xpath>
<field name="amount_total" position="after">
<field name="total_margin"/>
<field name="total_percent_margin"/>