summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchasing_job.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-03-25 13:07:44 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-03-25 13:07:44 +0700
commitb2377426bec8aa334277aac48b0b25f0dfac420f (patch)
tree49c6a042e0fe29295231b1d409d705a92ddbfc03 /indoteknik_custom/models/purchasing_job.py
parenta05da3fad1855cbf2ce4cc7645f1fda79cae037c (diff)
purchasing job feedback
Diffstat (limited to 'indoteknik_custom/models/purchasing_job.py')
-rw-r--r--indoteknik_custom/models/purchasing_job.py46
1 files changed, 35 insertions, 11 deletions
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py
index b3c25256..1c74f0e9 100644
--- a/indoteknik_custom/models/purchasing_job.py
+++ b/indoteknik_custom/models/purchasing_job.py
@@ -12,6 +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", compute='compute_vendor_id')
brand = fields.Char(string='Brand')
item_code = fields.Char(string='Item Code')
product = fields.Char(string='Product Name')
@@ -19,17 +20,47 @@ class PurchasingJob(models.Model):
incoming = fields.Float(string="Incoming")
outgoing = fields.Float(string="Outgoing")
action = fields.Char(string="Status")
+ status_apo = fields.Selection([
+ ('not_apo', 'Belum APO'),
+ ('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("""
CREATE OR REPLACE VIEW %s AS (
- select product_id as id, product_id, brand, item_code, product, onhand, incoming, outgoing, action
- from v_procurement_monitoring_by_product
- where action = 'kurang'
+ SELECT
+ pmp.product_id as id,
+ pmp.product_id,
+ pmp.brand,
+ pmp.item_code,
+ pmp.product,
+ pmp.onhand,
+ pmp.incoming,
+ pmp.outgoing,
+ pmp.action,
+ 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
+ WHERE pmp.action = 'kurang'
)
""" % self._table)
+
def open_form_multi_generate_request_po(self):
action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchasing_job_multi_update')
action['context'] = {
@@ -80,14 +111,7 @@ class PurchasingJob(models.Model):
automatic_purchase._create_sync_purchasing_job(job)
count += 1
_logger.info('Create Automatic Purchase Line %s' % job.product_id.name)
- return {
- 'name': _('Automatic Purchase'),
- 'view_mode': 'tree,form',
- 'res_model': 'automatic.purchase',
- 'target': 'current',
- 'type': 'ir.actions.act_window',
- 'domain': [('id', '=', automatic_purchase.id)],
- }
+ return automatic_purchase.id
class OutstandingSales(models.Model):
_name = 'v.sales.outstanding'