summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rw-r--r--indoteknik_custom/models/automatic_purchase.py5
-rw-r--r--indoteknik_custom/models/product_monitoring.py35
-rwxr-xr-xindoteknik_custom/models/product_template.py35
-rwxr-xr-xindoteknik_custom/models/purchase_order.py13
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py1
-rw-r--r--indoteknik_custom/models/solr/product_product.py13
-rw-r--r--indoteknik_custom/models/solr/product_template.py8
-rw-r--r--indoteknik_custom/models/stock_picking.py2
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/product_monitoring.xml55
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml2
-rw-r--r--indoteknik_custom/views/stock_picking.xml1
14 files changed, 158 insertions, 19 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 6ae60345..23abc084 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -98,6 +98,7 @@
'views/sale_orders_multi_update.xml',
'views/quotation_so_multi_update.xml',
'views/stock_move_line.xml',
+ 'views/product_monitoring.xml',
'report/report.xml',
'report/report_banner_banner.xml',
'report/report_banner_banner2.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 95defed6..1133c3e7 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -88,4 +88,5 @@ from . import account_move_line
from . import stock_scheduler_compute
from . import promotion
from . import sale_orders_multi_update
-from . import quotation_so_multi_update \ No newline at end of file
+from . import quotation_so_multi_update
+from . import product_monitoring \ No newline at end of file
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index e21b411d..990d3cc5 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -30,12 +30,13 @@ class AutomaticPurchase(models.Model):
for vendor in vendor_ids:
param_header = {
'partner_id': vendor['partner_id'][0],
- 'partner_ref': 'Automatic PO',
+ # 'partner_ref': 'Automatic PO',
'currency_id': 12,
'user_id': self.env.user.id,
'company_id': 1, # indoteknik dotcom gemilang
'picking_type_id': 28, # indoteknik bandengan receipts
- 'date_order': current_time
+ 'date_order': current_time,
+ 'note_description': 'Automatic PO'
}
# new_po = self.env['purchase.order'].create([param_header])
products_vendors = self.env['automatic.purchase.line'].search([
diff --git a/indoteknik_custom/models/product_monitoring.py b/indoteknik_custom/models/product_monitoring.py
new file mode 100644
index 00000000..df9701ab
--- /dev/null
+++ b/indoteknik_custom/models/product_monitoring.py
@@ -0,0 +1,35 @@
+from odoo import models, fields, tools, api
+
+class ProductMonitoring(models.Model):
+ _name = 'product.monitoring'
+ _auto = False
+ _rec_name = 'product_id'
+
+ id = fields.Integer()
+ product_id = fields.Many2one('product.product', string='Product')
+ outgoing_qty = fields.Float(string="Outgoing", related='product_id.outgoing_qty')
+ incoming_qty = fields.Float(string="Incoming", related='product_id.incoming_qty')
+ qty_available = fields.Float(string="On Hand", related='product_id.qty_available')
+ qty_upcoming = fields.Float(string="Upcoming", related='product_id.qty_upcoming')
+ status_stock = fields.Selection([
+ ('outgoing_gt_stock', 'Outgoing > Stock'),
+ ('outgoing_lt_stock', 'Outgoing < Stock'),
+ ], string="Status Stock", compute='_compute_status_stock')
+
+ def _compute_status_stock(self):
+ for product in self:
+ product.status_stock = 'outgoing_lt_stock' if product.outgoing_qty <= product.qty_upcoming else 'outgoing_gt_stock'
+
+ def init(self):
+ tools.drop_view_if_exists(self.env.cr, self._table)
+ self.env.cr.execute("""
+ CREATE OR REPLACE VIEW %s AS (
+ SELECT
+ sm.product_id AS id,
+ sm.product_id AS product_id
+ FROM stock_move sm
+ LEFT JOIN stock_picking sp ON sm.picking_id = sp.id
+ WHERE sp.state NOT IN ('cancel', 'done') AND sm.product_id IS NOT null
+ GROUP BY sm.product_id
+ )
+ """ % self._table) \ No newline at end of file
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index fb8561e7..10d109fb 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -52,7 +52,11 @@ class ProductTemplate(models.Model):
help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru')
seq_new_product = fields.Integer(string='Seq New Product', help='Urutan Sequence New Product')
is_edited = fields.Boolean(string='Is Edited')
-
+ qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
+
+ def _get_qty_sold(self):
+ for rec in self:
+ rec.qty_sold = sum(x.qty_sold for x in rec.product_variant_ids)
def day_product_to_edit(self):
day_products = []
@@ -184,12 +188,7 @@ class ProductTemplate(models.Model):
def _compute_web_price(self):
for template in self:
- products = self.env['product.product'].search([
- ('product_tmpl_id', '=', template.id),
- ('active', 'in', [True, False])
- ])
- for variants in products:
- template.web_price = variants[0].web_price
+ template.web_price = template.product_variant_id.web_price
def _have_promotion_program(self):
for template in self:
@@ -308,6 +307,12 @@ class ProductTemplate(models.Model):
}
self.env['token.storage'].create([values])
return values
+
+ def write(self, vals):
+ if self.id == 224484:
+ raise UserError('Tidak dapat mengubah produk sementara')
+
+ return super(ProductTemplate, self).write(vals)
class ProductProduct(models.Model):
_inherit = "product.product"
@@ -329,8 +334,22 @@ class ProductProduct(models.Model):
material = fields.Char(string='Material')
qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan')
qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan')
+ qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming')
sla_version = fields.Integer(string="SLA Version", default=0)
is_edited = fields.Boolean(string='Is Edited')
+ qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
+
+ def _get_qty_upcoming(self):
+ for product in self:
+ product.qty_upcoming = product.incoming_qty + product.qty_available
+
+ def _get_qty_sold(self):
+ for product in self:
+ order_line = self.env['sale.order.line'].search([
+ ('order_id.state', 'in', ['done', 'sale']),
+ ('product_id', '=', product.id)
+ ])
+ product.qty_sold = sum(x.product_uom_qty for x in order_line)
def day_product_to_edit(self):
day_products = []
@@ -403,7 +422,7 @@ class ProductProduct(models.Model):
for product in self:
pricelist_id = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default_price_id_v2')
- domain = [('pricelist_id', '=', pricelist_id or 17022), ('product_id', '=', product.id)]
+ domain = [('pricelist_id.id', '=', pricelist_id or 17022), ('product_id.id', '=', product.id)]
product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1)
if product_pricelist_item.base_pricelist_id:
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 8ad25228..e8cd86fa 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -47,6 +47,7 @@ class PurchaseOrder(models.Model):
count_line_product = fields.Float('Total Item', compute='compute_count_line_product')
note_description = fields.Char(string='Note', help='bisa diisi sebagai informasi indent barang tertentu atau apapun')
has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice')
+ description = fields.Char(string='Description', help='bisa diisi sebagai informasi indent barang tertentu atau apapun')
def _compute_has_active_invoice(self):
for order in self:
@@ -55,6 +56,14 @@ class PurchaseOrder(models.Model):
def add_product_to_pricelist(self):
for line in self.order_line:
current_time = datetime.utcnow()
+ price_unit = line.price_unit
+ taxes = line.taxes_id
+ for tax in taxes:
+ tax_include = tax.price_include
+ tax_amt = tax.amount
+ if taxes:
+ if not tax_include:
+ price_unit = price_unit + (price_unit * tax_amt / 100)
purchase_pricelist = self.env['purchase.pricelist'].search([
('product_id', '=', line.product_id.id),
@@ -66,7 +75,7 @@ class PurchaseOrder(models.Model):
'vendor_id': line.order_id.partner_id.id,
'product_id': line.product_id.id,
'product_price': 0.00,
- 'system_price': line.price_unit,
+ 'system_price': price_unit,
'system_last_update': current_time,
}])
return True
@@ -74,7 +83,7 @@ class PurchaseOrder(models.Model):
for pricelist in purchase_pricelist:
pricelist.write({
'system_last_update': current_time,
- 'system_price': line.price_unit
+ 'system_price': price_unit
})
def _compute_date_planned(self):
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index 95e85122..2e91bb69 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -30,6 +30,7 @@ class PurchaseOrderLine(models.Model):
suggest = fields.Char(string='Suggest')
price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor')
so_line_id = fields.Many2one('sale.order.line', string='ID SO Line')
+ indent = fields.Boolean(string='Indent', help='centang ini jika barang indent')
def compute_price_vendor(self):
for line in self:
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py
index 31a0026d..567e2a3e 100644
--- a/indoteknik_custom/models/solr/product_product.py
+++ b/indoteknik_custom/models/solr/product_product.py
@@ -1,4 +1,4 @@
-from odoo import models, fields
+from odoo import models, fields, api
from datetime import datetime
@@ -63,7 +63,8 @@ class ProductProduct(models.Model):
'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly,
'attributes': [x.name for x in variant.product_template_attribute_value_ids],
'has_product_info_b': True,
- 'publish_b': variant.product_tmpl_id.active and variant.product_tmpl_id.type == 'product',
+ 'publish_b': variant.active and variant.type == 'product',
+ 'qty_sold_f': variant.qty_sold
})
self.solr().add(docs=[document], softCommit=True)
@@ -185,4 +186,10 @@ class ProductProduct(models.Model):
results.append(result)
- return results \ No newline at end of file
+ return results
+
+ @api.constrains('active')
+ def constrains_active(self):
+ for rec in self:
+ rec.product_tmpl_id._create_solr_queue_sync_product_template()
+ \ No newline at end of file
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index d7439bcb..f178dd5f 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -80,7 +80,8 @@ class ProductTemplate(models.Model):
"category_name": category_name,
"description_t": template.website_description or '',
'has_product_info_b': True,
- 'publish_b': template.active and template.type == 'product'
+ 'publish_b': template.active and template.type == 'product',
+ "qty_sold_f": template.qty_sold
})
self.solr().add(docs=[document], softCommit=True)
@@ -220,3 +221,8 @@ class ProductTemplate(models.Model):
results.append(result)
return results
+
+ @api.constrains('active')
+ def constrains_active(self):
+ for rec in self:
+ rec._create_solr_queue_sync_product_template() \ No newline at end of file
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 418649b1..626e842d 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -69,7 +69,7 @@ class StockPicking(models.Model):
('hold', 'Hold by Sales'),
('not_paid', 'Customer belum bayar'),
('partial', 'Kirim Parsial')
- ], string='Note', help='jika field ini diisi maka tidak akan dihitung ke lead time')
+ ], string='Note Logistic', help='jika field ini diisi maka tidak akan dihitung ke lead time')
waybill_id = fields.One2many(comodel_name='airway.bill', inverse_name='do_id', string='Airway Bill')
purchase_representative_id = fields.Many2one('res.users', related='move_lines.purchase_line_id.order_id.user_id', string="Purchase Representative", readonly=True)
carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method')
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index e362e546..7a074c71 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -77,4 +77,5 @@ access_cost_centre,access.cost.centre,model_cost_centre,,1,1,1,1
access_stock_scheduler_compute,access.stock.scheduler.compute,model_stock_scheduler_compute,,1,1,1,1
access_sale_order_promotion,access.sale.order.promotion,model_sale_order_promotion,,1,1,1,1
access_sale_orders_multi_update,access.sale.orders.multi_update,model_sale_orders_multi_update,,1,1,1,1
-access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1 \ No newline at end of file
+access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1
+access_product_monitoring,access.product.monitoring,model_product_monitoring,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/product_monitoring.xml b/indoteknik_custom/views/product_monitoring.xml
new file mode 100644
index 00000000..779a7dd7
--- /dev/null
+++ b/indoteknik_custom/views/product_monitoring.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<odoo>
+ <record id="product_monitoring_tree" model="ir.ui.view">
+ <field name="name">product.monitoring.tree</field>
+ <field name="model">product.monitoring</field>
+ <field name="arch" type="xml">
+ <tree create="false" multi_edit="1">
+ <field name="product_id"/>
+ <field name="outgoing_qty"/>
+ <field name="incoming_qty"/>
+ <field name="qty_available"/>
+ <field name="qty_upcoming"/>
+ <field name="status_stock"
+ widget="badge"
+ decoration-danger="status_stock == 'outgoing_gt_stock'"
+ decoration-success="status_stock == 'outgoing_lt_stock'"
+ />
+ </tree>
+ </field>
+ </record>
+
+ <record id="product_monitoring_form" model="ir.ui.view">
+ <field name="name">product.monitoring.form</field>
+ <field name="model">product.monitoring</field>
+ <field name="arch" type="xml">
+ <form create="false" edit="false">
+ <sheet>
+ <group>
+ <group>
+ <field name="product_id"/>
+ <field name="outgoing_qty"/>
+ <field name="incoming_qty"/>
+ <field name="qty_available"/>
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="product_monitoring_action" model="ir.actions.act_window">
+ <field name="name">Product Monitoring</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">product.monitoring</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_product_monitoring_in_purchase"
+ name="Product Monitoring"
+ parent="menu_monitoring_in_purchase"
+ sequence="1"
+ action="product_monitoring_action"
+ />
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index adcaaf43..8688c1fb 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -65,6 +65,7 @@
</field>
<field name="price_subtotal" position="after">
<field name="so_line_id" attrs="{'readonly': 1}" optional="hide"/>
+ <field name="indent" optional="hide"/>
</field>
<page name="purchase_delivery_invoice" position="after">
<page name="purchase_vendor_bills" string="Vendor Bills" groups="indoteknik_custom.technical_administrator">
@@ -75,6 +76,7 @@
</page>
<field name="fiscal_position_id" position="after">
<field name="note_description"/>
+ <field name="description"/>
<field name="total_so_percent_margin"/>
<field name="has_active_invoice" invisible="1" />
</field>
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index 9f03235d..3702dcf8 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -15,6 +15,7 @@
<field name="driver_departure_date" optional="hide"/>
<field name="driver_arrival_date" optional="hide"/>
<field name="note_logistic" optional="hide"/>
+ <field name="note" optional="hide"/>
</field>
<field name="partner_id" position="after">
<field name="purchase_representative_id"/>