diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-04 12:20:26 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-04 12:20:26 +0700 |
| commit | 5636ea3098a830a1c9fca3d18e68de573b22b986 (patch) | |
| tree | f78422516acc2d144da760bf74cf32d453b4b98b /indoteknik_custom/models | |
| parent | 39883f829f246f06d981e61431d12c3ef812e202 (diff) | |
| parent | 5d0266a4f843a1ba21127a6536a8c37d59c01647 (diff) | |
Merge branch 'brand-vendor' into release
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/brand_vendor.py | 13 | ||||
| -rwxr-xr-x | indoteknik_custom/models/x_manufactures.py | 9 |
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([ |
