summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchasing_job.py
blob: c660b93750280b9fa447e9055b494570086ffdfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from odoo import fields, models, api, tools
import logging

_logger = logging.getLogger(__name__)


class PurchasingJob(models.Model):
    _name = 'v.purchasing.job'
    _auto = False
    _rec_name = 'product_id'

    id = fields.Integer()
    product_id = fields.Many2one('product.product', string="Product")
    brand = fields.Char(string='Brand')
    item_code = fields.Char(string='Item Code')
    product = fields.Char(string='Product Name')
    onhand = fields.Float(string='OnHand')
    incoming = fields.Float(string="Incoming")
    outgoing = fields.Float(string="Outgoing")
    action = fields.Char(string="Status")

    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 beli'
            )
        """ % self._table)

    def open_form_multi_generate_request_po(self):
        action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_generate_request_po')
        action['context'] = {
            'product_ids': [x.id for x in self]
        }
        return action
    
    def generate_request_po(self):
        # print(1)
        for product in self:
            print(product)