summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-05-20 14:38:49 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-05-20 14:38:49 +0700
commit9c59172b0e5b3829dbd7ad156ed4a98a87d75aed (patch)
tree7d09fd1bf0d4431cb1be5e8c9c513951c40e68bd
parent89f0377dd6e8143092d47ea4e3cdeff42a3b49e8 (diff)
parent209cfed90c1306a31a32b05eb1b3365e5a9b04e8 (diff)
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
# Conflicts: # indoteknik_custom/models/stock_picking.py
-rwxr-xr-xindoteknik_custom/models/sale_order.py43
-rw-r--r--indoteknik_custom/models/sale_order_line.py13
-rw-r--r--indoteknik_custom/models/stock_picking.py16
-rwxr-xr-xindoteknik_custom/views/sale_order.xml15
4 files changed, 62 insertions, 25 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index bdf8f1eb..e977e07c 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -332,9 +332,9 @@ class SaleOrder(models.Model):
('approve', 'Approve')
], tracking=True, string='State Cancel', copy=False)
date_hold = fields.Datetime(string='Date Hold', tracking=True, readonly=True, help='Waktu ketika SO di Hold'
- )
+ )
date_unhold = fields.Datetime(string='Date Unhold', tracking=True, readonly=True, help='Waktu ketika SO di Unhold'
- )
+ )
def _compute_total_margin_excl_third_party(self):
for order in self:
@@ -373,7 +373,7 @@ class SaleOrder(models.Model):
}
}
- def hold_unhold_qty_outgoing_so(self):
+ def hold_unhold_qty_outgoing_so(self):
if self.hold_outgoing == True:
self.hold_outgoing = False
self.date_unhold = fields.Datetime.now()
@@ -387,7 +387,6 @@ class SaleOrder(models.Model):
picking.do_unreserve()
self.hold_outgoing = True
self.date_hold = fields.Datetime.now()
-
def _validate_uniform_taxes(self):
for order in self:
@@ -405,8 +404,8 @@ class SaleOrder(models.Model):
# if rec.fee_third_party == 0 and rec.total_margin_excl_third_party != rec.total_percent_margin:
# # Gunakan direct SQL atau flag context untuk menghindari rekursi
# self.env.cr.execute("""
- # UPDATE sale_order
- # SET total_margin_excl_third_party = %s
+ # UPDATE sale_order
+ # SET total_margin_excl_third_party = %s
# WHERE id = %s
# """, (rec.total_percent_margin, rec.id))
# self.invalidate_cache()
@@ -1226,10 +1225,12 @@ class SaleOrder(models.Model):
for order in self:
for line in order.order_line:
if 'bom-it' in line.name.lower() or 'bom' in line.product_id.default_code.lower() if line.product_id.default_code else False:
- search_bom = self.env['mrp.production'].search([('product_id', '=', line.product_id.id), ('sale_order', '=', order.id), ('state', '!=', 'cancel')],
- order='name desc')
+ search_bom = self.env['mrp.production'].search(
+ [('product_id', '=', line.product_id.id), ('sale_order', '=', order.id),
+ ('state', '!=', 'cancel')],
+ order='name desc')
if search_bom:
- confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed' or x.state == 'done')
+ confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed' or x.state == 'done')
if not confirmed_bom:
raise UserError(
"Product BOM belum dikonfirmasi di Manufacturing Orders. Silakan hubungi MD.")
@@ -1527,7 +1528,7 @@ class SaleOrder(models.Model):
if not order.real_shipping_id:
UserError('Real Delivery Address harus di isi')
-
+
if not self.env.context.get('due_approve', []):
if order.validate_partner_invoice_due():
return self._create_notification_action('Notification',
@@ -2008,3 +2009,25 @@ class SaleOrder(models.Model):
if any(field in vals for field in ["order_line", "client_order_ref"]):
self._calculate_etrts_date()
return res
+
+ def write(self, vals):
+ # Cek apakah payment_term_id diubah dan SO sedang dalam approval
+ if 'payment_term_id' in vals and any(
+ order.approval_status in ['pengajuan1', 'pengajuan2', 'approved'] for order in self):
+ raise UserError(
+ "Payment Term tidak dapat diubah karena Sales Order sedang dalam proses approval atau sudah diapprove.")
+
+ if 'payment_term_id' in vals:
+ for order in self:
+ partner = order.partner_id.parent_id or order.partner_id
+ customer_payment_term = partner.property_payment_term_id
+
+ # Jika payment term yang diinput berbeda dengan payment term customer
+ if vals['payment_term_id'] != customer_payment_term.id:
+ raise UserError(
+ f"Payment Term berbeda pada Master Data Customer. "
+ f"Harap ganti ke '{customer_payment_term.name}' "
+ f"sesuai dengan payment term yang terdaftar pada customer."
+ )
+
+ return super(SaleOrder, self).write(vals)
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py
index 2450abd4..049bee2d 100644
--- a/indoteknik_custom/models/sale_order_line.py
+++ b/indoteknik_custom/models/sale_order_line.py
@@ -41,6 +41,19 @@ class SaleOrderLine(models.Model):
qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan')
desc_updatable = fields.Boolean(string='desc boolean', default=True, compute='_get_desc_updatable')
+ def _get_outgoing_incoming_moves(self):
+ outgoing_moves = self.env['stock.move']
+ incoming_moves = self.env['stock.move']
+
+ for move in self.move_ids.filtered(lambda r: r.state != 'cancel' and not r.scrapped and self.product_id == r.product_id):
+ if move.location_dest_id.usage == "customer":
+ if not move.origin_returned_move_id or (move.origin_returned_move_id and move.to_refund):
+ outgoing_moves |= move
+ elif move.location_id.usage == "customer" and move.to_refund:
+ incoming_moves |= move
+
+ return outgoing_moves, incoming_moves
+
def _get_desc_updatable(self):
for line in self:
if line.product_id.id != 417724 and line.product_id.id:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 02da5b61..0071bb1a 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1012,15 +1012,15 @@ class StockPicking(models.Model):
self.sale_id.date_doc_kirim = self.date_doc_kirim
def action_assign(self):
- # if self.sale_id.hold_outgoing == True and self.location_id.id == 57 and self.location_dest_id.id == 60:
- # raise UserError("SO on hold")
- res = super(StockPicking, self).action_assign()
- # current_time = datetime.datetime.utcnow()
- # self.real_shipping_id = self.sale_id.real_shipping_id
- # self.date_availability = current_time
+ if self.sale_id.hold_outgoing and self.location_id.id == 57 and self.location_dest_id.id == 60:
+ print(1)
+ else:
+ res = super(StockPicking, self).action_assign()
+ current_time = datetime.datetime.utcnow()
+ self.real_shipping_id = self.sale_id.real_shipping_id
+ self.date_availability = current_time
# self.check_state_reserve()
- return res
-
+ return res
def ask_approval(self):
if self.env.user.is_accounting:
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index a599a7b8..ad6bc11c 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -96,11 +96,11 @@
<attribute name="invisible">1</attribute>
</field>
<field name="user_id" position="after">
- <field name="hold_outgoing" readonly="1" />
- <field name="date_hold" readonly="1" widget="datetime" />
- <field name="date_unhold" readonly="1" widget="datetime" />
- <field name="helper_by_id" readonly="1" />
- <field name="compute_fullfillment" invisible="1" />
+ <field name="hold_outgoing" readonly="1"/>
+ <field name="date_hold" readonly="1" widget="datetime"/>
+ <field name="date_unhold" readonly="1" widget="datetime"/>
+ <field name="helper_by_id" readonly="1"/>
+ <field name="compute_fullfillment" invisible="1"/>
</field>
<field name="tag_ids" position="after">
<field name="eta_date_start"/>
@@ -303,8 +303,9 @@
</field>
<field name="payment_term_id" position="attributes">
<attribute name="attrs">
- {'readonly': [('approval_status', '=', 'approved'), ('state', 'not in',
- ['cancel', 'draft'])]}
+ {'readonly': ['|', ('approval_status', 'in', ['pengajuan1', 'pengajuan2', 'approved']),
+ ('state', 'not in',
+ ['cancel', 'draft'])]}
</attribute>
</field>