summaryrefslogtreecommitdiff
path: root/fixco_custom/models/purchasing_job.py
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_custom/models/purchasing_job.py')
-rw-r--r--fixco_custom/models/purchasing_job.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/fixco_custom/models/purchasing_job.py b/fixco_custom/models/purchasing_job.py
index 1a8ccb1..2c7138a 100644
--- a/fixco_custom/models/purchasing_job.py
+++ b/fixco_custom/models/purchasing_job.py
@@ -17,7 +17,7 @@ class PurchasingJob(models.Model):
action = fields.Char(string='Action')
product_id = fields.Many2one('product.product', string='Product')
vendor_id = fields.Many2one('res.partner', string='Vendor')
- # brand_id = fields.Many2one('brands', string='Brand')
+ brand_id = fields.Many2one('brands', string='Brand')
def create_automatic_purchase(self):
if not self:
@@ -86,7 +86,8 @@ class PurchasingJob(models.Model):
ELSE 'cukup'
END AS action,
a.product_id,
- pp2.vendor_id
+ pp2.vendor_id,
+ b.id AS brand_id
FROM (
SELECT
COALESCE(pp.default_code, pt.default_code) AS item_code,
@@ -94,7 +95,8 @@ class PurchasingJob(models.Model):
get_qty_onhand(pp.id::numeric) AS onhand,
get_qty_incoming(pp.id::numeric) AS incoming,
get_qty_outgoing(pp.id::numeric) AS outgoing,
- pp.id AS product_id
+ pp.id AS product_id,
+ pp.brand_id
FROM stock_move sm
JOIN stock_picking sp ON sp.id = sm.picking_id
JOIN product_product pp ON pp.id = sm.product_id
@@ -102,8 +104,9 @@ class PurchasingJob(models.Model):
WHERE sp.state IN ('draft', 'waiting', 'confirmed', 'assigned')
AND sp.name LIKE '%%OUT%%'
AND sm.location_id = 55
- GROUP BY pp.id, pp.default_code, pt.default_code, pt.name
+ GROUP BY pp.id, pp.default_code, pt.default_code, pt.name, pp.brand_id
) a
+ LEFT JOIN brands b ON b.id = a.brand_id
LEFT JOIN LATERAL (
SELECT vendor_id
FROM purchase_pricelist