summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-01-22 17:04:08 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-01-22 17:04:08 +0700
commitecd50c41bc9db2697865dfe1c55bb32b7c9410c0 (patch)
tree1f5740cebd7b454af5c81e703c8ee9492342c54e /indoteknik_custom/models
parent4f73c6225571608e0fed6ee94ae0d2c91eaefd1a (diff)
<Miqdad> add vendor
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/gudang_service.py53
1 files changed, 41 insertions, 12 deletions
diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py
index d4f7397c..72a0f00e 100644
--- a/indoteknik_custom/models/gudang_service.py
+++ b/indoteknik_custom/models/gudang_service.py
@@ -13,6 +13,7 @@ class GudangService(models.Model):
name = fields.Char('Name', readonly=True)
partner_id = fields.Many2one('res.partner', string='Customer', readonly=True)
+ vendor_id = fields.Many2one('res.partner', string='Vendor', readonly=True, required=True)
origin = fields.Many2one('sale.order', string='Origin SO', required=True)
# picking_id = fields.Many2one('stock.picking', string = 'Picking ID', domain="[('sale_id', '=', origin)]")
schedule_date = fields.Date(
@@ -26,10 +27,17 @@ class GudangService(models.Model):
copy=False,
tracking=True
)
-
+ create_date = fields.Datetime(string='Create Date', copy=False, tracking=True, default=fields.Datetime.now())
done_date = fields.Datetime(string='Date Done', copy=False, tracking=True)
gudang_service_lines = fields.One2many('gudang.service.line', 'gudang_service_id', string='Gudang Service Lines')
- remaining_date = fields.Char('Unprocessed Since', compute='_compute_remaining_date')
+ # unprocessed_date = fields.Char(
+ # string='Unprocessed Since',
+ # compute='_compute_unprocessed_date'
+ # )
+ remaining_date = fields.Char(
+ compute='_compute_remaining_date',
+ string='Remaining Date'
+ )
state = fields.Selection([('draft', 'Backlog'), ('onprogress', 'On Progress'),('done', 'Done'), ('cancel', 'Cancel')], default='draft', tracking=True)
cancel_reason = fields.Text('Cancel Reason', tracking=True)
@@ -99,26 +107,47 @@ class GudangService(models.Model):
if records:
records._send_logistic_notification()
+ # @api.depends('schedule_date', 'start_date', 'state')
+ # def _compute_unprocessed_date(self):
+ # today = fields.Date.today()
+
+ # for rec in self:
+ # if not rec.schedule_date or rec.state == 'cancel':
+ # rec.unprocessed_date = "-"
+ # continue
+
+ # schedule = rec.schedule_date
+
+ # # BELUM DIPROSES
+ # if not rec.start_date:
+ # days = (today - schedule).days
- @api.depends('start_date', 'done_date', 'state')
+ # # SUDAH DIPROSES
+ # else:
+ # days = (rec.start_date.date() - schedule).days
+
+ # rec.unprocessed_date = _("Unprocessed %s days") % max(days, 0)
+
+ @api.depends('schedule_date', 'create_date')
def _compute_remaining_date(self):
today = fields.Date.today()
for rec in self:
- if not rec.start_date:
+ if not rec.schedule_date:
rec.remaining_date = "-"
continue
- start = rec.start_date.date()
+ base_date = rec.create_date.date() if rec.create_date else today
- if rec.state == 'done' and rec.done_date:
- end = rec.done_date.date()
- else:
- end = today
-
- days = (end - start).days
- rec.remaining_date = _("%s days") % days
+ schedule = rec.schedule_date
+ days = (schedule - base_date).days
+ if days > 0:
+ rec.remaining_date = _("In %s days") % days
+ elif days == 0:
+ rec.remaining_date = _("Today")
+ else:
+ rec.remaining_date = _("Overdue %s days") % abs(days)
def action_submit(self):