summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHafidBuroiroh <hafidburoiroh09@gmail.com>2025-10-18 08:32:28 +0700
committerHafidBuroiroh <hafidburoiroh09@gmail.com>2025-10-18 08:32:28 +0700
commit51ebcf6f9b57c61efabb9e4e0b4fc8d5bc058512 (patch)
treefee2b5c83d896966c6be0847242ff17c96410094
parent13f131132a140e3d3b7f551d19d76a4f32a49f6b (diff)
create branch crm_pipeline
-rw-r--r--indoteknik_custom/models/sourcing.py65
-rw-r--r--indoteknik_custom/views/sourcing.xml0
2 files changed, 65 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sourcing.py b/indoteknik_custom/models/sourcing.py
new file mode 100644
index 00000000..62540700
--- /dev/null
+++ b/indoteknik_custom/models/sourcing.py
@@ -0,0 +1,65 @@
+from odoo import models, fields, api
+from odoo.exceptions import UserError
+import requests
+import json
+import logging, subprocess
+
+_logger = logging.getLogger(__name__)
+
+class SourcingOrderJob(models.Model):
+ _name = 'sourcing.job.order'
+ _descriptions = 'Sourcing Job Order MD'
+ _rec_name = 'name'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
+
+ name = fields.Char(string='Job Number', default='name', copy=False, readonly=True)
+ leads_id = fields.Many2One('crm.lead', string='Leads Number')
+ product_name = fields.Char(string='Nama Barang', required=True)
+ descriptions = fields.Text(string='Deskripsi / Spesifikasi', required=True)
+ quantity = fields.Float(string='Quantity Product', required=True)
+ eta_sales = fiels.Date(string='Expected Ready')
+ sla_product = fields.Date(string='Product Ready Date')
+ price = fields.Float(string='Harga Product Vendor')
+ vendor_id = fields.Many2One('res.partner', string="Vendor")
+ tax_id = fields.Many2One('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)])
+ user_id = fields.Many2One('res.users', string='MD Person')
+ subtotal = fields.Float(string='Total Purchase', compute='_compute_subtotal_purchase')
+ state = fields.Selection([
+ ('draft', 'Untaken'),
+ ('taken', 'On Sourcing'),
+ ('done', 'Complete'),
+ ('cancel', 'Cancel')
+ ], string='Status')
+
+ @api.depends('quantity', 'price', 'tax_id')
+ def _compute_subtotal_purchase(self):
+ """Menghitung subtotal termasuk pajak."""
+ for record in self:
+ subtotal = (record.quantity or 0.0) * (record.price or 0.0)
+ if record.tax_id:
+ tax_amount = subtotal * (record.tax_id.amount / 100)
+ subtotal += tax_amount
+
+ record.subtotal = subtotal
+
+ @api.model
+ def create(self, vals):
+ if not (self.env.user.has_group('indoteknik_custom.group_role_sales') or self.env.user.has_group('indoteknik_custom.group_role_merchandiser')):
+ raise UserError("❌ Hanya Sales dan Merchandiser yang boleh membuat Sourcing Job.")
+
+ if vals.get('name', 'New') == 'New':
+ vals['name'] = self.env['ir.sequence'].next_by_code('sourcing.job.order') or 'New'
+
+ if self.env.user.has_group('indoteknik_custom.group_role_merchandiser'):
+ vals['user_id'] = self.env.user.id
+ vals['state'] = 'taken'
+
+ return super().create(vals)
+
+ def write(self, vals):
+ if not (self.env.user.has_group('indoteknik_custom.group_role_sales') or self.env.user.has_group('indoteknik_custom.group_role_merchandiser')):
+ raise UserError("❌ Hanya Sales dan Merchandiser yang boleh membuat Sourcing Job.")
+
+ return super().write(vals)
+
+
diff --git a/indoteknik_custom/views/sourcing.xml b/indoteknik_custom/views/sourcing.xml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/indoteknik_custom/views/sourcing.xml