From 1a68a5e600e2f7f90bee44144557f6af2f35618c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 14 Dec 2023 15:42:41 +0700 Subject: add some field in automatic purchase --- indoteknik_custom/models/automatic_purchase.py | 14 ++++++++++++++ indoteknik_custom/views/automatic_purchase.xml | 18 +++++++++++++++--- indoteknik_custom/views/ir_sequence.xml | 11 +++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 502761e0..63eefb93 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -9,7 +9,10 @@ _logger = logging.getLogger(__name__) class AutomaticPurchase(models.Model): _name = 'automatic.purchase' _order = 'id desc' + _inherit = ['mail.thread'] + _rec_name = 'number' + number = fields.Char(string='Document No', index=True, copy=False, readonly=True) date_doc = fields.Date(string='Date', required=True, help='Isi tanggal hari ini') description = fields.Char(string='Description', help='bebas isi nya apa') purchase_lines = fields.One2many('automatic.purchase.line', 'automatic_purchase_id', string='Lines', auto_join=True) @@ -18,6 +21,16 @@ class AutomaticPurchase(models.Model): purchase_match = fields.One2many('automatic.purchase.match', 'automatic_purchase_id', string='Matches', auto_join=True) vendor_id = fields.Many2one('res.partner', string='Vendor', help='boleh kosong, jika diisi, maka hanya keluar data untuk vendor tersebut') responsible_id = fields.Many2one('res.users', string='Responsible', required=True) + apo_type = fields.Selection([ + ('regular', 'Regular Fulfill SO'), + ('reordering', 'Reordering Rule'), + ], string='Type') + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('automatic.purchase') or '0' + result = super(AutomaticPurchase, self).create(vals) + return result def create_po_from_automatic_purchase(self): if not self.purchase_lines: @@ -84,6 +97,7 @@ class AutomaticPurchase(models.Model): self.is_po = True def generate_automatic_purchase(self): + # for reordering rule only if self.purchase_lines: raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index 0478304e..6f10653f 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -5,7 +5,9 @@ automatic.purchase + + @@ -56,13 +58,14 @@
- + + - - + +