diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-12-14 15:42:41 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-12-14 15:42:41 +0700 |
| commit | 1a68a5e600e2f7f90bee44144557f6af2f35618c (patch) | |
| tree | d0f3414e583284be53c5d089f2a938e35ba86ece | |
| parent | ce2b8502ab85419096dda2bffaffbec4a096a99f (diff) | |
add some field in automatic purchase
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 14 | ||||
| -rw-r--r-- | indoteknik_custom/views/automatic_purchase.xml | 18 | ||||
| -rw-r--r-- | 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 @@ <field name="model">automatic.purchase</field> <field name="arch" type="xml"> <tree> + <field name="number"/> <field name="date_doc"/> + <field name="apo_type"/> <field name="vendor_id"/> <field name="description"/> <field name="notification" readonly="1"/> @@ -56,13 +58,14 @@ <div class="oe_button_box" name="button_box"/> <group> <group> - <field name="date_doc"/> + <field name="number"/> + <field name="apo_type"/> <field name="vendor_id"/> - <field name="responsible_id"/> <field name="description"/> - <field name="notification" readonly="1"/> </group> <group> + <field name="date_doc"/> + <field name="responsible_id"/> <div> <button name="generate_automatic_purchase" string="Generate Line" @@ -84,8 +87,17 @@ <page string="Matches"> <field name="purchase_match"/> </page> + <page string="Info" name="automatic_purchase_info"> + <group> + <field name="notification" readonly="1"/> + </group> + </page> </notebook> </sheet> + <div class="oe_chatter"> + <field name="message_follower_ids" widget="mail_followers"/> + <field name="message_ids" widget="mail_thread"/> + </div> </form> </field> </record> diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index 86259b12..f276275d 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -70,5 +70,16 @@ <field name="number_next">1</field> <field name="number_increment">1</field> </record> + + <record id="sequence_automatic_purchase" model="ir.sequence"> + <field name="name">Automatic Purchase</field> + <field name="code">automatic.purchase</field> + <field name="active">TRUE</field> + <field name="prefix">APO/%(year)s/</field> + <field name="padding">5</field> + <field name="number_next">1</field> + <field name="number_increment">1</field> + </record> + </data> </odoo>
\ No newline at end of file |
