summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-08-21 16:19:50 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-08-21 16:19:50 +0700
commit1043e2f2b9630b8b622a9bc5070bf167d17e08d7 (patch)
tree8fe136db08053e3b05e187d820d1b4802fb19c31
parent0e4e1eaf30f79afb2b9885c897b8a8a2044f8509 (diff)
parentfc6f0a00ab98a72ad3d08f1d5ad6f8120e21814a (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into block_manual_input_stock_picking
-rwxr-xr-xindoteknik_custom/__manifest__.py3
-rw-r--r--indoteknik_custom/models/account_move.py4
-rwxr-xr-xindoteknik_custom/models/product_template.py1
-rwxr-xr-xindoteknik_custom/models/purchase_order.py32
-rwxr-xr-xindoteknik_custom/models/sale_order.py39
-rw-r--r--indoteknik_custom/models/sale_order_line.py23
-rw-r--r--indoteknik_custom/models/stock_picking.py37
-rw-r--r--indoteknik_custom/models/tukar_guling.py3
-rw-r--r--indoteknik_custom/views/approval_payment_term.xml11
-rwxr-xr-xindoteknik_custom/views/product_template.xml1
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml26
-rwxr-xr-xindoteknik_custom/views/sale_order.xml11
12 files changed, 119 insertions, 72 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 2f809e3d..aa1acef2 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -8,10 +8,11 @@
'author': 'Rafi Zadanly',
'website': '',
'images': ['assets/favicon.ico'],
- 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan', 'vit_efaktur', 'barcodes'],
+ 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan', 'vit_efaktur'],
'data': [
'views/assets.xml',
'security/ir.model.access.csv',
+ # 'views/assets.xml',
'views/group_partner.xml',
'views/blog_post.xml',
'views/coupon_program.xml',
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index b0ffd8b9..94774f0f 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -278,8 +278,9 @@ class AccountMove(models.Model):
'reply_to': 'finance@indoteknik.co.id',
}
- _logger.info(f"Mengirim email ke: {values['email_to']} > email CC: {values['email_cc']}")
template.send_mail(invs[0].id, force_send=True, email_values=values)
+ _logger.info(f"Mengirim email ke: {values['email_to']} > email CC: {values['email_cc']}")
+ _logger.info(f"Reminder terkirim ke {partner.name} ({values['email_to']}) → {len(invs)} invoice (dtd = {dtd})")
# flag
invs.write({'reminder_sent_date': today})
# Post ke chatter
@@ -293,7 +294,6 @@ class AccountMove(models.Model):
author_id=system_id,
)
- _logger.info(f"Reminder terkirim ke {partner.name} ({values['email_to']}) → {len(invs)} invoice (dtd = {dtd})")
@api.onchange('invoice_date')
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index f59bea6b..13e99707 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -1365,4 +1365,5 @@ class ImageCarousel(models.Model):
_order = 'product_id, id'
product_id = fields.Many2one('product.template', string='Product', required=True, ondelete='cascade', index=True, copy=False)
+ sequence = fields.Integer("Sequence", default=10)
image = fields.Binary(string='Image')
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 103a9131..50913a80 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -103,6 +103,11 @@ class PurchaseOrder(models.Model):
string="BU Related Count",
compute='_compute_bu_related_count'
)
+
+ bills_related_count = fields.Integer(
+ string="Bills DP & Pelunasan",
+ compute="_compute_bills_related_count"
+ )
manufacturing_id = fields.Many2one('mrp.production', string='Manufacturing Orders')
complete_bu_in_count = fields.Integer(
@@ -260,6 +265,33 @@ class PurchaseOrder(models.Model):
'target': 'current',
}
+ def action_view_bills(self):
+ self.ensure_one()
+
+ bill_ids = []
+ if self.bills_dp_id:
+ bill_ids.append(self.bills_dp_id.id)
+ if self.bills_pelunasan_id:
+ bill_ids.append(self.bills_pelunasan_id.id)
+
+ return {
+ 'name': 'Bills (DP & Pelunasan)',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'account.move',
+ 'view_mode': 'tree,form',
+ 'target': 'current',
+ 'domain': [('id', 'in', bill_ids)],
+ }
+
+ def _compute_bills_related_count(self):
+ for order in self:
+ count = 0
+ if order.bills_dp_id:
+ count += 1
+ if order.bills_pelunasan_id:
+ count += 1
+ order.bills_related_count = count
+
# cek payment term
def _check_payment_term(self):
_logger.info("Check Payment Term Terpanggil")
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 53be999f..9a6f314d 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -391,9 +391,9 @@ class SaleOrder(models.Model):
payment_state_custom = fields.Selection([
('unpaid', 'Unpaid'),
('partial', 'Partially Paid'),
- ('paid', 'Paid'),
+ ('paid', 'Full Paid'),
('no_invoice', 'No Invoice'),
- ], string="Payment Status", compute="_compute_payment_state_custom", store=False)
+ ], string="Payment Status Invoice", compute="_compute_payment_state_custom", store=False)
@api.depends('invoice_ids.payment_state', 'invoice_ids.amount_total', 'invoice_ids.amount_residual')
def _compute_payment_state_custom(self):
@@ -431,21 +431,27 @@ class SaleOrder(models.Model):
continue
for move in line.move_ids:
- if move.state != 'done':
- # reserve qty (draft/assigned)
- if move.picking_type_id.code == 'internal':
+ if move.picking_type_id.code == 'internal':
+ if move.state != 'done':
+ # PICK belum done → qty reserved
reserved_qty += move.reserved_availability or 0.0
- continue
-
- # sudah done → cek alur lokasi
- if move.location_dest_id.usage == 'customer':
- # barang keluar → delivered
- delivered_qty += move.quantity_done
- elif move.location_id.usage == 'customer':
- # barang balik (return) → kurangi delivered
- delivered_qty -= move.quantity_done
-
- # clamp biar ga minus
+ else:
+ # PICK done → qty_done masih dianggap reserved (masuk BU/OUT)
+ reserved_qty += move.quantity_done or 0.0
+
+ elif move.state == 'done':
+ # OUT done (customer terima) → delivered
+ if move.location_dest_id.usage == 'customer':
+ delivered_qty += move.quantity_done
+ # sekaligus kurangi reserved (karena udah terkirim)
+ reserved_qty -= move.quantity_done
+ # Return dari customer
+ elif move.location_id.usage == 'customer':
+ delivered_qty -= move.quantity_done
+ reserved_qty += move.quantity_done # balik ke reserved
+
+ # clamp jangan sampai minus
+ reserved_qty = max(reserved_qty, 0)
delivered_qty = max(delivered_qty, 0)
order.reserved_percent = (reserved_qty / total_qty) * 100
@@ -455,6 +461,7 @@ class SaleOrder(models.Model):
order.reserved_percent = order.delivered_percent = order.unreserved_percent = 0
+
def _has_ccm(self):
if self.id:
self.ccm_id = self.env['tukar.guling'].search([('origin', 'ilike', self.name)], limit=1)
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py
index 2406995d..a20f93ef 100644
--- a/indoteknik_custom/models/sale_order_line.py
+++ b/indoteknik_custom/models/sale_order_line.py
@@ -66,21 +66,29 @@ class SaleOrderLine(models.Model):
if order_qty > 0:
for move in line.move_ids:
+ # --- CASE 1: Picking belum done ---
if move.state != 'done':
- # Reserve qty (hanya dari picking internal yang belum selesai)
if move.picking_type_id.code == 'internal':
reserved_qty += move.reserved_availability or 0.0
continue
- # Kalau sudah done → cek lokasi
- if move.location_dest_id.usage == 'customer':
- # Barang keluar → tambah delivered
+ # --- CASE 2: Picking sudah done ---
+ if move.picking_type_id.code == 'internal':
+ # PICK done → qty_done tetap dianggap reserved (masih nunggu OUT)
+ reserved_qty += move.quantity_done or 0.0
+
+ elif move.location_dest_id.usage == 'customer':
+ # OUT done (barang nyampe customer)
delivered_qty += move.quantity_done
+ reserved_qty -= move.quantity_done
+
elif move.location_id.usage == 'customer':
- # Barang balik dari customer (retur) → kurangi delivered
+ # Retur dari customer
delivered_qty -= move.quantity_done
+ reserved_qty += move.quantity_done
- # Jangan sampai delivered minus
+ # clamp supaya gak minus
+ reserved_qty = max(reserved_qty, 0)
delivered_qty = max(delivered_qty, 0)
# Hitung persentase
@@ -88,9 +96,6 @@ class SaleOrderLine(models.Model):
line.delivered_percent = (delivered_qty / order_qty) * 100 if order_qty else 0
line.unreserved_percent = 100 - line.reserved_percent - line.delivered_percent
-
-
-
def _get_outgoing_incoming_moves(self):
outgoing_moves = self.env['stock.move']
incoming_moves = self.env['stock.move']
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 534b1ff1..a48e0ed1 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1330,18 +1330,20 @@ class StockPicking(models.Model):
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.date_reserved = current_time
+
# Validate Qty Demand Can't higher than Qty Product
- for move_line in self.move_line_ids_without_package:
- purchase_line = move_line.move_id.purchase_line_id
- if purchase_line:
- if purchase_line.product_uom_qty < move_line.product_uom_qty:
- raise UserError(
- _("Quantity demand (%s) tidak bisa lebih besar dari qty product (%s) untuk produk %s") % (
- move_line.product_uom_qty,
- purchase_line.product_uom_qty,
- move_line.product_id.display_name
+ if self.location_dest_id.id == 58 and 'BU/INPUT/' in self.name:
+ for move in self.move_ids_without_package:
+ purchase_line = move.purchase_line_id
+ if purchase_line:
+ if purchase_line.product_qty < move.quantity_done:
+ raise UserError(
+ _("Quantity demand (%s) tidak bisa lebih besar dari qty product (%s) untuk produk %s") % (
+ move.quantity_done,
+ purchase_line.product_qty,
+ move.product_id.display_name
+ )
)
- )
self.validation_minus_onhand_quantity()
self.responsible = self.env.user.id
@@ -2086,21 +2088,6 @@ class CheckProduct(models.Model):
status = fields.Char(string='Status', compute='_compute_status')
code_product = fields.Char(string='Code Product')
- def write(self, vals):
- if 'code_product' in vals and not self.env.context.get('from_barcode_scan'):
- raise UserError("Field Code Product hanya bisa diisi melalui barcode scan.")
- res = super().write(vals)
- # konsolidasi dll milik Anda tetap jalan
- if not self.env.context.get('skip_consolidate'):
- self.with_context(skip_consolidate=True)._consolidate_duplicate_lines()
- return res
-
- # Scanner handler
- def on_barcode_scanned(self, barcode):
- self.ensure_one()
- self.with_context(from_barcode_scan=True).write({'code_product': barcode})
- self._onchange_code_product()
-
@api.onchange('code_product')
def _onchange_code_product(self):
if not self.code_product:
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py
index 4b03d4b0..23b9f085 100644
--- a/indoteknik_custom/models/tukar_guling.py
+++ b/indoteknik_custom/models/tukar_guling.py
@@ -109,9 +109,6 @@ class TukarGuling(models.Model):
('invoice_line_ids.product_id', 'in', product_ids),
]
- if rec.partner_id:
- domain.append(('partner_id', '=', rec.partner_id.id))
-
extra = []
if rec.origin:
extra.append(('invoice_origin', 'ilike', rec.origin))
diff --git a/indoteknik_custom/views/approval_payment_term.xml b/indoteknik_custom/views/approval_payment_term.xml
index f7c24737..5c130f3f 100644
--- a/indoteknik_custom/views/approval_payment_term.xml
+++ b/indoteknik_custom/views/approval_payment_term.xml
@@ -86,6 +86,17 @@
<field name="view_mode">tree,form</field>
</record>
+ <record id="approval_payment_term_search" model="ir.ui.view">
+ <field name="name">approval.payment.term.search</field>
+ <field name="model">approval.payment.term</field>
+ <field name="arch" type="xml">
+ <search>
+ <field name="number" string="Document Number"/>
+ <field name="partner_id" string="Partner"/>
+ </search>
+ </field>
+ </record>
+
<menuitem id="menu_approval_payment_term" name="Approval Payment Term"
parent="account.menu_finance_receivables"
action="approval_payment_term_action"
diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml
index 8f9d1190..177449f4 100755
--- a/indoteknik_custom/views/product_template.xml
+++ b/indoteknik_custom/views/product_template.xml
@@ -66,6 +66,7 @@
<field name="model">image.carousel</field>
<field name="arch" type="xml">
<tree editable="bottom">
+ <field name="sequence" widget="handle"/>
<field name="image" widget="image" width="80"/>
</tree>
</field>
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 15cdc788..821f3295 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -14,6 +14,16 @@
attrs="{'invisible': ['|', ('sale_order_id', '=', False), ('state', 'not in', ['draft'])]}"
/>
</div>
+ <xpath expr="//button[@name='action_view_invoice']" position="after">
+ <button type="object"
+ name="action_view_related_bu"
+ class="oe_stat_button"
+ icon="fa-truck"
+ attrs="{'invisible': [('state', 'in', ['draft', 'sent'])]}">
+ <field name="bu_related_count" widget="statinfo" string="BU Related"/>
+ </button>
+ <field name="picking_count" invisible="1"/>
+ </xpath>
<xpath expr="//button[@name='action_view_invoice']" position="before">
<field name="is_cab_visible" invisible="1"/>
<button type="object"
@@ -21,21 +31,19 @@
class="oe_stat_button"
icon="fa-book"
attrs="{'invisible': [('is_cab_visible', '=', False)]}"
- style="width: 200px;">
+ >
<field name="move_id" widget="statinfo" string="Journal Uang Muka"/>
<span class="o_stat_text">
<t t-esc="record.move_id.name"/>
</span>
</button>
- <button type="object"
- name="action_view_related_bu"
- class="oe_stat_button"
- icon="fa-truck"
- style="width: 200px;"
- attrs="{'invisible': [('state', 'in', ['draft', 'sent'])]}">
- <field name="bu_related_count" widget="statinfo" string="BU Related"/>
+ <button name="action_view_bills"
+ type="object"
+ icon="fa-pencil-square-o"
+ attrs="{'invisible': [
+ ('bills_related_count', '=', 0)]}">
+ <field string="Bills DP &amp; Pelunasan" name="bills_related_count" widget="statinfo"/>
</button>
- <field name="picking_count" invisible="1"/>
</xpath>
<button id="draft_confirm" position="after">
<button name="po_approve"
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index be31456b..a1a5e0cd 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -464,9 +464,6 @@
<field name="pareto_status" optional="hide"/>
<field name="shipping_method_picking" optional="hide"/>
<field name="hold_outgoing" optional="hide"/>
- <field name="unreserved_percent" widget="percentpie" string="Unreserved"/>
- <field name="reserved_percent" widget="percentpie" string="Reserved"/>
- <field name="delivered_percent" widget="percentpie" string="Delivered"/>
</field>
</field>
</record>
@@ -486,10 +483,10 @@
<field name="payment_state_custom" widget="badge"
decoration-danger="payment_state_custom == 'unpaid'"
decoration-success="payment_state_custom == 'paid'"
- decoration-warning="payment_state_custom == 'partial'"/>
- <field name="unreserved_percent" widget="percentpie" string="Unreserved"/>
- <field name="reserved_percent" widget="percentpie" string="Reserved"/>
- <field name="delivered_percent" widget="percentpie" string="Delivered"/>
+ decoration-warning="payment_state_custom == 'partial'" optional="hide"/>
+ <field name="unreserved_percent" widget="percentpie" string="Unreserved" optional="hide"/>
+ <field name="reserved_percent" widget="percentpie" string="Reserved" optional="hide"/>
+ <field name="delivered_percent" widget="percentpie" string="Delivered" optional="hide"/>
<field name="payment_type" optional="hide"/>
<field name="payment_status" optional="hide"/>
<field name="pareto_status" optional="hide"/>