summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-08-19 11:39:17 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-08-19 11:39:17 +0700
commit9907f33408582ea68e11bd0b1b2bc8608c6c1c1e (patch)
treed807418706333975ee76a800217dc70086e3e32a
parenta836a99c12e1ebf4b764810036ecb64183890ad2 (diff)
parent553ddb705044ec7ebe75361a0963564e6cde6b7b (diff)
Merge branch 'development' of bitbucket.org:altafixco/indoteknik-addons into development
-rwxr-xr-xindoteknik_custom/__manifest__.py6
-rwxr-xr-xindoteknik_custom/models/__init__.py5
-rwxr-xr-xindoteknik_custom/models/sale_order.py75
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv4
4 files changed, 30 insertions, 60 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 5120c057..61b51eed 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -16,8 +16,8 @@
'views/product_template.xml',
'views/purchase_order.xml',
'views/purchase_pricelist.xml',
- # 'views/sale_monitoring.xml',
- # 'views/sale_monitoring_detail.xml',
+ 'views/sale_monitoring.xml',
+ 'views/sale_monitoring_detail.xml',
'views/user_activity_log.xml',
'views/vit_kelurahan.xml',
'views/vit_kecamatan.xml',
@@ -30,7 +30,7 @@
'views/x_product_tags.xml',
'views/stock_vendor.xml',
'views/crm_lead.xml',
- # 'views/sale_order.xml',
+ 'views/sale_order.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 0f824714..8da36ce1 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -13,4 +13,7 @@ from . import res_users
from . import user_activity_log
from . import purchase_order
from . import purchase_pricelist
-from . import purchase_order_line \ No newline at end of file
+from . import purchase_order_line
+from . import sale_order
+from . import sale_monitoring_detail
+from . import sale_monitoring
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 88147042..44eeae60 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -4,7 +4,7 @@ from odoo.exceptions import AccessError, UserError, ValidationError
import warnings
-class SaleApproval(models.Model):
+class SaleOrder(models.Model):
_inherit = "sale.order"
total_margin = fields.Float(
'Total Margin', compute='compute_total_margin',
@@ -44,22 +44,8 @@ class SaleApproval(models.Model):
raise UserError("Bisa langsung Confirm")
def action_cancel(self):
- # cancel_warning = self._show_cancel_wizard()
- # if cancel_warning:
- # return {
- # 'name': _('Cancel Sales Order'),
- # 'view_mode': 'form',
- # 'res_model': 'sale.order.cancel',
- # 'view_id': self.env.ref('sale.sale_order_cancel_view_form').id,
- # 'type': 'ir.actions.act_window',
- # 'context': {'default_order_id': self.id},
- # 'target': 'new'
- # }
- # inv = self.invoice_ids.filtered(lambda inv: inv.state == 'draft')
- # inv.button_cancel()
self.approval_status = False
- # return self.write({'state': 'cancel'})
- return super(SaleApproval, self).action_cancel
+ return super(SaleOrder, self).action_cancel()
def compute_total_margin(self):
for order in self:
@@ -75,44 +61,25 @@ class SaleApproval(models.Model):
total_percent_margin = round((total_margin / order.amount_untaxed), 4) * 100
order.total_percent_margin = total_percent_margin
- # def action_confirm(self):
- # # if self._get_forbidden_state_confirm() & set(self.mapped('state')):
- # # raise UserError(_(
- # # 'It is not allowed to confirm an order in the following states: %s'
- # # ) % (', '.join(self._get_forbidden_state_conf irm())))
- #
- # # custom approval start here
- # res = super(SaleApproval, 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'
- #
- # # for order in self.filtered(lambda order: order.partner_id not in order.message_partner_ids):
- # # order.message_subscribe([order.partner_id.id])
- # # self.write(self._prepare_confirmation_values())
- # #
- # # # Context key 'default_name' is sometimes propagated up to here.
- # # # We don't need it and it creates issues in the creation of linked records.
- # # context = self._context.copy()
- # # context.pop('default_name', None)
- # #
- # # self.with_context(context)._action_confirm()
- # # if self.env.user.has_group('sale.group_auto_done_setting'):
- # # self.action_done()
- # 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/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index c43c17cc..08d8b519 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -8,5 +8,5 @@ access_x_product_tags,access.x.product.tags,model_x_product_tags,,1,1,1,1
access_stock_vendor,access.stock.vendor,model_stock_vendor,,1,1,1,1
access_user_activity_log,access.user.activity.log,model_user_activity_log,,1,1,1,1
access_purchase_pricelist,access.purchase.pricelist,model_purchase_pricelist,,1,1,1,1
-# access_sale_monitoring,access.sale.monitoring,model_sale_monitoring,,1,1,1,1
-# access_sale_monitoring_detail,access.sale.monitoring.detail,model_sale_monitoring_detail,,1,1,1,1 \ No newline at end of file
+access_sale_monitoring,access.sale.monitoring,model_sale_monitoring,,1,1,1,1
+access_sale_monitoring_detail,access.sale.monitoring.detail,model_sale_monitoring_detail,,1,1,1,1 \ No newline at end of file