summaryrefslogtreecommitdiff
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
parentf0f30aa566c0e49b03fd86f86bbcd80d6c7383ce (diff)
parent4a670f1f85848ef46c605fd67ff4e3d305571522 (diff)
Merged in production (pull request #80)
Production
-rw-r--r--indoteknik_api/controllers/api_v1/banner.py17
-rw-r--r--indoteknik_api/controllers/api_v1/lead.py4
-rw-r--r--indoteknik_api/controllers/api_v1/manufacture.py3
-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
-rwxr-xr-xindoteknik_custom/views/sale_order.xml9
-rw-r--r--indoteknik_custom/views/website_categories_homepage.xml14
-rwxr-xr-xindoteknik_custom/views/x_banner_banner.xml29
-rwxr-xr-xindoteknik_custom/views/x_manufactures.xml2
15 files changed, 96 insertions, 51 deletions
diff --git a/indoteknik_api/controllers/api_v1/banner.py b/indoteknik_api/controllers/api_v1/banner.py
index 1bd0fea6..79aa5fa5 100644
--- a/indoteknik_api/controllers/api_v1/banner.py
+++ b/indoteknik_api/controllers/api_v1/banner.py
@@ -1,6 +1,7 @@
from .. import controller
from odoo import http
from odoo.http import request
+from datetime import datetime
class Banner(controller.Controller):
@@ -13,14 +14,17 @@ class Banner(controller.Controller):
type = kw.get('type')
limit = int(kw.get('limit', 0))
offset = int(kw.get('offset', 0))
- order = kw.get('order')
- if not order:
- order = 'write_date DESC'
+ order = kw.get('order', 'write_date DESC')
query = [('x_status_banner', '=', 'tayang')]
if type:
query += [('x_banner_category.x_studio_field_KKVl4', '=', type)]
+ week_number = self.get_week_number_of_current_month()
+ if type == 'index-a-1':
+ order = 'sequence ASC'
+ query += [('for_week', 'in', [week_number, False])]
+
if manufacture_id:
query += [('x_relasi_manufacture', '=', int(manufacture_id))]
@@ -35,4 +39,9 @@ class Banner(controller.Controller):
'image': request.env['ir.attachment'].api_image('x_banner.banner', 'x_banner_image', banner.id),
})
- return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')]) \ No newline at end of file
+ return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')])
+
+ def get_week_number_of_current_month(self):
+ today = datetime.now().day
+ week_number = (today - 1) // 7 + 1
+ return min(week_number, 4) \ No newline at end of file
diff --git a/indoteknik_api/controllers/api_v1/lead.py b/indoteknik_api/controllers/api_v1/lead.py
index df4f46bd..23c3bf99 100644
--- a/indoteknik_api/controllers/api_v1/lead.py
+++ b/indoteknik_api/controllers/api_v1/lead.py
@@ -20,7 +20,9 @@ class Lead(controller.Controller):
if not params['valid']:
return self.response(code=400, description=params)
-
+
+ params['value']['user_id'] = 20
+
lead = request.env['crm.lead'].create(params['value'])
return self.response(True) \ No newline at end of file
diff --git a/indoteknik_api/controllers/api_v1/manufacture.py b/indoteknik_api/controllers/api_v1/manufacture.py
index 345fd660..cbee253d 100644
--- a/indoteknik_api/controllers/api_v1/manufacture.py
+++ b/indoteknik_api/controllers/api_v1/manufacture.py
@@ -16,6 +16,7 @@ class Manufacture(controller.Controller):
level = kw.get('level')
limit = int(kw.get('limit', 0))
offset = int(kw.get('offset', 0))
+ order = 'sequence ASC'
if name:
name = '%' + name.replace(' ', '%') + '%' if '%' not in name else name
@@ -26,7 +27,7 @@ class Manufacture(controller.Controller):
return self.response(code=400, description='level possible value is prioritas, gold, silver')
query.append(('x_manufacture_level', '=', level))
- manufactures = request.env['x_manufactures'].search(query, limit=limit, offset=offset)
+ manufactures = request.env['x_manufactures'].search(query, order=order, limit=limit, offset=offset)
data = {
'manufacture_total': request.env['x_manufactures'].search_count(query),
'manufactures': [request.env['x_manufactures'].api_single_response(x) for x in manufactures]
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
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index f7f9c0ea..d2a59621 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -28,11 +28,15 @@
<field name="total_percent_margin"/>
<field name="voucher_id" readonly="1" />
</field>
+ <field name="source_id" position="attributes">
+ <attribute name="invisible">1</attribute>
+ </field>
<field name="analytic_account_id" position="after">
<field name="customer_type" attrs="{'required': ['|', ('create_date', '&gt;', '2023-06-28'), ('create_date', '=', False)]}"/>
<field name="npwp" placeholder='99.999.999.9-999.999' attrs="{'required': ['|', ('create_date', '&gt;', '2023-06-28'), ('create_date', '=', False)]}"/>
<field name="sppkp" attrs="{'invisible': [('customer_type','!=','pkp')], 'required': [('customer_type', '=', 'pkp')]}"/>
<field name="due_id" readonly="1"/>
+ <field name="source_id" domain="[('id', 'in', [32, 59, 60, 61])]" attrs="{'required':[('create_date', '&gt;', '2023-09-10')]}"/>
</field>
<field name="partner_shipping_id" position="after">
<field name="real_shipping_id"/>
@@ -56,11 +60,6 @@
}
</attribute>
</xpath>
- <field name="source_id" position="attributes">
- <attribute name="domain">[('id', 'in', [32, 59, 60, 61])]</attribute>
- <attribute name="attrs">{'required':[('create_date', '&gt;', '2023-07-30')]}
- </attribute>
- </field>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_total']" position="after">
<field name="vendor_id" attrs="{'readonly': [('parent.approval_status', '=', 'approved')]}"/>
<field name="purchase_price" attrs="
diff --git a/indoteknik_custom/views/website_categories_homepage.xml b/indoteknik_custom/views/website_categories_homepage.xml
index 22424280..0a7ef2c2 100644
--- a/indoteknik_custom/views/website_categories_homepage.xml
+++ b/indoteknik_custom/views/website_categories_homepage.xml
@@ -11,8 +11,7 @@
<field name="name">Website Categories Homepage</field>
<field name="model">website.categories.homepage</field>
<field name="arch" type="xml">
- <tree>
- <field name="id"/>
+ <tree default_order="sequence">
<field name="sequence"/>
<field name="category_id"/>
<field name="url"/>
@@ -31,11 +30,20 @@
<group>
<field name="sequence"/>
<field name="category_id"/>
- <field name="image"/>
+ <field name="image" widget="image"/>
<field name="url"/>
<field name="status"/>
</group>
</group>
+ <notebook>
+ <page string="Products" name="product_ids">
+ <field name="product_ids" domain="[('sale_ok', '=', True)]">
+ <tree>
+ <field name="display_name" />
+ </tree>
+ </field>
+ </page>
+ </notebook>
</sheet>
</form>
</field>
diff --git a/indoteknik_custom/views/x_banner_banner.xml b/indoteknik_custom/views/x_banner_banner.xml
index 4f3f1911..10c762af 100755
--- a/indoteknik_custom/views/x_banner_banner.xml
+++ b/indoteknik_custom/views/x_banner_banner.xml
@@ -5,12 +5,13 @@
<field name="model">x_banner.banner</field>
<field name="arch" type="xml">
<tree>
- <field name="id"/>
- <field name="x_name"/>
- <field name="x_banner_category"/>
- <field name="x_relasi_manufacture"/>
- <field name="x_url_banner"/>
- <field name="x_status_banner"/>
+ <field name="sequence" string="Seq" />
+ <field name="x_name" />
+ <field name="for_week" />
+ <field name="x_banner_category" />
+ <field name="x_relasi_manufacture" />
+ <field name="x_url_banner" />
+ <field name="x_status_banner" />
</tree>
</field>
</record>
@@ -23,15 +24,17 @@
<sheet>
<group>
<group>
- <field name="x_name"/>
- <field name="x_banner_category"/>
- <field name="x_relasi_manufacture"/>
- <field name="x_url_banner"/>
- <field name="x_status_banner"/>
+ <field name="x_name" />
+ <field name="x_banner_category" />
+ <field name="x_relasi_manufacture" />
+ <field name="x_url_banner" />
+ <field name="x_status_banner" />
+ <field name="sequence" />
+ <field name="for_week" />
</group>
<group>
- <field name="background_color"/>
- <field name="x_banner_image" widget="image"/>
+ <field name="background_color" />
+ <field name="x_banner_image" widget="image" />
</group>
</group>
</sheet>
diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml
index a88c5d34..dd896179 100755
--- a/indoteknik_custom/views/x_manufactures.xml
+++ b/indoteknik_custom/views/x_manufactures.xml
@@ -16,6 +16,7 @@
<field name="model">x_manufactures</field>
<field name="arch" type="xml">
<tree>
+ <field name="sequence" string="Seq"/>
<field name="x_name"/>
<field name="x_negara_asal"/>
<field name="x_short_desc"/>
@@ -37,6 +38,7 @@
<group>
<group>
<field name="x_name"/>
+ <field name="sequence"/>
<field name="x_negara_asal"/>
<field name="x_short_desc"/>
<field name="x_manufacture_level"/>