summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rw-r--r--indoteknik_custom/models/account_move.py9
-rw-r--r--indoteknik_custom/models/account_move_multi_update_bills.py26
-rw-r--r--indoteknik_custom/models/automatic_purchase.py14
-rw-r--r--indoteknik_custom/models/def_cargo/__init__.py3
-rw-r--r--indoteknik_custom/models/def_cargo/def_cargo_city.py11
-rw-r--r--indoteknik_custom/models/def_cargo/def_cargo_district.py15
-rw-r--r--indoteknik_custom/models/def_cargo/def_cargo_province.py10
-rw-r--r--indoteknik_custom/models/dunning_run.py1
-rw-r--r--indoteknik_custom/models/ged.py61
-rwxr-xr-xindoteknik_custom/models/product_template.py2
-rw-r--r--indoteknik_custom/models/promotion/promotion_monitoring.py16
-rw-r--r--indoteknik_custom/models/purchasing_job.py15
-rw-r--r--indoteknik_custom/models/purchasing_job_multi_update.py14
-rw-r--r--indoteknik_custom/models/report_logbook_sj.py7
-rw-r--r--indoteknik_custom/models/res_partner.py18
-rwxr-xr-xindoteknik_custom/models/sale_order.py10
-rw-r--r--indoteknik_custom/models/sale_order_line.py12
-rw-r--r--indoteknik_custom/models/uangmuka_pembelian.py5
-rw-r--r--indoteknik_custom/models/uangmuka_penjualan.py5
20 files changed, 229 insertions, 28 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 33aa0784..510dd659 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -106,6 +106,7 @@ from . import po_multi_cancel
from . import logbook_sj
from . import report_logbook_sj
from . import role_permission
+
from . import cust_commision
from . import report_stock_forecasted
from . import web_logging
@@ -113,3 +114,5 @@ from . import sales_order_fullfillment
from . import res_partner_site
from . import external_api
from . import ged
+from . import account_move_multi_update_bills
+from . import def_cargo
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index b306b6af..aa8b97be 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -246,7 +246,7 @@ class AccountMove(models.Model):
due_date = tukar_date + timedelta(days=add_days)
invoice.invoice_date_due = due_date
- @api.onchange('date_terima_tukar_faktur')
+ @api.constrains('date_terima_tukar_faktur')
def change_date_terima_tukar_faktur(self):
for invoice in self:
if not invoice.date_terima_tukar_faktur:
@@ -266,6 +266,13 @@ class AccountMove(models.Model):
}
return action
+ def open_form_multi_update_bills(self):
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_account_move_multi_update_bills')
+ action['context'] = {
+ 'move_ids': [x.id for x in self]
+ }
+ return action
+
@api.constrains('efaktur_id', 'ref', 'date', 'journal_id', 'name')
def constrains_edit(self):
for rec in self.line_ids:
diff --git a/indoteknik_custom/models/account_move_multi_update_bills.py b/indoteknik_custom/models/account_move_multi_update_bills.py
new file mode 100644
index 00000000..d348beed
--- /dev/null
+++ b/indoteknik_custom/models/account_move_multi_update_bills.py
@@ -0,0 +1,26 @@
+from odoo import models, fields
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class AccountMoveMultiUpdateBills(models.TransientModel):
+ _name = 'account.move.multi_update_bills'
+
+ date_terima_tukar_faktur = fields.Date(string="Terima Faktur")
+
+ def save_multi_update_bills(self):
+ move_ids = self._context['move_ids']
+ moves = self.env['account.move'].browse(move_ids)
+ moves.update({
+ 'date_terima_tukar_faktur': self.date_terima_tukar_faktur
+ })
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'title': 'Notification',
+ 'message': 'Account Move berhasil diubah',
+ 'next': {'type': 'ir.actions.act_window_close'},
+ }
+ } \ No newline at end of file
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index af09abf0..21d21c9c 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -570,6 +570,20 @@ class AutomaticPurchaseSalesMatch(models.Model):
qty_po = fields.Float(string='Qty PO')
purchase_price = fields.Float(string='Purchase Price SO')
purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)])
+ note_procurement = fields.Char(string='Note Detail', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring")
+
+ @api.constrains('note_procurement')
+ def note_procurement_to_so_line(self):
+ for rec in self:
+ so_line = self.env['sale.order.line'].search([
+ ('id', '=', rec.sale_line_id.id),
+ ], limit=1)
+
+ if so_line.note_procurement == False:
+ so_line.note_procurement = rec.note_procurement
+
+ if so_line.note_procurement != rec.note_procurement:
+ so_line.note_procurement = rec.note_procurement
class SyncPurchasingJob(models.Model):
_name = 'sync.purchasing.job'
diff --git a/indoteknik_custom/models/def_cargo/__init__.py b/indoteknik_custom/models/def_cargo/__init__.py
new file mode 100644
index 00000000..d6f2b19e
--- /dev/null
+++ b/indoteknik_custom/models/def_cargo/__init__.py
@@ -0,0 +1,3 @@
+from . import def_cargo_province
+from . import def_cargo_city
+from . import def_cargo_district \ No newline at end of file
diff --git a/indoteknik_custom/models/def_cargo/def_cargo_city.py b/indoteknik_custom/models/def_cargo/def_cargo_city.py
new file mode 100644
index 00000000..4e7015be
--- /dev/null
+++ b/indoteknik_custom/models/def_cargo/def_cargo_city.py
@@ -0,0 +1,11 @@
+from odoo import fields, models, api
+from datetime import datetime, timedelta
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class DefCargoCity(models.Model):
+ _name = 'def.cargo.city'
+ name = fields.Char(string="Name")
+ province_id = fields.Many2one('def.cargo.province', string="Province")
diff --git a/indoteknik_custom/models/def_cargo/def_cargo_district.py b/indoteknik_custom/models/def_cargo/def_cargo_district.py
new file mode 100644
index 00000000..0650005d
--- /dev/null
+++ b/indoteknik_custom/models/def_cargo/def_cargo_district.py
@@ -0,0 +1,15 @@
+from odoo import fields, models, api
+from datetime import datetime, timedelta
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class DefCargoDistrict(models.Model):
+ _name = 'def.cargo.district'
+ name = fields.Char(string="Name")
+ city_id = fields.Many2one('def.cargo.city', string="City")
+ coverage = fields.Char(string="Coverage")
+ rate = fields.Float(string="Rate (min 10kg)")
+ next_kg = fields.Float(string="Next Kg")
+ sla = fields.Char(string="SLA")
diff --git a/indoteknik_custom/models/def_cargo/def_cargo_province.py b/indoteknik_custom/models/def_cargo/def_cargo_province.py
new file mode 100644
index 00000000..c666da5a
--- /dev/null
+++ b/indoteknik_custom/models/def_cargo/def_cargo_province.py
@@ -0,0 +1,10 @@
+from odoo import fields, models, api
+from datetime import datetime, timedelta
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class DefCargoProvince(models.Model):
+ _name = 'def.cargo.province'
+ name = fields.Char(string="Name")
diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py
index 4e04c03c..d75d7c51 100644
--- a/indoteknik_custom/models/dunning_run.py
+++ b/indoteknik_custom/models/dunning_run.py
@@ -11,6 +11,7 @@ class DunningRun(models.Model):
_name = 'dunning.run'
_description = 'Dunning Run'
_order = 'dunning_date desc, id desc'
+ _inherit = ['mail.thread']
_rec_name = 'number'
number = fields.Char(string='Document No', index=True, copy=False, readonly=True)
diff --git a/indoteknik_custom/models/ged.py b/indoteknik_custom/models/ged.py
index a2e8bc3c..ef7b422a 100644
--- a/indoteknik_custom/models/ged.py
+++ b/indoteknik_custom/models/ged.py
@@ -124,6 +124,27 @@ class GedApi(models.Model):
self.env['token.storage'].create([param])
return token
+ def get_tracking_awb_log(self, dunning_run):
+ token = self._get_token()
+ headers = {
+ 'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ 'X-Ged-Key': x_ged_key,
+ 'X-Ged-Password': x_ged_password,
+ 'Authorization': 'Bearer ' + token
+ }
+ json_data = {
+ 'data': {
+ 'awb': dunning_run.resi_tukar_faktur
+ }
+ }
+ response = requests.post(url_tracking, headers=headers, json=json_data)
+ log = {
+ 'body': str(json_data),
+ 'responses': str(response.json())
+ }
+ self.env['ged.tracking.log'].create(log)
+
def get_tracking_awb(self, dunning_run):
# current_time = datetime.now()
# current_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
@@ -235,6 +256,10 @@ class GedApi(models.Model):
status_detail = line['status_detail']
status = line['status']
+ if status == 'Received At Warehouse' and not dunning_run.date_kirim_tukar_faktur:
+ dunning_run.date_kirim_tukar_faktur = line.created_at
+ dunning_run.copy_date_faktur()
+
param_line = {
'ged_tracking_id': ged_tracking_id,
'user_input': user_input,
@@ -257,21 +282,22 @@ class DunningRunGed(models.Model):
ged_tracking = fields.One2many('ged.tracking', 'dunning_id', string='GED Tracking', auto_join=True)
ged_tracking_line = fields.One2many('ged.tracking.line', 'dunning_id', string='GED Tracking Line', auto_join=True)
- def _get_tracking_history(self, test_awb_number):
- if test_awb_number > 0:
+ def _get_tracking_history(self, awb_number='all_data'):
+ if awb_number == 'all_data':
query = [
('last_status_awb', '!=', 'POD Return'),
- ('resi_tukar_faktur', '=', test_awb_number),
- ('shipper_faktur_id', '=', 123)
+ ('resi_tukar_faktur', '!=', False),
+ ('shipper_faktur_id', '=', 123),
+ ('date_terima_tukar_faktur', '=', False)
]
else:
query = [
('last_status_awb', '!=', 'POD Return'),
- ('resi_tukar_faktur', '!=', False),
- ('shipper_faktur_id', '=', 123),
- ('date_terima_tukar_faktur', '=', False)
+ ('resi_tukar_faktur', '=', awb_number),
+ ('shipper_faktur_id', '=', 123)
]
- dunnings = self.env['dunning.run'].search(query, limit=50)
+
+ dunnings = self.env['dunning.run'].search(query, limit=100)
for dunning in dunnings:
current_tracking = self.env['ged.tracking'].search([('awb_no', '=', dunning.resi_tukar_faktur)], limit=1)
@@ -287,5 +313,22 @@ class DunningRunGed(models.Model):
dunning.copy_date_faktur()
return
+ def _get_tracking_history_log(self, awb_number='all_data'):
+ query = [
+ ('last_status_awb', '!=', 'POD Return'),
+ ('resi_tukar_faktur', '=', awb_number),
+ ('shipper_faktur_id', '=', 123)
+ ]
+
+ dunnings = self.env['dunning.run'].search(query, limit=1)
+
+ for dunning in dunnings:
+ ged_api = self.env['ged.api']
+ ged_api.get_tracking_awb_log(dunning)
+ return
+
def get_tracking_history_by_awb(self):
- self._get_tracking_history(self.resi_tukar_faktur) \ No newline at end of file
+ self._get_tracking_history(self.resi_tukar_faktur)
+
+ def get_tracking_history_by_awb_log(self):
+ self._get_tracking_history_log(self.resi_tukar_faktur)
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 97ad07a7..6086a2ca 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -57,6 +57,8 @@ class ProductTemplate(models.Model):
('sp', 'Spare Part'),
('acc', 'Accessories')
], string='Kind of', copy=False)
+ sni = fields.Boolean(string='SNI')
+ tkdn = fields.Boolean(string='TKDN')
def _get_qty_sold(self):
for rec in self:
diff --git a/indoteknik_custom/models/promotion/promotion_monitoring.py b/indoteknik_custom/models/promotion/promotion_monitoring.py
index 9df0825d..2c4b90f1 100644
--- a/indoteknik_custom/models/promotion/promotion_monitoring.py
+++ b/indoteknik_custom/models/promotion/promotion_monitoring.py
@@ -12,6 +12,8 @@ class PromotionMonitoring(models.Model):
has_promo = fields.Boolean(string="Has Promo")
count_active = fields.Integer(string="Count Active")
count_inactive = fields.Integer(string="Count Inactive")
+ human_last_update = fields.Datetime(string='Human Last Update')
+ promotion_program_line_names = fields.Text(string="Promotion Program Line Names")
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
@@ -25,19 +27,23 @@ class PromotionMonitoring(models.Model):
p.id as id,
p.id as product_id,
ppi.computed_price as price,
- ({count_active} > 0) as has_promo,
- {count_active} as count_active,
- {count_inactive} as count_inactive
+ (COUNT(ppl.id) FILTER (WHERE ppl.active = True) > 0) as has_promo,
+ COUNT(ppl.id) FILTER (WHERE ppl.active = True) as count_active,
+ COUNT(ppl.id) FILTER (WHERE ppl.active = False) as count_inactive,
+ pr.human_last_update as human_last_update,
+ STRING_AGG(DISTINCT ppl.name, ', ') as promotion_program_line_names -- Concatenate promotion_program_line names
FROM product_product p
LEFT JOIN product_template pt ON pt.id = p.product_tmpl_id
LEFT JOIN promotion_product pp ON pp.product_id = p.id
LEFT JOIN promotion_program_line ppl ON ppl.id = pp.program_line_id
LEFT JOIN product_pricelist_item ppi ON ppi.product_id = p.id
+ LEFT JOIN purchase_pricelist pr ON pr.product_id = p.id
+ LEFT JOIN promotion_product prp ON prp.product_id = p.id -- Join with promotion.product
WHERE p.active = True
AND pt.sale_ok = True
AND ppi.pricelist_id = 17023
- GROUP BY p.id, ppi.id
- )
+ GROUP BY p.id, ppi.id, pr.human_last_update
+ );
""".format(
table=self._table,
count_active=sql['count_active'],
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py
index 86f8afcc..373e469a 100644
--- a/indoteknik_custom/models/purchasing_job.py
+++ b/indoteknik_custom/models/purchasing_job.py
@@ -188,9 +188,18 @@ class OutstandingSales(models.Model):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
CREATE OR REPLACE VIEW v_sales_outstanding AS (
- select sm.id, sm.id as move_id, sp.id as picking_id, sm.product_id, so.id as sale_id,
- sol.id as sale_line_id, rp.id as partner_id, so.user_id as salesperson_id, so.partner_invoice_id,
- sp.origin, rp2.name as salesperson, coalesce(pp.default_code, pt.default_code) as item_code, pt.name as product,
+ select sm.id,
+ sm.id as move_id,
+ sp.id as picking_id,
+ sm.product_id,
+ so.id as sale_id,
+ sol.id as sale_line_id,
+ rp.id as partner_id,
+ so.user_id as salesperson_id,
+ so.partner_invoice_id,
+ sp.origin,
+ rp2.name as salesperson,
+ coalesce(pp.default_code, pt.default_code) as item_code, pt.name as product,
sm.product_uom_qty as outgoing, xm.x_name as brand, rp.name as invoice_partner
from stock_move sm
join stock_picking sp on sp.id = sm.picking_id
diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py
index 0145b112..deba960a 100644
--- a/indoteknik_custom/models/purchasing_job_multi_update.py
+++ b/indoteknik_custom/models/purchasing_job_multi_update.py
@@ -15,15 +15,15 @@ class PurchasingJobMultiUpdate(models.TransientModel):
# if product.status_apo == 'apo':
# raise UserError('Ada Purchase Order yang statusnya APO, proses dulu')
purchasing_job_state = self.env['purchasing.job.state'].search([
- ('purchasing_job_id', '=', product.id),
- ('status_apo', '=', 'apo')
+ ('purchasing_job_id', '=', product.id)
])
- if not purchasing_job_state:
- purchasing_job_state.create({
- 'purchasing_job_id': product.id,
- 'status_apo': 'apo',
- })
+ purchasing_job_state.unlink()
+
+ purchasing_job_state.create({
+ 'purchasing_job_id': product.id,
+ 'status_apo': 'apo',
+ })
apo = self.env['automatic.purchase'].generate_regular_purchase(products)
return {
diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py
index 093848b5..a1b6299c 100644
--- a/indoteknik_custom/models/report_logbook_sj.py
+++ b/indoteknik_custom/models/report_logbook_sj.py
@@ -30,6 +30,13 @@ class ReportLogbookSJ(models.Model):
tracking=True,
)
+ count_line = fields.Char(string='Count Line', compute='_compute_count_line')
+
+ @api.depends('report_logbook_sj_line')
+ def _compute_count_line(self):
+ for rec in self:
+ rec.count_line = len(rec.report_logbook_sj_line)
+
@api.model
def create(self, vals):
vals['name'] = self.env['ir.sequence'].next_by_code('report.logbook.sj') or '0'
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index eee19b2f..ea06854d 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -1,5 +1,6 @@
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError
+from datetime import datetime
class GroupPartner(models.Model):
_name = 'group.partner'
@@ -39,7 +40,24 @@ class ResPartner(models.Model):
('PNR', 'Pareto Non Repeating'),
('NP', 'Non Pareto')
])
+
+ user_payment_terms_sales = fields.Many2one('res.users', string='Users Update Payment Terms')
+ date_payment_terms_sales = fields.Datetime(string='Date Update Payment Terms')
+ user_payment_terms_purchase = fields.Many2one('res.users', string='Users Update Payment Terms')
+ date_payment_terms_purchase = fields.Datetime(string='Date Update Payment Terms')
+
+ @api.constrains('property_payment_term_id')
+ def updated_by_payment_term(self):
+ for rec in self:
+ rec.user_payment_terms_sales = self.env.user.id
+ rec.date_payment_terms_sales = datetime.utcnow()
+ @api.constrains('property_supplier_payment_term_id')
+ def updated_by_payment_term(self):
+ for rec in self:
+ rec.user_payment_terms_purchase = self.env.user.id
+ rec.date_payment_terms_purchase = datetime.utcnow()
+
@api.onchange('site_id')
def _onchange_site_id(self):
for rec in self:
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index d246f37f..9a4f9035 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -242,6 +242,14 @@ class SaleOrder(models.Model):
'Authorization': midtrans_auth,
}
+ check_url = f'https://api.midtrans.com/v2/{so_number}/status'
+ check_response = requests.get(check_url, headers=headers)
+
+ if check_response.status_code == 200:
+ status_response = check_response.json()
+ if status_response.get('transaction_status') == 'expire':
+ so_number = so_number + '-cpl'
+
json_data = {
'transaction_details': {
'order_id': so_number,
@@ -415,7 +423,7 @@ class SaleOrder(models.Model):
if self.payment_term_id.id == 31 and self.total_percent_margin < 25:
raise UserError("Jika ingin menggunakan Tempo 90 Hari maka margin harus di atas 25%")
- if self.warehouse_id.id != 8: #GD Bandengan
+ if self.warehouse_id.id != 8 and self.warehouse_id.id != 10: #GD Bandengan
raise UserError('Gudang harus Bandengan')
if self.state not in ['draft', 'sent']:
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py
index 8fb34328..11346fc9 100644
--- a/indoteknik_custom/models/sale_order_line.py
+++ b/indoteknik_custom/models/sale_order_line.py
@@ -31,6 +31,18 @@ class SaleOrderLine(models.Model):
qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved')
reserved_from = fields.Char(string='Reserved From', copy=False)
+ @api.constrains('note_procurement')
+ def note_procurement_to_apo(self):
+ for line in self:
+ matches_so = self.env['automatic.purchase.sales.match'].search([
+ ('sale_line_id', '=', line.id),
+ ])
+
+ for match_so in matches_so:
+ match_so.note_procurement = line.note_procurement
+
+
+
@api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self):
if not self.product_uom or not self.product_id:
diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py
index 26a003fd..e3ce4a20 100644
--- a/indoteknik_custom/models/uangmuka_pembelian.py
+++ b/indoteknik_custom/models/uangmuka_pembelian.py
@@ -41,7 +41,10 @@ class UangmukaPembelian(models.TransientModel):
is_have_selisih = True
for order in orders:
- ref_label = 'UANG MUKA PEMBELIAN '+order.name+' '+order.partner_id.name
+ partner_name = order.partner_id.name
+ if order.partner_id.parent_id:
+ partner_name = order.partner_id.parent_id.name
+ ref_label = 'UANG MUKA PEMBELIAN '+order.name+' '+partner_name
param_header = {
'ref': ref_label,
'date': current_time,
diff --git a/indoteknik_custom/models/uangmuka_penjualan.py b/indoteknik_custom/models/uangmuka_penjualan.py
index 65f5361b..5acf604d 100644
--- a/indoteknik_custom/models/uangmuka_penjualan.py
+++ b/indoteknik_custom/models/uangmuka_penjualan.py
@@ -44,7 +44,10 @@ class UangmukaPenjualan(models.TransientModel):
current_time = datetime.now()
for order in orders:
- ref_label = 'UANG MUKA PENJUALAN '+order.name+' '+order.partner_id.name
+ partner_name = order.partner_id.name
+ if order.partner_id.parent_id:
+ partner_name = order.partner_id.parent_id.name
+ ref_label = 'UANG MUKA PENJUALAN '+order.name+' '+partner_name
param_header = {
'ref': ref_label,
'date': current_time,