diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-12-13 14:15:17 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-12-13 14:15:17 +0700 |
| commit | 3ba967de0aa6c70b0d070a7ca723d49008aa0dd2 (patch) | |
| tree | 7f1a7ac4d517dfb988e4e5fc182b0a44108b5a2c | |
| parent | 01507fad2a05124137541dc187a06631732c606e (diff) | |
product sla
| -rw-r--r-- | indoteknik_custom/models/product_sla.py | 15 | ||||
| -rw-r--r-- | indoteknik_custom/models/vendor_sla.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/views/product_sla.xml | 2 |
3 files changed, 20 insertions, 3 deletions
diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py index 2e663d30..05210cdc 100644 --- a/indoteknik_custom/models/product_sla.py +++ b/indoteknik_custom/models/product_sla.py @@ -12,6 +12,8 @@ class ProductSla(models.Model): _rec_name = 'product_variant_id' product_variant_id = fields.Many2one('product.product',string='Product') + vendor_id = fields.Many2one('res.partner',string='Vendor', readonly=True) + sla_vendor = fields.Char(string='SLA Vendor', readonly=True) avg_leadtime = fields.Char(string='AVG Leadtime', readonly=True) leadtime = fields.Char(string='Leadtime', readonly=True) sla = fields.Char(string='SLA', readonly=True) @@ -36,6 +38,7 @@ class ProductSla(models.Model): product.sla_version += 1 product_sla = self.search([('product_variant_id', '=', product.id)], limit=1) + print(product_sla.id, product.id) if not product_sla: product_sla = self.env['product.sla'].create({ 'product_variant_id': product.id, @@ -48,6 +51,18 @@ class ProductSla(models.Model): self.sla = '-' product = self.product_variant_id + + q_vendor = [ + ('product_id', '=', product.id), + ('is_winner', '=', True) + ] + + vendor = self.env['purchase.pricelist'].search(q_vendor) + print(vendor.vendor_id.id) + if vendor: + vendor_sla = self.env['vendor.sla'].search([('id_vendor', '=', vendor.vendor_id.id)], limit=1) + self.sla_vendor = "{} {}".format(vendor_sla.duration, vendor_sla.unit) + self.vendor_id = vendor.vendor_id.id qty_available = 0 qty_available = product.qty_onhand_bandengan diff --git a/indoteknik_custom/models/vendor_sla.py b/indoteknik_custom/models/vendor_sla.py index 1e0a344f..9af86a14 100644 --- a/indoteknik_custom/models/vendor_sla.py +++ b/indoteknik_custom/models/vendor_sla.py @@ -5,11 +5,11 @@ class VendorSLA(models.Model): _description = 'Vendor SLA' _rec_name = 'id_vendor' - id_vendor = fields.Many2one('res.partner', string='Name') - duration = fields.Integer(string='Duration', description='Duration SLA') + id_vendor = fields.Many2one('res.partner', string='Name', domain="[('industry_id', '=', 46)]") + duration = fields.Integer(string='Duration', description='SLA Duration') unit = fields.Selection( [('jam', 'Jam'),('hari', 'Hari')], - string="Unit" + string="SLA Time" ) duration_unit = fields.Char(string="Duration (Unit)", compute="_compute_duration_unit") diff --git a/indoteknik_custom/views/product_sla.xml b/indoteknik_custom/views/product_sla.xml index 8b0e874b..5276bb03 100644 --- a/indoteknik_custom/views/product_sla.xml +++ b/indoteknik_custom/views/product_sla.xml @@ -6,6 +6,8 @@ <field name="arch" type="xml"> <tree create="false"> <field name="product_variant_id"/> + <field name="vendor_id" string="Vendor"/> + <field name="sla_vendor" string="Vendor SLA"/> <field name="avg_leadtime"/> <field name="sla"/> </tree> |
