summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-08-16 14:28:37 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-08-16 14:28:37 +0700
commit67816f01ee3c9ed5e550bbb2d515d51a97e291ad (patch)
tree07ff5e19308074a2aaa20aad971f843e76aa80df
parente534cd541152921e9f041176ab18b86172367fa9 (diff)
parent2e1c1c057b76964f4c919371209c1216df53f222 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
-rw-r--r--indoteknik_api/controllers/api_v1/user.py29
-rw-r--r--indoteknik_custom/models/mrp_production.py16
-rw-r--r--indoteknik_custom/models/stock_picking.py2
-rw-r--r--indoteknik_custom/models/user_company_request.py10
4 files changed, 38 insertions, 19 deletions
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index b5b7e055..28ac8a5e 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -396,7 +396,7 @@ class User(controller.Controller):
'user': request.env['res.users'].api_single_response(user)
})
- @http.route(prefix + 'user/<id>', auth='public', methods=['PUT', 'OPTIONS'], csrf=False)
+ @http.route(prefix + 'user/<id>', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized()
def update_user(self, **kw):
id = kw.get('id')
@@ -446,7 +446,7 @@ class User(controller.Controller):
return self.response(address)
- @http.route(prefix + 'user/<id>/switch', auth='public', methods=['PUT', 'OPTIONS'], csrf=False)
+ @http.route(prefix + 'user/<id>/switch', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized()
def switch_account(self, **kw):
id = int(kw.get('id'))
@@ -489,7 +489,7 @@ class User(controller.Controller):
if type_acc == 'business':
parameter = [
- ('company_type', '=', 'company'),
+ ('is_company', '=', True),
('name', 'ilike', business_name)
]
if parent_id:
@@ -674,11 +674,11 @@ class User(controller.Controller):
# request_company.send_company_request_mail_switch()
request_company.send_company_request_mail_switch()
- response['switch'] = 'Pending'
+ response['switch'] = 'pending'
return self.response(response)
@http.route(prefix + 'user/<id>/switch_progres', auth='public', methods=['GET', 'OPTIONS'], csrf=False)
- # @controller.Controller.must_authorized()
+ @controller.Controller.must_authorized()
def switch_account_progres(self, **kw):
id = int(kw.get('id'))
# user = request.env['res.partner'].search([('id', '=', id)], limit=1)
@@ -691,15 +691,28 @@ class User(controller.Controller):
new_company_request = request.env['user.company.request'].search(parameter, limit=1)
is_approve = ''
if new_company_request:
- # Mengambil nilai is_approve
- if new_company_request.is_approve == False:
+ if not new_company_request.is_approve: # None atau ''
response['status'] = 'pending'
else:
- response['status'] = new_company_request.is_approve
+ response['status'] = new_company_request.is_approve # 'approved' atau 'rejected'
else:
response['status'] = False
return self.response(response)
+ # @http.route(prefix + 'user/<id>/parent_status', auth='public', methods=['GET', 'OPTIONS'], csrf=False)
+ # # @controller.Controller.must_authorized()
+ # def parent_status(self, **kw):
+ # id = int(kw.get('id'))
+ # response = {
+ # 'parentId': None,
+ # 'parentName': None
+ # }
+ # partner = request.env['res.partner'].sudo().search([('id', '=', id)], limit=1)
+ # if partner and partner.parent_id:
+ # response['parentId'] = partner.parent_id.id
+ # response['parentName'] = partner.parent_id.name
+ # return self.response(response)
+
def get_user_by_email(self, email):
return request.env['res.users'].search([
('login', '=', email),
diff --git a/indoteknik_custom/models/mrp_production.py b/indoteknik_custom/models/mrp_production.py
index 91da0597..b39995b5 100644
--- a/indoteknik_custom/models/mrp_production.py
+++ b/indoteknik_custom/models/mrp_production.py
@@ -263,7 +263,7 @@ class CheckBomProduct(models.Model):
"The product '%s' tidak ada di operations. "
) % record.product_id.display_name)
- total_qty_in_moves = sum(moves.mapped('product_uom_qty'))
+ total_qty_in_moves = sum(moves.mapped('quantity_done'))
# Find existing lines for the same product, excluding the current line
existing_lines = record.production_id.check_bom_product_lines.filtered(
@@ -273,15 +273,15 @@ class CheckBomProduct(models.Model):
if existing_lines:
total_quantity = sum(existing_lines.mapped('quantity'))
- if total_quantity > total_qty_in_moves:
+ if total_quantity != total_qty_in_moves:
raise UserError((
- "Quantity Product '%s' kurang dari quantity demand."
+ "Quantity Product '%s' harus sama dengan quantity consumed."
) % (record.product_id.display_name))
else:
# Check if the quantity exceeds the allowed total
- if record.quantity > total_qty_in_moves:
+ if record.quantity != total_qty_in_moves:
raise UserError((
- "Quantity Product '%s' kurang dari quantity demand."
+ "Quantity Product '%s' harus sama dengan quantity consumed."
) % (record.product_id.display_name))
# Set the quantity to the entered value
@@ -446,7 +446,7 @@ class CheckBomProduct(models.Model):
"The product '%s' tidak ada di operations. "
) % record.product_id.display_name)
- total_qty_in_moves = sum(moves.mapped('product_uom_qty'))
+ total_qty_in_moves = sum(moves.mapped('quantity_done'))
# Find existing lines for the same product, excluding the current line
existing_lines = record.production_id.check_bom_product_lines.filtered(
@@ -462,13 +462,13 @@ class CheckBomProduct(models.Model):
if total_quantity > total_qty_in_moves:
raise UserError((
- "Quantity Product '%s' sudah melebihi quantity demand."
+ "Quantity Product '%s' sudah melebihi quantity consumed."
) % (record.product_id.display_name))
else:
# Check if the quantity exceeds the allowed total
if record.quantity == total_qty_in_moves:
raise UserError((
- "Quantity Product '%s' sudah melebihi quantity demand."
+ "Quantity Product '%s' sudah melebihi quantity consumed."
) % (record.product_id.display_name))
# Set the quantity to the entered value
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index bf6834d0..d63c5d4c 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1060,7 +1060,7 @@ class StockPicking(models.Model):
self.sale_id.date_doc_kirim = self.date_doc_kirim
def action_assign(self):
- if self.env.context.get('default_picking_type_id') and self.sale_id:
+ if self.env.context.get('default_picking_type_id') and ('BU/INPUT' not in self.name or 'BU/PUT' not in self.name):
pickings_to_assign = self.filtered(
lambda p: not (p.sale_id and p.sale_id.hold_outgoing)
)
diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py
index 9216e8eb..284575aa 100644
--- a/indoteknik_custom/models/user_company_request.py
+++ b/indoteknik_custom/models/user_company_request.py
@@ -1,6 +1,9 @@
from odoo import models, fields, api
from odoo.exceptions import UserError
from odoo.http import request
+import logging
+
+_logger = logging.getLogger(__name__)
class UserCompanyRequest(models.Model):
_name = 'user.company.request'
@@ -65,8 +68,8 @@ class UserCompanyRequest(models.Model):
is_approve = vals.get('is_approve')
is_internal_input = vals.get('internal_input')
is_company_id = vals.get('user_company_id')
- if self.is_approve and is_approve:
- raise UserError('Tidak dapat mengubah approval yang sudah diisi')
+ # if self.is_approve and is_approve:
+ # raise UserError('Tidak dapat mengubah approval yang sudah diisi')
if is_internal_input:
if self.user_company_id.nama_wajib_pajak == self.user_company_id.name:
@@ -75,6 +78,7 @@ class UserCompanyRequest(models.Model):
user_company_id = []
if is_company_id:
user_company_id = request.env['res.partner'].search([('id', '=', is_company_id)], limit=1)
+ _logger.info('User Company ID: %s', user_company_id)
# self.user_company_id.customer_type = self.similar_company_ids.customer_type
# self.user_company_id.npwp = self.similar_company_ids.npwp
# self.user_company_id.sppkp = self.similar_company_ids.sppkp
@@ -101,6 +105,8 @@ class UserCompanyRequest(models.Model):
self.user_id.property_account_payable_id = user_company_id.property_account_payable_id if user_company_id else self.user_company_id.property_account_payable_id
self.user_id.property_payment_term_id = user_company_id.property_payment_term_id if user_company_id else self.user_company_id.property_payment_term_id
self.user_id.property_supplier_payment_term_id = user_company_id.property_supplier_payment_term_id if user_company_id else self.user_company_id.property_supplier_payment_term_id
+ # self.user_id.is_company = True
+ # self.user_id.active = True
self.user_company_id.active = True
user.send_company_switch_approve_mail() if vals.get('is_switch_account') == True else user.send_company_request_approve_mail()
else: