summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/product_pricelist.py1
-rwxr-xr-xindoteknik_custom/models/product_template.py1
-rw-r--r--indoteknik_custom/models/stock_picking.py23
-rw-r--r--indoteknik_custom/models/stock_picking_return.py27
-rwxr-xr-xindoteknik_custom/models/user_activity_log.py31
-rw-r--r--indoteknik_custom/views/product_pricelist.xml3
-rwxr-xr-xindoteknik_custom/views/product_template.xml1
-rw-r--r--indoteknik_custom/views/stock_picking.xml9
9 files changed, 94 insertions, 3 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index c4f1a443..14df8266 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -29,5 +29,6 @@ from . import users
from . import ir_attachment
from . import delivery_carrier
from . import dunning_run
+from . import stock_picking_return
from . import website_user_cart
from . import website_user_wishlist
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py
index 5573ea55..7b850d57 100644
--- a/indoteknik_custom/models/product_pricelist.py
+++ b/indoteknik_custom/models/product_pricelist.py
@@ -9,6 +9,7 @@ class ProductPricelist(models.Model):
banner = fields.Binary(string='Banner')
start_date = fields.Datetime(string='Start Date')
end_date = fields.Datetime(string='End Date')
+ banner_mobile = fields.Binary(string='Banner Mobile')
class ProductPricelistItem(models.Model):
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 5d34fbc8..114899e6 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -33,6 +33,7 @@ class ProductTemplate(models.Model):
web_price_sorting = fields.Float('Web Price Sorting', help='Hanya digunakan untuk sorting di web, harga tidak berlaku', default=0.0)
virtual_qty = fields.Float(string='Virtual Qty', default=0)
solr_flag = fields.Integer(string='Solr Flag', default=0)
+ search_rank = fields.Integer(string='Search Rank', default=0)
# def write(self, vals):
# if 'solr_flag' not in vals and self.solr_flag == 1:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index d016e241..2bdfbd9e 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -50,7 +50,12 @@ class StockPicking(models.Model):
approval_status = fields.Selection([
('pengajuan1', 'Approval Accounting'),
('approved', 'Approved'),
- ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3)
+ ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Internal Use")
+
+ approval_return_status = fields.Selection([
+ ('pengajuan1', 'Approval Accounting'),
+ ('approved', 'Approved'),
+ ], string='Approval Return Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Return")
def action_assign(self):
res = super(StockPicking, self).action_assign()
@@ -68,6 +73,13 @@ class StockPicking(models.Model):
raise UserError("Qty tidak boleh 0")
pick.approval_status = 'pengajuan1'
+ def ask_return_approval(self):
+ for pick in self:
+ if self.env.user.is_accounting:
+ pick.approval_return_status = 'approved'
+ else:
+ pick.approval_return_status = 'pengajuan1'
+
def calculate_line_no(self):
line_no = 0
for picking in self:
@@ -99,11 +111,18 @@ class StockPicking(models.Model):
def button_validate(self):
if not self.picking_code:
self.picking_code = self.env['ir.sequence'].next_by_code('stock.picking.code') or '0'
-
+
if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False:
raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO'))
+
if self.is_internal_use and not self.env.user.is_accounting:
raise UserError("Harus di Approve oleh Accounting")
+
+ for line in self.move_line_ids_without_package:
+ if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing':
+ if line.move_id.sale_line_id.qty_delivered + line.qty_done > line.move_id.sale_line_id.product_uom_qty:
+ raise UserError("Qty Delivered akan lebih dari Qty SO")
+
res = super(StockPicking, self).button_validate()
return res
diff --git a/indoteknik_custom/models/stock_picking_return.py b/indoteknik_custom/models/stock_picking_return.py
new file mode 100644
index 00000000..91a3a9fd
--- /dev/null
+++ b/indoteknik_custom/models/stock_picking_return.py
@@ -0,0 +1,27 @@
+from odoo import _, api, fields, models
+from odoo.exceptions import UserError
+from odoo.tools.float_utils import float_round
+
+
+class ReturnPicking(models.TransientModel):
+ _inherit = 'stock.return.picking'
+
+ @api.model
+ def default_get(self, fields):
+ res = super(ReturnPicking, self).default_get(fields)
+
+ stock_picking = self.env['stock.picking'].search([
+ ('id', '=', res['picking_id']),
+ ])
+
+ sale_id = stock_picking.group_id.sale_id
+ if not stock_picking.approval_return_status == 'approved' and sale_id.invoice_ids:
+ raise UserError('Harus Approval Accounting AR untuk melakukan Retur')
+
+ purchase = self.env['purchase.order'].search([
+ ('name', '=', stock_picking.group_id.name),
+ ])
+ if not stock_picking.approval_return_status == 'approved' and purchase.invoice_ids:
+ raise UserError('Harus Approval Accounting AP untuk melakukan Retur')
+
+ return res \ No newline at end of file
diff --git a/indoteknik_custom/models/user_activity_log.py b/indoteknik_custom/models/user_activity_log.py
index 07079714..ab85d47f 100755
--- a/indoteknik_custom/models/user_activity_log.py
+++ b/indoteknik_custom/models/user_activity_log.py
@@ -1,4 +1,7 @@
from odoo import models, fields
+import logging, re
+
+_logger = logging.getLogger(__name__)
class UserActivityLog(models.Model):
@@ -9,8 +12,36 @@ class UserActivityLog(models.Model):
url = fields.Char(string="URL")
res_user_id = fields.Many2one("res.users", string="User")
email = fields.Char(string="Email")
+ update_product = fields.Boolean(string="Update Product")
def clean_activity_log(self):
self.env['user.activity.log'].search([
('email', 'not ilike', '%@%'),
]).unlink()
+
+ def update_rank_search(self):
+ activity_logs = self.env['user.activity.log'].search([
+ ('url', 'ilike', '%/shop/product/%'),
+ ('update_product', '=', False),
+ # ('url', 'not ilike', '%/shop/product/%google-ads-shopping'),
+ # ('id', '=', 211957)
+ ], limit=1000)
+
+ for activity_log in activity_logs:
+ _logger.info(activity_log.url)
+ strip_index = i = 0
+ for c in activity_log.url:
+ if c == '-':
+ strip_index = i
+ i += 1
+ _logger.info(activity_log.url[strip_index+1:len(activity_log.url)])
+ product_id = activity_log.url[strip_index+1:len(activity_log.url)]
+ if '#' in product_id:
+ continue
+ if any(ch.isalpha() for ch in product_id):
+ continue
+ template = self.env['product.template'].search([
+ ('id', '=', product_id)
+ ], limit=1)
+ template.search_rank += int(template.search_rank+1)
+ activity_log.update_product = True
diff --git a/indoteknik_custom/views/product_pricelist.xml b/indoteknik_custom/views/product_pricelist.xml
index 18e9835a..3ff6854f 100644
--- a/indoteknik_custom/views/product_pricelist.xml
+++ b/indoteknik_custom/views/product_pricelist.xml
@@ -13,6 +13,9 @@
<field name="banner" widget="image" attrs="{
'invisible': [('is_flash_sale', '=', False)]
}" />
+ <field name="banner_mobile" widget="image" attrs="{
+ 'invisible': [('is_flash_sale', '=', False)]
+ }" />
<field name="start_date" attrs="{
'invisible': [('is_flash_sale', '=', False)],
'required': [('is_flash_sale', '=', True)]
diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml
index d97359b6..0e774012 100755
--- a/indoteknik_custom/views/product_template.xml
+++ b/indoteknik_custom/views/product_template.xml
@@ -45,6 +45,7 @@
<field name="website_ribbon_id" position="after">
<field name="last_calculate_rating" attrs="{'readonly': [('type', '=', 'product')]}"/>
<field name="product_rating"/>
+ <field name="search_rank"/>
<field name="web_price_sorting" attrs="{'readonly': [('type', '=', 'product')]}"/>
<field name="solr_flag"/>
</field>
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index d53bf5b5..ce70fdd8 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -10,6 +10,12 @@
<button name="ask_approval"
string="Ask Approval"
type="object"
+ attrs="{'invisible': [('is_internal_use', '=', False)]}"
+ />
+ <button name="ask_return_approval"
+ string="Ask Return/Acc"
+ type="object"
+ attrs="{'invisible': ['|', ('state', '=', 'draft'), ('state', '=', 'cancel'), ('approval_return_status', '=', 'pengajuan1')]}"
/>
</button>
<div class="oe_title" position="after">
@@ -34,7 +40,8 @@
<field name="real_shipping_id"/>
</field>
<field name="origin" position="after">
- <field name="approval_status"/>
+ <field name="approval_status" attrs="{'invisible': [('is_internal_use', '=', False)]}"/>
+ <field name="approval_return_status" attrs="{'invisible': [('approval_return_status', '=', False)]}"/>
<field name="summary_qty_operation"/>
<field name="count_line_operation"/>
<field name="account_id"