summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-08-03 06:15:54 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-08-03 06:15:54 +0000
commit0be8a77f6cbb31d3ac8cf9e3e606d2266a20c2ec (patch)
tree6f62bce6e049935b5a85e445ee7d959242fe7e7c /indoteknik_custom/models
parentf0f30aa566c0e49b03fd86f86bbcd80d6c7383ce (diff)
parent4a670f1f85848ef46c605fd67ff4e3d305571522 (diff)
Merged in production (pull request #80)
Production
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/account_move.py3
-rw-r--r--indoteknik_custom/models/account_move_due_extension.py1
-rw-r--r--indoteknik_custom/models/airway_bill.py10
-rw-r--r--indoteknik_custom/models/airway_bill_manifest.py33
-rwxr-xr-xindoteknik_custom/models/crm_lead.py2
-rwxr-xr-xindoteknik_custom/models/sale_order.py9
-rw-r--r--indoteknik_custom/models/website_categories_homepage.py2
-rwxr-xr-xindoteknik_custom/models/x_banner_banner.py9
8 files changed, 45 insertions, 24 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 4db97706..b188285d 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -31,8 +31,7 @@ class AccountMove(models.Model):
def unlink(self):
res = super(AccountMove, self).unlink()
- if not self.env.user.is_accounting:
- raise UserError('Hanya Accounting yang bisa delete')
+ raise UserError('Data Hanya Bisa Di Cancel')
return res
def button_cancel(self):
diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py
index 43207534..3824fb30 100644
--- a/indoteknik_custom/models/account_move_due_extension.py
+++ b/indoteknik_custom/models/account_move_due_extension.py
@@ -26,6 +26,7 @@ class DueExtension(models.Model):
('3', '3 Hari'),
('7', '7 Hari'),
('14', '14 Hari'),
+ ('21', '21 Hari'),
], string='Day Extension', help='Menambah Due Date yang sudah limit dari hari ini', tracking=True)
counter = fields.Integer(string="Counter", compute='_compute_counter')
diff --git a/indoteknik_custom/models/airway_bill.py b/indoteknik_custom/models/airway_bill.py
index 463272b4..37d2b671 100644
--- a/indoteknik_custom/models/airway_bill.py
+++ b/indoteknik_custom/models/airway_bill.py
@@ -41,11 +41,11 @@ class AirwayBill(models.Model):
self.ensure_one()
return self._json_decode(self.response)
- def _fetch(self):
+ def _fetch(self, days_before=30):
# jne, pos, tiki, wahana, jnt, rpx, sap, sicepat, jet, dse, dan first
carrier_ids = [51, 53, 54, 7, 57, 55, 59, 59, 27, 60, 62, 64]
- delta_time = datetime.now() - timedelta(days=30) # Last 30 days
+ delta_time = datetime.now() - timedelta(days=days_before) # Last 30 days
delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
query = [
'|',
@@ -61,7 +61,10 @@ class AirwayBill(models.Model):
history = self._get_waybill_history(out.delivery_tracking_no, rajaongkir.name)
if not history:
continue
- delivered = history['rajaongkir']['result']['delivered']
+ try:
+ delivered = history['rajaongkir']['result']['delivered']
+ except:
+ delivered = False
values = {
'do_id': out.id,
'so_id': out.sale_id.id,
@@ -108,6 +111,7 @@ class AirwayBill(models.Model):
elif response.get('rajaongkir', {}):
raja_ongkir = response.get('rajaongkir', {})
result = raja_ongkir.get('result', {})
+ result = result or {} # Change to empty dict when result is None
return result.get(key)
def _compute_way_bill(self, airway, key, attribute):
diff --git a/indoteknik_custom/models/airway_bill_manifest.py b/indoteknik_custom/models/airway_bill_manifest.py
index 2e16be2c..a606c2be 100644
--- a/indoteknik_custom/models/airway_bill_manifest.py
+++ b/indoteknik_custom/models/airway_bill_manifest.py
@@ -16,18 +16,21 @@ class AirwayBillManifest(models.Model):
def generate_airway_bill_line(self, waybill):
- history = waybill.decode_response()
- manifests = history['rajaongkir']['result']['manifest'] or []
- for manifest in manifests:
- code = manifest['manifest_code']
- description = manifest['manifest_description']
- date = manifest['manifest_date']
- time = manifest['manifest_time']
- city = manifest['city_name']
- self.create({
- 'waybill_id': waybill.id,
- 'code': code,
- 'description': description,
- 'datetime': date+' '+time,
- 'city': city,
- }) \ No newline at end of file
+ try:
+ history = waybill.decode_response()
+ manifests = history['rajaongkir']['result']['manifest'] or []
+ for manifest in manifests:
+ code = manifest['manifest_code']
+ description = manifest['manifest_description']
+ date = manifest['manifest_date']
+ time = manifest['manifest_time']
+ city = manifest['city_name']
+ self.create({
+ 'waybill_id': waybill.id,
+ 'code': code,
+ 'description': description,
+ 'datetime': date+' '+time,
+ 'city': city,
+ })
+ except:
+ return \ No newline at end of file
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py
index b87315ff..0cea878a 100755
--- a/indoteknik_custom/models/crm_lead.py
+++ b/indoteknik_custom/models/crm_lead.py
@@ -87,5 +87,5 @@ class CrmLead(models.Model):
elif lead.partner_id.user_id:
salesperson_id = lead.partner_id.user_id.id
else:
- salesperson_id = 2
+ salesperson_id = 20
lead.user_id = salesperson_id
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 12043996..25d28bbb 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -89,6 +89,7 @@ class SaleOrder(models.Model):
purchase_total = fields.Monetary(string='Purchase Total', compute='_compute_purchase_total')
voucher_id = fields.Many2one(comodel_name='voucher', string='Voucher')
amount_voucher_disc = fields.Float(string='Voucher Discount')
+ source_id = fields.Many2one('utm.source', 'Source', domain="[('id', 'in', [32, 59, 60, 61])]")
def _compute_purchase_total(self):
for order in self:
@@ -336,7 +337,9 @@ class SaleOrder(models.Model):
raise UserError("Status harus draft atau sent")
if not order.partner_invoice_id.npwp:
raise UserError("NPWP harus diisi di master data konsumen, jika non pkp dapat diisi 00.000.000.0-000.000")
-
+ if '-' not in order.npwp or '.' not in order.npwp:
+ raise UserError("Isi NPWP Dengan Benar!")
+
if order.partner_id.parent_id:
if not order.partner_id.parent_id.property_payment_term_id:
raise UserError("Payment Term pada Master Data Customer harus diisi")
@@ -487,7 +490,9 @@ class SaleOrder(models.Model):
raise UserError("Tax di Header harus diisi")
if not order.carrier_id:
raise UserError("Shipping Method harus diisi")
- # approval1 = approval2 = 0
+ if '-' not in order.npwp or '.' not in order.npwp:
+ raise UserError("Isi NPWP Dengan Benar!")
+
for line in order.order_line:
if not line.product_id or line.product_id.type == 'service':
continue
diff --git a/indoteknik_custom/models/website_categories_homepage.py b/indoteknik_custom/models/website_categories_homepage.py
index 612dd8a0..a0fc1011 100644
--- a/indoteknik_custom/models/website_categories_homepage.py
+++ b/indoteknik_custom/models/website_categories_homepage.py
@@ -3,6 +3,7 @@ from odoo import fields, models
class WebsiteCategoriesHomepage(models.Model):
_name = 'website.categories.homepage'
+ _rec_name = 'category_id'
category_id = fields.Many2one('product.public.category', string='Category', help='table ecommerce category')
image = fields.Binary(string='Image')
@@ -12,3 +13,4 @@ class WebsiteCategoriesHomepage(models.Model):
('tayang', 'Tayang'),
('tidak_tayang', 'Tidak Tayang')
], string='Status')
+ product_ids = fields.Many2many('product.template', string='Product Template')
diff --git a/indoteknik_custom/models/x_banner_banner.py b/indoteknik_custom/models/x_banner_banner.py
index c34b7634..a9de2067 100755
--- a/indoteknik_custom/models/x_banner_banner.py
+++ b/indoteknik_custom/models/x_banner_banner.py
@@ -16,4 +16,11 @@ class XBannerBanner(models.Model):
x_status_banner = fields.Selection([
('tayang', 'Tayang'),
('tidak_tayang', 'Tidak Tayang')
- ], string="Status") \ No newline at end of file
+ ], string="Status")
+ sequence = fields.Integer(string='Sequence')
+ for_week = fields.Selection([
+ ('1', 1),
+ ('2', 2),
+ ('3', 3),
+ ('4', 4)
+ ], string='For Week') \ No newline at end of file