diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-03-27 16:07:33 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-03-27 16:07:33 +0700 |
| commit | d3165976ff4c87377a33bfb7f98ac87a7f9f7930 (patch) | |
| tree | 4c94bb6f73d1f2e896b62a934921d9610fe14514 | |
| parent | 5f813fe3aec30873c6cbac323954f275c1eb31f7 (diff) | |
fix bug purchasing job
| -rw-r--r-- | indoteknik_custom/models/purchasing_job.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 06985041..1c74f0e9 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -12,7 +12,7 @@ class PurchasingJob(models.Model): id = fields.Integer() product_id = fields.Many2one('product.product', string="Product") - vendor_id = fields.Many2one('res.partner', string="Vendor") + vendor_id = fields.Many2one('res.partner', string="Vendor", compute='compute_vendor_id') brand = fields.Char(string='Brand') item_code = fields.Char(string='Item Code') product = fields.Char(string='Product Name') @@ -25,6 +25,20 @@ class PurchasingJob(models.Model): ('apo', 'APO') ], string='APO?') + def compute_vendor_id(self): + for sale in self: + domain = [ + ('product_id', '=', sale.product_id.id) + ] + sales = self.env['v.sales.outstanding'].search(domain) + + vendor_id = False + + if sales: + vendor_id = sales[0].sale_line_id.vendor_id.id + + sale.vendor_id = vendor_id + def init(self): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" @@ -39,12 +53,9 @@ class PurchasingJob(models.Model): pmp.incoming, pmp.outgoing, pmp.action, - pjs.status_apo AS status_apo, - sol.vendor_id AS vendor_id + pjs.status_apo AS status_apo FROM v_procurement_monitoring_by_product pmp LEFT JOIN purchasing_job_state pjs ON pjs.purchasing_job_id = pmp.product_id - LEFT JOIN v_sales_outstanding so ON so.product_id = pmp.product_id - LEFT JOIN sale_order_line sol ON so.sale_line_id = sol.id WHERE pmp.action = 'kurang' ) """ % self._table) |
