summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-02-25 14:01:15 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-02-25 14:01:15 +0700
commit6a5a2a2666c33ffafd610df882491d86918468bb (patch)
treeb61d4672169aa78a0bee9aae319af68768a2b6ee /indoteknik_api/controllers/api_v1
parent141bfb3a32e73d5b8557a70867d957d5ed3d485b (diff)
parenta24d7b2a21ff24e31eef77e2032a861b7eb13e31 (diff)
Merge branch 'odoo-production' into CR/renca-commision
# Conflicts: # indoteknik_custom/models/commision.py # indoteknik_custom/views/customer_commision.xml
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py2
-rw-r--r--indoteknik_api/controllers/api_v1/user.py8
-rw-r--r--indoteknik_api/controllers/api_v1/voucher.py22
3 files changed, 24 insertions, 8 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 8b95ade8..5b7b59bd 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -426,7 +426,7 @@ class SaleOrder(controller.Controller):
'npwp': sales_partner.npwp or '0', # Get NPWP from partner
'sppkp': sales_partner.sppkp, # Get SPPKP from partner
'email': sales_partner.email, # Get Email from partner
- 'user_id': 3222 # User ID: Nadia Rauhadatul Firdaus
+ 'user_id': 11314 # User ID: Boy Revandi
}
sales_partner = request.env['res.partner'].browse(parameters['partner_id'])
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index 1d26d356..c0974367 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -98,7 +98,7 @@ class User(controller.Controller):
user.partner_id.npwp = '00.000.000.0-000.000'
user.partner_id.sppkp = '-'
user.partner_id.nama_wajib_pajak = user.name
- user.partner_id.user_id = 3222
+ user.partner_id.user_id = 11314
user.partner_id.property_account_receivable_id = 395
user.partner_id.property_account_payable_id = 438
data = {
@@ -208,7 +208,7 @@ class User(controller.Controller):
'email': email_partner,
'street': alamat_bisnis,
'company_type': 'company',
- 'user_id': 3222,
+ 'user_id': 11314,
'property_account_receivable_id': 395,
'property_account_payable_id': 438,
'active': False,
@@ -253,7 +253,7 @@ class User(controller.Controller):
user.partner_id.npwp = '00.000.000.0-000.000'
user.partner_id.sppkp = '-'
user.partner_id.nama_wajib_pajak = name
- user.partner_id.user_id = 3222
+ user.partner_id.user_id = 11314
user.partner_id.property_account_receivable_id= 395
user.partner_id.property_account_payable_id = 438
@@ -605,7 +605,7 @@ class User(controller.Controller):
'email': email_partner,
'street': alamat_bisnis,
'company_type': 'company',
- 'user_id': 3222,
+ 'user_id': 11314,
'property_account_receivable_id': 395,
'property_account_payable_id': 438,
'active': False,
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py
index 910488d1..9ffeeace 100644
--- a/indoteknik_api/controllers/api_v1/voucher.py
+++ b/indoteknik_api/controllers/api_v1/voucher.py
@@ -22,9 +22,14 @@ class Voucher(controller.Controller):
code = kw.get('code')
type = kw.get('type')
user_id = int(kw.get('user_id', 0))
+ partner_id = int(kw.get('partner_id', 0))
source = kw.get('source')
visibility = ['public']
+ user = request.env['res.users'].search([('id', '=', user_id)], limit=1)
+ if not user:
+ return self.response([])
+
domain = []
if code:
visibility.append('private')
@@ -37,14 +42,19 @@ class Voucher(controller.Controller):
type = type.split(',')
domain += [('apply_type', 'in', type)]
+ if partner_id:
+ partner = request.env['res.partner'].search([('id', '=', partner_id)], limit=1)
+ main_parent = partner.get_main_parent()
+ if main_parent and main_parent.company_type:
+ domain += [('account_type', 'in', ['all',main_parent.company_type])]
+ # domain += [('account_type', 'in', main_parent.company_type)]
+
+
domain += [('visibility', 'in', visibility)]
vouchers = request.env['voucher'].get_active_voucher(domain)
checkout = cart.get_user_checkout(user_id, source=source)
products = checkout['products']
- user = request.env['res.users'].search([('id', '=', user_id)], limit=1)
- if not user:
- return self.response([])
order_line = []
for product in products:
@@ -89,3 +99,9 @@ class Voucher(controller.Controller):
sorted_results = sorted(results, key=lambda x: x['can_apply'], reverse=True)
return self.response(sorted_results)
+
+ def get_user_by_email(self, email):
+ return request.env['res.users'].search([
+ ('login', '=', email),
+ ('active', 'in', [True, False])
+ ]) \ No newline at end of file