summaryrefslogtreecommitdiff
path: root/fixco_custom/models/purchasing_job.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-07-22 11:11:34 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-07-22 11:11:34 +0700
commit737d6932676242ad4aae7f7c175ea98d5b00f437 (patch)
tree0da618be66f96ccb053ddbe5a1161fc60cd7186d /fixco_custom/models/purchasing_job.py
parent10e171ea5389873fea3fb13c90242b322a37a990 (diff)
odoo fixco
Diffstat (limited to 'fixco_custom/models/purchasing_job.py')
-rw-r--r--fixco_custom/models/purchasing_job.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/fixco_custom/models/purchasing_job.py b/fixco_custom/models/purchasing_job.py
index 1af47b7..2c7138a 100644
--- a/fixco_custom/models/purchasing_job.py
+++ b/fixco_custom/models/purchasing_job.py
@@ -17,6 +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')
def create_automatic_purchase(self):
if not self:
@@ -54,6 +55,8 @@ class PurchasingJob(models.Model):
'partner_id': stock.vendor_id.id,
'taxes_id': stock.vendor_id.tax_id.id if stock.vendor_id.tax_id else False,
'price': price,
+ 'brand_id': stock.brand_id.id,
+ 'product_public_category_id': stock.product_id.product_public_category_id.id,
})
self.env['automatic.purchase.line'].create(lines_to_create)
@@ -83,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,
@@ -91,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
@@ -99,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
@@ -116,3 +122,4 @@ class PurchasingJob(models.Model):
+