summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sales_order_fullfillment.py
blob: ab416e8d8ca9309fd92a808b686892faaaecbb5e (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
from odoo import fields, models, api, _
from odoo.exceptions import AccessError, UserError, ValidationError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
import logging

_logger = logging.getLogger(__name__)


class SalesOrderFullfillment(models.Model):
    _name = 'sales.order.fullfillment'

    sales_order_id = fields.Many2one('sale.order', string='Sale Order')
    product_id = fields.Many2one('product.product', string='Product')
    reserved_from = fields.Char(string='Reserved From', copy=False)  
    qty_fullfillment = fields.Float(string='Qty')
    user_id = fields.Many2one('res.users', string='Responsible', compute='get_user_id')

    def get_user_id(self):
        for rec in self:
            po = self.env['purchase.order'].search([('name', '=', rec.reserved_from)], limit=1)

            if po:
                rec.user_id = po.user_id.id
            else:
                rec.user_id = False