summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/account_asset.py12
-rwxr-xr-xindoteknik_custom/models/sale_monitoring.py8
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py6
-rwxr-xr-xindoteknik_custom/models/sale_order.py91
-rwxr-xr-xindoteknik_custom/models/x_manufactures.py1
6 files changed, 70 insertions, 49 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index f4b2f27d..25341923 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -18,3 +18,4 @@ from . import sale_order
from . import sale_monitoring_detail
from . import sale_monitoring
from . import account_move
+from . import account_asset
diff --git a/indoteknik_custom/models/account_asset.py b/indoteknik_custom/models/account_asset.py
new file mode 100644
index 00000000..bd5f9adb
--- /dev/null
+++ b/indoteknik_custom/models/account_asset.py
@@ -0,0 +1,12 @@
+from odoo import fields, models, api, _
+from odoo.exceptions import AccessError, UserError, ValidationError
+
+
+class AccountAsset(models.Model):
+ _inherit = 'account.asset.asset'
+
+ def action_close_asset(self):
+ for asset in self:
+ if asset.value > 0:
+ raise UserError("Asset masih mempunyai Value")
+ asset.state = 'close'
diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py
index 70c51132..97e96e72 100755
--- a/indoteknik_custom/models/sale_monitoring.py
+++ b/indoteknik_custom/models/sale_monitoring.py
@@ -8,6 +8,8 @@ class SaleMonitoring(models.Model):
id = fields.Integer()
sale_order_id = fields.Many2one("sale.order", string="Sale Order")
+ partner_id = fields.Many2one("res.partner", string="Customer")
+ user_id = fields.Many2one("res.users", string="Salesperson")
qty_so = fields.Integer(string="Qty SO")
qty_po = fields.Integer(string="Qty PO")
qty_po_received = fields.Integer(string="Qty PO Received")
@@ -23,7 +25,9 @@ class SaleMonitoring(models.Model):
SELECT
smd.sale_order_id AS id,
smd.date_order,
- smd.sale_order_id,
+ smd.sale_order_id,
+ smd.partner_id,
+ smd.user_id,
SUM(smd.qty_so) AS qty_so,
SUM(smd.qty_po) AS qty_po,
SUM(smd.qty_po_received) AS qty_po_received,
@@ -39,6 +43,6 @@ class SaleMonitoring(models.Model):
ELSE 'Belum Invoiced'
END AS status
FROM sale_monitoring_detail smd
- GROUP BY smd.date_order, smd.sale_order_id
+ GROUP BY smd.date_order, smd.sale_order_id, smd.partner_id, smd.user_id
)
""" % self._table)
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py
index ec9fe222..cb412c98 100755
--- a/indoteknik_custom/models/sale_monitoring_detail.py
+++ b/indoteknik_custom/models/sale_monitoring_detail.py
@@ -8,6 +8,8 @@ class SaleMonitoringDetail(models.Model):
id = fields.Integer()
sale_order_id = fields.Many2one("sale.order", string="Sale Order")
+ partner_id = fields.Many2one("res.partner", string="Customer")
+ user_id = fields.Many2one("res.users", string="Salesperson")
product_id = fields.Many2one("product.product", string="Product")
qty_so = fields.Integer(string="Qty SO")
qty_po = fields.Integer(string="Qty PO")
@@ -36,7 +38,9 @@ class SaleMonitoringDetail(models.Model):
(
SELECT
p.id AS id,
- so.id AS sale_order_id,
+ so.id AS sale_order_id,
+ so.partner_id as partner_id,
+ so.user_id,
p.id AS product_id,
sol.product_uom_qty AS qty_so,
sol.qty_delivered AS qty_so_delivered,
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 44eeae60..50e6baa3 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -12,40 +12,39 @@ class SaleOrder(models.Model):
total_percent_margin = fields.Float(
'Total Percent Margin', compute='compute_total_margin',
help="Total % Margin in Sales Order Header")
- # approval_status = fields.Integer('Approval Status', copy=False)
approval_status = fields.Selection([
('pengajuan1', 'Approval Adela'),
('pengajuan2', 'Approval Tyas'),
('approved', 'Approved'),
], string='Approval Status', readonly=True, copy=False, index=True, tracking=3)
- def sale_order_approve(self):
- for order in self:
- if order.state == 'cancel' or order.state == 'done' or order.state == 'sale':
- raise UserError("Status harus draft atau sent")
- approval1 = approval2 = 0
- for line in order.order_line:
- if not line.product_id:
- continue
- if (line.item_percent_margin <= 15 or line.item_percent_margin == 100) and (
- self.env.user.id != 6 and self.env.user.id != 7):
- approval2 += 1
- # order.approval_status = "pengajuan2"
- # break
- elif line.item_percent_margin <= 40 and (self.env.user.id != 8 and self.env.user.id != 6 and self.env.user.id != 7):
- approval1 += 1
- # order.approval_status = 'pengajuan1'
- # break
- if approval2 > 0:
- order.approval_status = 'pengajuan2'
- elif approval1 > 0:
- order.approval_status = 'pengajuan1'
- else:
- raise UserError("Bisa langsung Confirm")
+ # def sale_order_approve(self):
+ # for order in self:
+ # if order.state == 'cancel' or order.state == 'done' or order.state == 'sale':
+ # raise UserError("Status harus draft atau sent")
+ # approval1 = approval2 = 0
+ # for line in order.order_line:
+ # if not line.product_id:
+ # continue
+ # if (line.item_percent_margin <= 15 or line.item_percent_margin == 100) and (
+ # self.env.user.id != 6 and self.env.user.id != 7):
+ # approval2 += 1
+ # # order.approval_status = "pengajuan2"
+ # # break
+ # elif line.item_percent_margin <= 40 and (self.env.user.id != 8 and self.env.user.id != 6 and self.env.user.id != 7):
+ # approval1 += 1
+ # # order.approval_status = 'pengajuan1'
+ # # break
+ # if approval2 > 0:
+ # order.approval_status = 'pengajuan2'
+ # elif approval1 > 0:
+ # order.approval_status = 'pengajuan1'
+ # else:
+ # raise UserError("Bisa langsung Confirm")
- def action_cancel(self):
- self.approval_status = False
- return super(SaleOrder, self).action_cancel()
+ # def action_cancel(self):
+ # self.approval_status = False
+ # return super(SaleOrder, self).action_cancel()
def compute_total_margin(self):
for order in self:
@@ -61,25 +60,25 @@ class SaleOrder(models.Model):
total_percent_margin = round((total_margin / order.amount_untaxed), 4) * 100
order.total_percent_margin = total_percent_margin
- def action_confirm(self):
- res = super(SaleOrder, self).action_confirm()
- for order in self:
- approval1 = approval2 = 0
- for line in order.order_line:
- if not line.product_id:
- continue
- if (line.item_percent_margin <= 15 or line.item_percent_margin == 100) and (
- self.env.user.id != 6 and self.env.user.id != 7):
- approval2 += 1
- elif line.item_percent_margin <= 40 and (
- self.env.user.id != 8 and self.env.user.id != 6 and self.env.user.id != 7):
- approval1 += 1
- if approval2 > 0:
- raise UserError("Need Tyas / Akbar Approval, atau Approval manual dan lampirkan di Log Internal")
- elif approval1 > 0:
- raise UserError("Need Adela Approval")
- order.approval_status = 'approved'
- return res
+ # def action_confirm(self):
+ # res = super(SaleOrder, self).action_confirm()
+ # for order in self:
+ # approval1 = approval2 = 0
+ # for line in order.order_line:
+ # if not line.product_id:
+ # continue
+ # if (line.item_percent_margin <= 15 or line.item_percent_margin == 100) and (
+ # self.env.user.id != 6 and self.env.user.id != 7):
+ # approval2 += 1
+ # elif line.item_percent_margin <= 40 and (
+ # self.env.user.id != 8 and self.env.user.id != 6 and self.env.user.id != 7):
+ # approval1 += 1
+ # if approval2 > 0:
+ # raise UserError("Need Tyas / Akbar Approval, atau Approval manual dan lampirkan di Log Internal")
+ # elif approval1 > 0:
+ # raise UserError("Need Adela Approval")
+ # order.approval_status = 'approved'
+ # return res
class SaleOrderLine(models.Model):
diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py
index 8aff7f26..e07f724e 100755
--- a/indoteknik_custom/models/x_manufactures.py
+++ b/indoteknik_custom/models/x_manufactures.py
@@ -9,6 +9,7 @@ class XManufactures(models.Model):
x_name = fields.Char(string="Name")
x_description = fields.Html(string="Description")
x_logo_manufacture = fields.Binary(string="Logo Manufacture")
+ x_logo_manufacture_128 = fields.Image("Image 128", related="x_logo_manufacture", max_width=128, max_height=128, store=True)
x_manufacture_level = fields.Selection([
('prioritas', 'Prioritas'),
('gold', 'Gold'),