summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-05-04 12:20:26 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-05-04 12:20:26 +0700
commit5636ea3098a830a1c9fca3d18e68de573b22b986 (patch)
treef78422516acc2d144da760bf74cf32d453b4b98b /indoteknik_custom/models
parent39883f829f246f06d981e61431d12c3ef812e202 (diff)
parent5d0266a4f843a1ba21127a6536a8c37d59c01647 (diff)
Merge branch 'brand-vendor' into release
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/brand_vendor.py13
-rwxr-xr-xindoteknik_custom/models/x_manufactures.py9
3 files changed, 23 insertions, 0 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 68b7df93..5dc9ce9e 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -60,3 +60,4 @@ from . import automatic_purchase
from . import apache_solr
from . import raja_ongkir
from . import procurement_monitoring_detail
+from . import brand_vendor \ No newline at end of file
diff --git a/indoteknik_custom/models/brand_vendor.py b/indoteknik_custom/models/brand_vendor.py
new file mode 100644
index 00000000..0fd122ca
--- /dev/null
+++ b/indoteknik_custom/models/brand_vendor.py
@@ -0,0 +1,13 @@
+from odoo import models, fields
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class BrandVendor(models.Model):
+ _name = 'brand.vendor'
+ _order = 'id asc'
+
+ x_manufacture_id = fields.Many2one('x_manufactures', string='Manufacture')
+ partner_id = fields.Many2one('res.partner', string='Vendor')
+ priority = fields.Integer(string='Priority', default=0)
diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py
index dd6948a9..710bfe8a 100755
--- a/indoteknik_custom/models/x_manufactures.py
+++ b/indoteknik_custom/models/x_manufactures.py
@@ -46,6 +46,15 @@ class XManufactures(models.Model):
show_as_new_product = fields.Boolean(string='Show as New Product', help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru')
parent_id = fields.Many2one('x_manufactures', string='Parent', help='Parent Brand tersebut')
category_ids = fields.Many2many('product.public.category', string='Category', help='Brand tsb memiliki Category apa saja')
+ vendor_ids = fields.Many2many('res.partner', string='Vendor', compute='_compute_vendor_ids')
+
+ def _compute_vendor_ids(self):
+ for manufacture in self:
+ vendor_ids = []
+ brand_vendors = self.env['brand.vendor'].search([('x_manufacture_id', '=', manufacture.id)], order='priority')
+ for vendor in brand_vendors:
+ vendor_ids.append(vendor.partner_id.id)
+ manufacture.vendor_ids = vendor_ids
def cache_reset(self):
manufactures = self.env['x_manufactures'].search([